1
0
mirror of synced 2024-11-25 06:46:07 +03:00

+deliveryServices methods

This commit is contained in:
Grisha Pomadchin 2014-03-22 15:09:44 +04:00
parent 0e17e6c541
commit 4f678f35d8

View File

@ -5,7 +5,8 @@ class RestApi
{ {
protected $apiUrl; protected $apiUrl;
protected $apiKey; protected $apiKey;
protected $apiVersion = '1'; protected $apiVersion = '2';
protected $generatedAt;
protected $parameters; protected $parameters;
@ -282,6 +283,34 @@ class RestApi
return $result; 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 $result;
} }
/**
* @return \DateTime
*/
public function getGeneratedAt() {
return $this->generatedAt;
}
protected function getErrorMessage($response) protected function getErrorMessage($response)
{ {
$str = ''; $str = '';
@ -511,6 +547,11 @@ class RestApi
throw new Exception\ApiException($this->getErrorMessage($result), $statusCode); throw new Exception\ApiException($this->getErrorMessage($result), $statusCode);
} }
if (isset($result['generatedAt'])) {
$this->generatedAt = new \DateTime($result['generatedAt']);
unset($result['generatedAt']);
}
unset($result['success']); unset($result['success']);
if (count($result) == 0) if (count($result) == 0)