add file response for php

This commit is contained in:
wing328
2015-06-26 17:06:30 +08:00
parent 4c2df94ec7
commit fcd0b31d7d
22 changed files with 154 additions and 153 deletions

View File

@@ -90,7 +90,7 @@ class ApiClient {
* @throws \{{invokerPackage}}\ApiException on a non 2xx response
* @return mixed
*/
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams) {
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType=null) {
$headers = array();
@@ -174,6 +174,11 @@ class ApiClient {
if ($response_info['http_code'] == 0) {
throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null);
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
// return raw body if response is a file
if ($responseType == 'SplFileObject') {
return array($http_body, $http_header);
}
$data = json_decode($http_body);
if (json_last_error() > 0) { // if response is a string
$data = $http_body;