2022-03-02 15:40:53 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @category Integration
|
|
|
|
* @package Intaro\RetailCrm\Component\ApiClient\Traits
|
|
|
|
* @author RetailCRM <integration@retailcrm.ru>
|
|
|
|
* @license MIT
|
|
|
|
* @link http://retailcrm.ru
|
|
|
|
* @see http://retailcrm.ru/docs
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Intaro\RetailCrm\Component\ApiClient\Traits;
|
|
|
|
|
|
|
|
use Intaro\RetailCrm\Component\Json\Deserializer;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\OrdersCreateResponse;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\OrdersEditResponse;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\OrdersGetResponse;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Trait OrderTrait
|
|
|
|
* @package Intaro\RetailCrm\Component\ApiClient\Traits
|
|
|
|
*/
|
|
|
|
trait OrderTrait
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param array $request
|
|
|
|
* @param string|null $site
|
|
|
|
* @return \Intaro\RetailCrm\Model\Api\Response\OrdersCreateResponse|null
|
|
|
|
*/
|
|
|
|
public function createOrder(array $request, string $site = null): ?OrdersCreateResponse
|
|
|
|
{
|
2022-06-14 14:08:43 +03:00
|
|
|
$response = $this->client->ordersCreate($request, $site);
|
2022-03-02 15:40:53 +03:00
|
|
|
|
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), OrdersCreateResponse::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $request
|
|
|
|
* @param string|null $site
|
|
|
|
* @return \Intaro\RetailCrm\Model\Api\Response\OrdersEditResponse|null
|
|
|
|
*/
|
|
|
|
public function editOrder(array $request, string $site = null): ?OrdersEditResponse
|
|
|
|
{
|
|
|
|
$response = $this->client->ordersEdit($request, 'externalId', $site);
|
|
|
|
|
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), OrdersEditResponse::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $orderId
|
|
|
|
* @param string|null $site
|
|
|
|
* @return \Intaro\RetailCrm\Model\Api\Response\OrdersGetResponse|null
|
|
|
|
*/
|
|
|
|
public function getOrder(int $orderId, string $site = null): ?OrdersGetResponse
|
|
|
|
{
|
|
|
|
$response = $this->client->ordersGet($orderId, 'externalId', $site);
|
|
|
|
|
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), OrdersGetResponse::class);
|
|
|
|
}
|
|
|
|
}
|