mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-12 08:31:21 +00:00
rename APIClient to ApiClient, APIClientException to APIException
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace {{invokerPackage}};
|
||||
|
||||
class APIClient {
|
||||
class ApiClient {
|
||||
|
||||
public static $PATCH = "PATCH";
|
||||
public static $POST = "POST";
|
||||
@@ -173,7 +173,7 @@ class APIClient {
|
||||
* @param array $headerParams parameters to be place in request header
|
||||
* @return mixed
|
||||
*/
|
||||
public function callAPI($resourcePath, $method, $queryParams, $postData,
|
||||
public function callApi($resourcePath, $method, $queryParams, $postData,
|
||||
$headerParams, $authSettings) {
|
||||
|
||||
$headers = array();
|
||||
@@ -228,7 +228,7 @@ class APIClient {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method != self::$GET) {
|
||||
throw new APIClientException('Method ' . $method . ' is not recognized.');
|
||||
throw new ApiException('Method ' . $method . ' is not recognized.');
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
|
||||
@@ -256,7 +256,7 @@ class APIClient {
|
||||
|
||||
// Handle the response
|
||||
if ($response_info['http_code'] == 0) {
|
||||
throw new APIClientException("TIMEOUT: api call to " . $url .
|
||||
throw new ApiException("TIMEOUT: api call to " . $url .
|
||||
" took more than 5s to return", 0, $response_info, $response);
|
||||
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
|
||||
$data = json_decode($response);
|
||||
@@ -264,12 +264,12 @@ class APIClient {
|
||||
$data = $response;
|
||||
}
|
||||
} else if ($response_info['http_code'] == 401) {
|
||||
throw new APIClientException("Unauthorized API request to " . $url .
|
||||
throw new ApiException("Unauthorized API request to " . $url .
|
||||
": " . serialize($response), 0, $response_info, $response);
|
||||
} else if ($response_info['http_code'] == 404) {
|
||||
$data = null;
|
||||
} else {
|
||||
throw new APIClientException("Can't connect to the api: " . $url .
|
||||
throw new ApiException("Can't connect to the api: " . $url .
|
||||
" response code: " .
|
||||
$response_info['http_code'], 0, $response_info, $response);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace {{invokerPackage}};
|
||||
|
||||
use \Exception;
|
||||
|
||||
class APIClientException extends Exception {
|
||||
class ApiException extends Exception {
|
||||
protected $response, $response_info;
|
||||
|
||||
public function __construct($message="", $code=0, $response_info=null, $response=null) {
|
||||
@@ -28,7 +28,7 @@ class {{classname}} {
|
||||
function __construct($apiClient = null) {
|
||||
if (null === $apiClient) {
|
||||
if (Configuration::$apiClient === null) {
|
||||
Configuration::$apiClient = new APIClient(); // create a new API client if not present
|
||||
Configuration::$apiClient = new ApiClient(); // create a new API client if not present
|
||||
$this->apiClient = Configuration::$apiClient;
|
||||
}
|
||||
else
|
||||
@@ -38,7 +38,7 @@ class {{classname}} {
|
||||
}
|
||||
}
|
||||
|
||||
private $apiClient; // instance of the APIClient
|
||||
private $apiClient; // instance of the ApiClient
|
||||
|
||||
/**
|
||||
* get the API client
|
||||
|
||||
@@ -31,7 +31,7 @@ class Configuration {
|
||||
public static $username = '';
|
||||
public static $password = '';
|
||||
|
||||
// an instance of APIClient
|
||||
// an instance of ApiClient
|
||||
public static $apiClient;
|
||||
|
||||
// debugging
|
||||
@@ -39,11 +39,11 @@ class Configuration {
|
||||
public static $debug_file = 'php://output'; //output debug log to STDOUT by default
|
||||
|
||||
/*
|
||||
* manually initalize API client
|
||||
* manually initalize Api client
|
||||
*/
|
||||
public static function init() {
|
||||
if (self::$apiClient === null)
|
||||
self::$apiClient = new APIClient();
|
||||
self::$apiClient = new ApiClient();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user