Skip to content

Commit 67b641f

Browse files
committed
Add api_url and login_url config options
1 parent 257ce41 commit 67b641f

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/Bigcommerce/Api/Client.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ public static function configureOAuth($settings)
115115
throw new Exception("'store_hash' must be provided");
116116
}
117117

118+
if (isset($settings['api_url'])) {
119+
self::$api_url = $settings['api_url'];
120+
}
121+
122+
if (isset($settings['login_url'])) {
123+
self::$login_url = $settings['login_url'];
124+
}
125+
118126
self::$client_id = $settings['client_id'];
119127
self::$auth_token = $settings['auth_token'];
120128
self::$store_hash = $settings['store_hash'];

test/Unit/Api/ClientTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,4 +1084,22 @@ public function testUpdatingOptionValuePutsToTheOptionValueResource()
10841084

10851085
Client::updateOptionValue(1, 1, array());
10861086
}
1087+
1088+
public function testConnectionUsesApiUrlOverride()
1089+
{
1090+
$this->connection->expects($this->once())
1091+
->method('get')
1092+
->with('https://api.url.com/time');
1093+
1094+
Client::configureOAuth([
1095+
'client_id' => '123',
1096+
'auth_token' => '123xyz',
1097+
'store_hash' => 'abc123',
1098+
'api_url' => 'https://api.url.com',
1099+
'login_url' => 'https://login.url.com',
1100+
]);
1101+
Client::setConnection($this->connection); // re-set the connection since Client::setConnection unsets it
1102+
1103+
Client::getTime();
1104+
}
10871105
}

0 commit comments

Comments
 (0)