diff --git a/lib/IntaroCrm/RestApi.php b/lib/IntaroCrm/RestApi.php index 0ad8d22..9576d9e 100644 --- a/lib/IntaroCrm/RestApi.php +++ b/lib/IntaroCrm/RestApi.php @@ -5,7 +5,8 @@ class RestApi { protected $apiUrl; protected $apiKey; - protected $apiVersion = '1'; + protected $apiVersion = '2'; + protected $generatedAt; protected $parameters; @@ -282,6 +283,34 @@ class RestApi return $result; } + /** + * Получение списка служб доставки + * + * @return array - массив типов доставки + */ + public function deliveryServicesList() + { + $url = $this->apiUrl.'reference/delivery-services'; + $result = $this->curlRequest($url); + return $result; + } + + /** + * Редактирование службы доставки + * + * @param array $deliveryService - информация о типе доставки + * @return array + */ + public function deliveryServiceEdit($deliveryService) + { + $dataJson = json_encode($deliveryService); + $this->parameters['deliveryService'] = $dataJson; + + $url = $this->apiUrl.'reference/delivery-services/'.$deliveryService['code'].'/edit'; + $result = $this->curlRequest($url, 'POST'); + return $result; + } + /** * Получение списка типов оплаты @@ -451,6 +480,13 @@ class RestApi return $result; } + /** + * @return \DateTime + */ + public function getGeneratedAt() { + return $this->generatedAt; + } + protected function getErrorMessage($response) { $str = ''; @@ -511,6 +547,11 @@ class RestApi throw new Exception\ApiException($this->getErrorMessage($result), $statusCode); } + if (isset($result['generatedAt'])) { + $this->generatedAt = new \DateTime($result['generatedAt']); + unset($result['generatedAt']); + } + unset($result['success']); if (count($result) == 0)