Skip to content

Commit

Permalink
[Fixes #79] Api Versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
tareqtms committed May 22, 2019
1 parent a2b4237 commit a1fcdec
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/ShopifySDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ class ShopifySDK
*
* @var array
*/
public static $config = array();
public static $config = array(
'ApiVersion' => '2019-04'
);

/**
* List of available resources which can be called from this client
Expand Down Expand Up @@ -225,8 +227,7 @@ class ShopifySDK
public function __construct($config = array())
{
if(!empty($config)) {
ShopifySDK::$config = $config;
ShopifySDK::setAdminUrl();
ShopifySDK::config($config);
}
}

Expand Down Expand Up @@ -315,13 +316,14 @@ public static function setAdminUrl()

//Remove https:// and trailing slash (if provided)
$shopUrl = preg_replace('#^https?://|/$#', '', $shopUrl);
$apiVersion = self::$config['ApiVersion'];

if(isset(self::$config['ApiKey']) && isset(self::$config['Password'])) {
$apiKey = self::$config['ApiKey'];
$apiPassword = self::$config['Password'];
$adminUrl = "https://$apiKey:$apiPassword@$shopUrl/admin/";
$adminUrl = "https://$apiKey:$apiPassword@$shopUrl/admin/api/$apiVersion/";
} else {
$adminUrl = "https://$shopUrl/admin/";
$adminUrl = "https://$shopUrl/admin/api/$apiVersion/";
}

self::$config['AdminUrl'] = $adminUrl;
Expand Down

0 comments on commit a1fcdec

Please sign in to comment.