diff --git a/src/SpurClientBase.php b/src/SpurClientBase.php index 4fa4f63..d2435d5 100644 --- a/src/SpurClientBase.php +++ b/src/SpurClientBase.php @@ -8,12 +8,18 @@ abstract class SpurClientBase { protected $baseUrl; + protected $optional = ""; protected $authToken; protected $timeOffset; public function __construct($baseUrl, $authToken, $timeOffset = null) { $this->baseUrl = $baseUrl; + $optional_string = str_replace("http://", "", $baseUrl); + $optional_string = str_replace("https://", "", $optional_string); + $this->optional = strpos($optional_string, '/') === false + ? "" + : substr($optional_string, strpos($optional_string, '/')) + "/"; $this->authToken = $authToken; $this->timeOffset = $timeOffset; } @@ -56,7 +62,7 @@ public function delete($url, $params = []) public function send($method, $url, $options) { try { - return json_decode($this->getClient()->request($method, $url, $options)->getBody()->getContents(), true); + return json_decode($this->getClient()->request($method, $this->optional + $url, $options)->getBody()->getContents(), true); } catch (ClientException $e) { if ($e->getResponse()->getStatusCode() === 422) { $data = json_decode($e->getResponse()->getBody(), true);