Skip to content

Commit 4fbdef2

Browse files
authored
Add API Version (#29)
1 parent 1d0bb73 commit 4fbdef2

File tree

180 files changed

+248
-285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+248
-285
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
},
2020
"autoload": {
2121
"psr-4": {
22-
"Shopify\\" : "lib/",
22+
"Shopify\\" : "src/",
2323
"Shopify\\Test\\" : "test/"
2424
},
2525
"files" : [
26-
"lib/includes.php"
26+
"src/includes.php"
2727
]
2828
},
2929
"require-dev": {
@@ -33,6 +33,6 @@
3333
},
3434
"scripts" : {
3535
"lint" : "./vendor/bin/phplint ./ --exclude=vendor",
36-
"phpcs" : "./vendor/bin/phpcs ./lib"
36+
"phpcs" : "./vendor/bin/phpcs ./src"
3737
}
3838
}

lib/Enum/Fields/InventoryLevelFields.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

lib/Object/InventoryLevel.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

lib/Service/InventoryLevelService.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

lib/AbstractApi.php renamed to src/AbstractApi.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
abstract class AbstractApi implements ApiInterface
99
{
10+
const DEFAULT_API_VERSION = '2019-04';
11+
1012
/**
1113
* Domain of the Shopify store
1214
*
@@ -28,6 +30,13 @@ abstract class AbstractApi implements ApiInterface
2830
*/
2931
protected $logger;
3032

33+
/**
34+
* The API Version to use
35+
*
36+
* @var string
37+
*/
38+
protected $api_version = self::DEFAULT_API_VERSION;
39+
3140
/**
3241
* Build our private API instance
3342
*
@@ -112,7 +121,28 @@ public function getLogger()
112121
{
113122
return $this->logger;
114123
}
115-
124+
125+
/**
126+
* Set the API Version
127+
* @param $apiVersion
128+
* @return $this
129+
*/
130+
public function setApiVersion($apiVersion)
131+
{
132+
$this->api_version = $apiVersion;
133+
$this->init();
134+
return $this;
135+
}
136+
137+
/**
138+
* Get the API Version
139+
* @return string
140+
*/
141+
public function getApiVersion()
142+
{
143+
return $this->api_version;
144+
}
145+
116146
/**
117147
* Initialize our Client, using settings based on the app type
118148
*

lib/Api.php renamed to src/Api.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ public function init()
121121
{
122122
$args = array();
123123
if (!is_null($this->myshopify_domain)) {
124-
$args['base_uri'] = sprintf("https://%s", $this->myshopify_domain);
124+
$args['base_uri'] = sprintf(
125+
"https://%s/admin/api/%s",
126+
$this->myshopify_domain,
127+
$this->getApiVersion()
128+
);
125129
}
126130
if (!is_null($this->access_token)) {
127131
$args['headers']['X-Shopify-Access-Token'] = $this->access_token;
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)