1
0
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:
Marc Carmier 2017-12-18 12:29:51 +01:00
parent 5bbb26ace4
commit e14f758e66

View File

@ -137,9 +137,20 @@ class Api
throw new Exceptions\InvalidParameterException("Endpoint parameter is empty"); 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)) { if (!array_key_exists($api_endpoint, $this->endpoints)) {
throw new Exceptions\InvalidParameterException("Unknown provided endpoint"); throw new Exceptions\InvalidParameterException("Unknown provided endpoint");
} }
else
{
$this->endpoint = $this->endpoints[$api_endpoint];
}
}
if (!isset($http_client)) { if (!isset($http_client)) {
$http_client = new Client([ $http_client = new Client([
@ -149,7 +160,6 @@ class Api
} }
$this->application_key = $application_key; $this->application_key = $application_key;
$this->endpoint = $this->endpoints[$api_endpoint];
$this->application_secret = $application_secret; $this->application_secret = $application_secret;
$this->http_client = $http_client; $this->http_client = $http_client;
$this->consumer_key = $consumer_key; $this->consumer_key = $consumer_key;