From 0d7edefb4a6e903732f56f1dac9c210a386e61b7 Mon Sep 17 00:00:00 2001 From: Fatemeh Gholampour <90197805+fgmpr@users.noreply.github.com> Date: Sat, 22 Apr 2023 09:45:17 +0200 Subject: [PATCH] API versioning (#16) * add version option * support versioning --------- Co-authored-by: nVuln <54855446+nVuln@users.noreply.github.com> --- src/Client.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index e532981..5f1d807 100644 --- a/src/Client.php +++ b/src/Client.php @@ -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 @@ -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; } @@ -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; }