diff --git a/src/Glassboxx/Request/AbstractRequest.php b/src/Glassboxx/Request/AbstractRequest.php index 74795df..a51cc3d 100644 --- a/src/Glassboxx/Request/AbstractRequest.php +++ b/src/Glassboxx/Request/AbstractRequest.php @@ -13,13 +13,17 @@ abstract class AbstractRequest { use UsesConfigTrait; - public const BASE_URL = 'https://server.glassboxx.co.uk/rest/V1'; + public const BASE_URL = 'https://server.glassboxx.co.uk'; /** @var HttpClient */ protected $client; - public function __construct(HttpClientInterface $client) + public function __construct(HttpClientInterface $client = null) { + if (!$client) { + $client = HttpClient::createForBaseUri(self::BASE_URL); + } + $this->client = $client; } } diff --git a/src/Glassboxx/Request/AuthTokenRequest.php b/src/Glassboxx/Request/AuthTokenRequest.php index 4790469..5333214 100644 --- a/src/Glassboxx/Request/AuthTokenRequest.php +++ b/src/Glassboxx/Request/AuthTokenRequest.php @@ -10,7 +10,7 @@ final class AuthTokenRequest extends AbstractRequest implements AuthTokenRequest { $response = $this->client->request( 'POST', - self::BASE_URL.self::ENDPOINT, + self::ENDPOINT, [ 'query' => [ 'password' => $this->config->getPassword(), diff --git a/src/Glassboxx/Request/AuthTokenRequestInterface.php b/src/Glassboxx/Request/AuthTokenRequestInterface.php index fad8996..5423480 100644 --- a/src/Glassboxx/Request/AuthTokenRequestInterface.php +++ b/src/Glassboxx/Request/AuthTokenRequestInterface.php @@ -6,7 +6,7 @@ namespace Opdavies\Glassboxx\Request; interface AuthTokenRequestInterface { - public const ENDPOINT = '/integration/admin/token'; + public const ENDPOINT = '/rest/V1/integration/admin/token'; public function getToken(): string; } diff --git a/src/Glassboxx/Request/CustomerRequest.php b/src/Glassboxx/Request/CustomerRequest.php index e3f8d75..d290060 100644 --- a/src/Glassboxx/Request/CustomerRequest.php +++ b/src/Glassboxx/Request/CustomerRequest.php @@ -34,7 +34,7 @@ final class CustomerRequest extends AbstractRequest implements CustomerRequestIn $response = $this->client->request( 'POST', - self::BASE_URL . self::ENDPOINT, + self::ENDPOINT, [ 'auth_bearer' => $this->authToken, 'headers' => [ diff --git a/src/Glassboxx/Request/CustomerRequestInterface.php b/src/Glassboxx/Request/CustomerRequestInterface.php index 2586988..afa0464 100644 --- a/src/Glassboxx/Request/CustomerRequestInterface.php +++ b/src/Glassboxx/Request/CustomerRequestInterface.php @@ -8,7 +8,7 @@ use Opdavies\Glassboxx\ValueObject\CustomerInterface; interface CustomerRequestInterface { - public const ENDPOINT = '/glassboxxorder/customCustomer'; + public const ENDPOINT = '/rest/V1/glassboxxorder/customCustomer'; public function forCustomer(CustomerInterface $customer): AbstractRequest; diff --git a/src/Glassboxx/Request/OrderRequest.php b/src/Glassboxx/Request/OrderRequest.php index db04fc4..ee6bb2c 100644 --- a/src/Glassboxx/Request/OrderRequest.php +++ b/src/Glassboxx/Request/OrderRequest.php @@ -47,7 +47,7 @@ class OrderRequest extends AbstractRequest implements OrderRequestInterface $response = $this->client->request( 'POST', - self::BASE_URL . self::ENDPOINT, + self::ENDPOINT, [ 'auth_bearer' => $this->authToken, 'headers' => [ diff --git a/src/Glassboxx/Request/OrderRequestInterface.php b/src/Glassboxx/Request/OrderRequestInterface.php index 1bb3628..6a55a76 100644 --- a/src/Glassboxx/Request/OrderRequestInterface.php +++ b/src/Glassboxx/Request/OrderRequestInterface.php @@ -8,7 +8,7 @@ use Opdavies\Glassboxx\ValueObject\OrderInterface; interface OrderRequestInterface { - public const ENDPOINT = '/glassboxxorder/toglassboxx'; + public const ENDPOINT = '/rest/V1/glassboxxorder/toglassboxx'; public function forOrder(OrderInterface $order): AbstractRequest; diff --git a/tests/Glassboxx/Request/AuthTokenRequestTest.php b/tests/Glassboxx/Request/AuthTokenRequestTest.php index 0ac805a..ad3c5bd 100644 --- a/tests/Glassboxx/Request/AuthTokenRequestTest.php +++ b/tests/Glassboxx/Request/AuthTokenRequestTest.php @@ -22,8 +22,7 @@ class AuthTokenRequestTest extends TestCase ->method('request') ->with( 'POST', - AuthTokenRequest::BASE_URL - .AuthTokenRequest::ENDPOINT, + AuthTokenRequest::ENDPOINT, [ 'query' => [ 'password' => 'secret', diff --git a/tests/Glassboxx/Request/CustomerRequestTest.php b/tests/Glassboxx/Request/CustomerRequestTest.php index d20a8b8..cf5b118 100644 --- a/tests/Glassboxx/Request/CustomerRequestTest.php +++ b/tests/Glassboxx/Request/CustomerRequestTest.php @@ -31,8 +31,7 @@ final class CustomerRequestTest extends TestCase ->method('request') ->with( 'POST', - CustomerRequest::BASE_URL - .CustomerRequest::ENDPOINT, + CustomerRequest::ENDPOINT, [ 'auth_bearer' => $authTokenRequest->getToken(), 'headers' => [ diff --git a/tests/Glassboxx/Request/OrderRequestTest.php b/tests/Glassboxx/Request/OrderRequestTest.php index 4993266..743e5f1 100644 --- a/tests/Glassboxx/Request/OrderRequestTest.php +++ b/tests/Glassboxx/Request/OrderRequestTest.php @@ -43,8 +43,7 @@ final class OrderRequestTest extends TestCase ->method('request') ->with( 'POST', - OrderRequest::BASE_URL - .OrderRequest::ENDPOINT, + OrderRequest::ENDPOINT, [ 'auth_bearer' => $authTokenRequest->getToken(), 'headers' => [