Skip to content

Commit

Permalink
API versioning (#16)
Browse files Browse the repository at this point in the history
* add version option

* support versioning

---------

Co-authored-by: nVuln <[email protected]>
  • Loading branch information
fgmpr and nVuln authored Apr 22, 2023
1 parent 3362231 commit 0d7edef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@
*/
class Client
{
private CONST DEFAULT_VERSION = '202212';
protected $app_key;
protected $app_secret;
protected $shop_id;
protected $access_token;
protected $sandbox;
protected $version;

/**
* custom guzzle client options
Expand All @@ -68,12 +70,13 @@ class Client
Promotion::class,
];

public function __construct($app_key, $app_secret, $shop_id = null, $sandbox = false, $options = [])
public function __construct($app_key, $app_secret, $shop_id = null, $sandbox = false, $version = self::DEFAULT_VERSION, $options = [])
{
$this->app_key = $app_key;
$this->app_secret = $app_secret;
$this->shop_id = $shop_id;
$this->sandbox = $sandbox;
$this->version = $version;
$this->options = $options;
}

Expand Down Expand Up @@ -125,6 +128,7 @@ protected function httpClient()

$query['app_key'] = $this->getAppKey();
$query['timestamp'] = time();
$query['version'] = $this->version;
if ($this->shop_id && !isset($query['shop_id'])) {
$query['shop_id'] = $this->shop_id;
}
Expand Down

0 comments on commit 0d7edef

Please sign in to comment.