forked from loafle/openapi-generator-original
moving $host back to ApiClient and making ApiClient setters fluent
This commit is contained in:
parent
99e963709b
commit
04be474f56
@ -31,6 +31,11 @@ class ApiClient {
|
||||
|
||||
protected $defaultHeaders = array();
|
||||
|
||||
/**
|
||||
* The host (from basePath)
|
||||
*/
|
||||
protected $host = '{{basePath}}';
|
||||
|
||||
/*
|
||||
* @var string timeout (second) of the HTTP request, by default set to 0, no timeout
|
||||
*/
|
||||
@ -49,7 +54,11 @@ class ApiClient {
|
||||
/**
|
||||
* @param ApiConfiguration $config config for this ApiClient
|
||||
*/
|
||||
function __construct(ApiConfiguration $config = null) {
|
||||
function __construct($host = null, ApiConfiguration $config = null) {
|
||||
if ($host != null) {
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
if ($config == null) {
|
||||
$config = ApiConfiguration::getDefaultConfiguration();
|
||||
}
|
||||
@ -69,6 +78,7 @@ class ApiClient {
|
||||
}
|
||||
|
||||
$this->defaultHeaders[$headerName] = $headerValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,6 +90,22 @@ class ApiClient {
|
||||
return $this->defaultHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @return ApiConfiguration
|
||||
*/
|
||||
public function setHost($host) {
|
||||
$this->host = $host;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHost() {
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete the default header based on header name
|
||||
*
|
||||
@ -99,6 +125,7 @@ class ApiClient {
|
||||
throw new \InvalidArgumentException('User-agent must be a string.');
|
||||
|
||||
$this->userAgent = $userAgent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,6 +147,7 @@ class ApiClient {
|
||||
throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.');
|
||||
|
||||
$this->curlTimeout = $seconds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,11 +21,6 @@ class ApiConfiguration {
|
||||
|
||||
private static $defaultConfiguration = null;
|
||||
|
||||
/**
|
||||
* The host (from basePath)
|
||||
*/
|
||||
protected $host = '{{basePath}}';
|
||||
|
||||
/**
|
||||
* Associate array to store API key(s)
|
||||
*/
|
||||
@ -56,22 +51,6 @@ class ApiConfiguration {
|
||||
*/
|
||||
protected $debugFile = 'php://output';
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @return ApiConfiguration
|
||||
*/
|
||||
public function setHost($host) {
|
||||
$this->host = $host;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHost() {
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
|
Loading…
x
Reference in New Issue
Block a user