Skip to content

Commit

Permalink
[Fixes #85] Separate AdminUrl and ApiUrl (Because of ApiVersion update
Browse files Browse the repository at this point in the history
  • Loading branch information
tareqtms committed May 23, 2019
1 parent 9b3fe3e commit c47eb45
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/ShopifyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function __construct($id = null, $parentResourceUrl = '')

$config = ShopifySDK::$config;

$this->resourceUrl = ($parentResourceUrl ? $parentResourceUrl . '/' : $config['AdminUrl']) . $this->getResourcePath() . ($this->id ? '/' . $this->id : '');
$this->resourceUrl = ($parentResourceUrl ? $parentResourceUrl . '/' : $config['ApiUrl']) . $this->getResourcePath() . ($this->id ? '/' . $this->id : '');

if (isset($config['AccessToken'])) {
$this->httpHeaders['X-Shopify-Access-Token'] = $config['AccessToken'];
Expand Down
14 changes: 12 additions & 2 deletions lib/ShopifySDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,13 @@ public static function setAdminUrl()
if(isset(self::$config['ApiKey']) && isset(self::$config['Password'])) {
$apiKey = self::$config['ApiKey'];
$apiPassword = self::$config['Password'];
$adminUrl = "https://$apiKey:$apiPassword@$shopUrl/admin/api/$apiVersion/";
$adminUrl = "https://$apiKey:$apiPassword@$shopUrl/admin/";
} else {
$adminUrl = "https://$shopUrl/admin/api/$apiVersion/";
$adminUrl = "https://$shopUrl/admin/";
}

self::$config['AdminUrl'] = $adminUrl;
self::$config['ApiUrl'] = $adminUrl . "api/$apiVersion/";

return $adminUrl;
}
Expand All @@ -340,6 +341,15 @@ public static function getAdminUrl() {
return self::$config['AdminUrl'];
}

/**
* Get the api url of the configured shop
*
* @return string
*/
public static function getApiUrl() {
return self::$config['ApiUrl'];
}

/**
* Maintain maximum 2 calls per second to the API
*
Expand Down

0 comments on commit c47eb45

Please sign in to comment.