mirror of
https://github.com/ovh/php-ovh.git
synced 2023-11-05 03:20:26 +01:00
Allow URL for api_endpoint specification
This commit is contained in:
parent
5bbb26ace4
commit
e14f758e66
12
src/Api.php
12
src/Api.php
@ -137,9 +137,20 @@ class Api
|
||||
throw new Exceptions\InvalidParameterException("Endpoint parameter is empty");
|
||||
}
|
||||
|
||||
if (preg_match('/^https?:\/\/..*/',$api_endpoint))
|
||||
{
|
||||
$this->endpoint = $api_endpoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!array_key_exists($api_endpoint, $this->endpoints)) {
|
||||
throw new Exceptions\InvalidParameterException("Unknown provided endpoint");
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->endpoint = $this->endpoints[$api_endpoint];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($http_client)) {
|
||||
$http_client = new Client([
|
||||
@ -149,7 +160,6 @@ class Api
|
||||
}
|
||||
|
||||
$this->application_key = $application_key;
|
||||
$this->endpoint = $this->endpoints[$api_endpoint];
|
||||
$this->application_secret = $application_secret;
|
||||
$this->http_client = $http_client;
|
||||
$this->consumer_key = $consumer_key;
|
||||
|
Loading…
Reference in New Issue
Block a user