Neur0toxine
5f69051859
* New module structure (refactoring) * Simple serializer and deserializer with models, new architecture * Move logic to strategies * Partial api client facade implementation (full implementation is not necessary for now) * Loyalty feature installer * Sms verification order (#167) * Make updater self-sufficient * Fix for order submit & fix for incorrect component rendering in the constructor * Fix for loyalty personal area error handling * Fix for cart component identity * Fix for softlock when customer cannot be registered in loyalty Co-authored-by: Сергей Чазов <45812598+Chazovs@users.noreply.github.com> Co-authored-by: Sergey Chazov <oitv18@gmail.com>
63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* PHP version 7.1
|
|
*
|
|
* @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
|
|
{
|
|
$response = $this->client->ordersCreate($request, 'externalId', $site);
|
|
|
|
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);
|
|
}
|
|
}
|