From 8d5d526f362958a69c587b5219786589787a9163 Mon Sep 17 00:00:00 2001 From: EugeneGpil Date: Thu, 12 Mar 2020 13:23:39 +0300 Subject: [PATCH 1/2] subdomain --- src/Components/Http/MoySkladHttpClient.php | 4 ++-- src/MoySklad.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Components/Http/MoySkladHttpClient.php b/src/Components/Http/MoySkladHttpClient.php index a6ab569..d1b6d34 100644 --- a/src/Components/Http/MoySkladHttpClient.php +++ b/src/Components/Http/MoySkladHttpClient.php @@ -20,17 +20,17 @@ class MoySkladHttpClient{ private $preRequestSleepTime = 200; private - $endpoint = "https://online.moysklad.ru/api/remap/1.1/", $posEndpoint = "https://online.moysklad.ru/api/posap/1.0/", $login, $password, $posToken; - public function __construct($login, $password, $posToken) + public function __construct($login, $password, $posToken, $subdomain = "online") { $this->login = $login; $this->password = $password; $this->posToken = $posToken; + $this->endpoin = "https://" . $subdomain . ".moysklad.ru/api/remap/1.1/"; } public function setPosToken($posToken){ diff --git a/src/MoySklad.php b/src/MoySklad.php index 3d0ec5a..b18cbd1 100644 --- a/src/MoySklad.php +++ b/src/MoySklad.php @@ -22,9 +22,9 @@ class MoySklad{ */ private static $instances = []; - private function __construct($login, $password, $posToken, $hashCode) + private function __construct($login, $password, $posToken, $hashCode, $subdomain = "online") { - $this->client = new MoySkladHttpClient($login, $password, $posToken); + $this->client = new MoySkladHttpClient($login, $password, $posToken, $subdomain); $this->hashCode = $hashCode; } @@ -45,10 +45,10 @@ private static function makeHash($login, $password){ * @param $posToken * @return MoySklad */ - public static function getInstance($login, $password, $posToken = null){ + public static function getInstance($login, $password, $subdomain = "online", $posToken = null){ $hash = static::makeHash($login, $password); if ( empty(static::$instances[$hash]) ){ - static::$instances[$hash] = new static($login, $password, $posToken, $hash); + static::$instances[$hash] = new static($login, $password, $posToken, $hash, $subdomain); EntityRegistry::instance()->bootEntities(); } return static::$instances[$hash]; From 41d7dde564d3da223453e248b0db6c36a3b0eb02 Mon Sep 17 00:00:00 2001 From: EugeneGpil Date: Thu, 12 Mar 2020 14:17:49 +0300 Subject: [PATCH 2/2] endpoint fix --- src/Components/Http/MoySkladHttpClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Http/MoySkladHttpClient.php b/src/Components/Http/MoySkladHttpClient.php index d1b6d34..3e8fdb1 100644 --- a/src/Components/Http/MoySkladHttpClient.php +++ b/src/Components/Http/MoySkladHttpClient.php @@ -30,7 +30,7 @@ public function __construct($login, $password, $posToken, $subdomain = "online") $this->login = $login; $this->password = $password; $this->posToken = $posToken; - $this->endpoin = "https://" . $subdomain . ".moysklad.ru/api/remap/1.1/"; + $this->endpoint = "https://" . $subdomain . ".moysklad.ru/api/remap/1.1/"; } public function setPosToken($posToken){