From 67b641f6bf512bdef2d5ee27f5585e13a5b36cf8 Mon Sep 17 00:00:00 2001 From: Roberto Alvarez Date: Mon, 2 Oct 2023 15:26:58 -0500 Subject: [PATCH 1/3] Add api_url and login_url config options --- src/Bigcommerce/Api/Client.php | 8 ++++++++ test/Unit/Api/ClientTest.php | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/Bigcommerce/Api/Client.php b/src/Bigcommerce/Api/Client.php index 308c4cb..f893667 100644 --- a/src/Bigcommerce/Api/Client.php +++ b/src/Bigcommerce/Api/Client.php @@ -115,6 +115,14 @@ public static function configureOAuth($settings) throw new Exception("'store_hash' must be provided"); } + if (isset($settings['api_url'])) { + self::$api_url = $settings['api_url']; + } + + if (isset($settings['login_url'])) { + self::$login_url = $settings['login_url']; + } + self::$client_id = $settings['client_id']; self::$auth_token = $settings['auth_token']; self::$store_hash = $settings['store_hash']; diff --git a/test/Unit/Api/ClientTest.php b/test/Unit/Api/ClientTest.php index b8e8db4..0a3890f 100644 --- a/test/Unit/Api/ClientTest.php +++ b/test/Unit/Api/ClientTest.php @@ -1084,4 +1084,22 @@ public function testUpdatingOptionValuePutsToTheOptionValueResource() Client::updateOptionValue(1, 1, array()); } + + public function testConnectionUsesApiUrlOverride() + { + $this->connection->expects($this->once()) + ->method('get') + ->with('https://api.url.com/time'); + + Client::configureOAuth([ + 'client_id' => '123', + 'auth_token' => '123xyz', + 'store_hash' => 'abc123', + 'api_url' => 'https://api.url.com', + 'login_url' => 'https://login.url.com', + ]); + Client::setConnection($this->connection); // re-set the connection since Client::setConnection unsets it + + Client::getTime(); + } } From b7d408b1230ddb97feea9064942e94f3ad2de95f Mon Sep 17 00:00:00 2001 From: Roberto Alvarez Date: Mon, 2 Oct 2023 15:37:55 -0500 Subject: [PATCH 2/3] Remove stale dependency codeless/jugglecode --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 09d90ff..6affced 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,6 @@ "ext-curl": "*" }, "require-dev": { - "codeless/jugglecode": "1.0", "friendsofphp/php-cs-fixer": "^3.13", "php-coveralls/php-coveralls": "2.5", "phpunit/phpunit": "^9.5", From 738593849cb649d969ca19e61179bc7673b19b70 Mon Sep 17 00:00:00 2001 From: Roberto Alvarez Date: Tue, 3 Oct 2023 09:23:07 -0500 Subject: [PATCH 3/3] Fix phpstan issues --- .phpstan/baseline.neon | 10 ---------- src/Bigcommerce/Api/Client.php | 8 ++++---- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.phpstan/baseline.neon b/.phpstan/baseline.neon index b34c34e..de83541 100644 --- a/.phpstan/baseline.neon +++ b/.phpstan/baseline.neon @@ -1,10 +1,5 @@ parameters: ignoreErrors: - - - message: "#^Call to function is_string\\(\\) with stdClass will always evaluate to false\\.$#" - count: 2 - path: ../src/Bigcommerce/Api/Client.php - - message: "#^Method Bigcommerce\\\\Api\\\\Client\\:\\:createCoupon\\(\\) has parameter \\$object with no type specified\\.$#" count: 1 @@ -500,11 +495,6 @@ parameters: count: 1 path: ../src/Bigcommerce/Api/Filter.php - - - message: "#^Method Bigcommerce\\\\Api\\\\Filter\\:\\:__set\\(\\) has no return type specified\\.$#" - count: 1 - path: ../src/Bigcommerce/Api/Filter.php - - message: "#^Method Bigcommerce\\\\Api\\\\Filter\\:\\:__set\\(\\) has parameter \\$parameter with no type specified\\.$#" count: 1 diff --git a/src/Bigcommerce/Api/Client.php b/src/Bigcommerce/Api/Client.php index f893667..1cd61e9 100644 --- a/src/Bigcommerce/Api/Client.php +++ b/src/Bigcommerce/Api/Client.php @@ -398,8 +398,8 @@ private static function mapCollectionObject($object) * Map a single object to a resource class. * * @param string $resource name of the resource class - * @param \stdClass $object - * @return Resource + * @param \stdClass|boolean|string $object + * @return bool|\stdClass|string */ private static function mapResource($resource, $object) { @@ -415,8 +415,8 @@ private static function mapResource($resource, $object) /** * Map object representing a count to an integer value. * - * @param \stdClass $object - * @return int + * @param \stdClass|boolean|string $object + * @return int|boolean */ private static function mapCount($object) {