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,8 +137,19 @@ class Api
throw new Exceptions\InvalidParameterException("Endpoint parameter is empty");
}
if (!array_key_exists($api_endpoint, $this->endpoints)) {
throw new Exceptions\InvalidParameterException("Unknown provided endpoint");
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)) {
@ -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;