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\Component\Json\Serializer;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Request\Loyalty\Account\LoyaltyAccountActivateRequest;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Request\Loyalty\Account\LoyaltyAccountCreateRequest;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Request\Loyalty\Account\LoyaltyAccountEditRequest;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Request\Loyalty\Account\LoyaltyAccountRequest;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\Loyalty\Account\LoyaltyAccountEditResponse;
|
2023-09-01 10:10:38 +03:00
|
|
|
use Intaro\RetailCrm\Model\Api\Response\Loyalty\Account\LoyaltyAccountGetResponse;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\Loyalty\Account\LoyaltyAccountsResponse;
|
2022-03-02 15:40:53 +03:00
|
|
|
use Intaro\RetailCrm\Model\Api\Request\Loyalty\LoyaltyCalculateRequest;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Request\Order\Loyalty\OrderLoyaltyApplyRequest;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationConfirmRequest;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\Loyalty\Account\LoyaltyAccountActivateResponse;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\Loyalty\Account\LoyaltyAccountCreateResponse;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\Loyalty\LoyaltyCalculateResponse;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\Loyalty\LoyaltyLoyaltiesResponse;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\Loyalty\LoyaltyLoyaltyResponse;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\Order\Loyalty\OrderLoyaltyApplyResponse;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationConfirmResponse;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationStatusRequest;
|
|
|
|
use Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationStatusResponse;
|
2023-09-01 10:10:38 +03:00
|
|
|
use ReflectionException;
|
2022-03-02 15:40:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Trait LoyaltyTrait
|
|
|
|
* @package Intaro\RetailCrm\Component\ApiClient\Traits
|
|
|
|
*/
|
|
|
|
trait LoyaltyTrait
|
|
|
|
{
|
|
|
|
/**
|
2023-09-01 10:10:38 +03:00
|
|
|
* @param SmsVerificationStatusRequest $request
|
|
|
|
*
|
|
|
|
* @return SmsVerificationStatusResponse|null
|
|
|
|
* @throws ReflectionException
|
2022-03-02 15:40:53 +03:00
|
|
|
*/
|
|
|
|
public function checkStatusPlVerification(SmsVerificationStatusRequest $request): ?SmsVerificationStatusResponse
|
|
|
|
{
|
|
|
|
$serialized = Serializer::serializeArray($request);
|
|
|
|
$response = $this->client->checkStatusPlVerification($serialized, $request->checkId);
|
|
|
|
|
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), SmsVerificationStatusResponse::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-09-01 10:10:38 +03:00
|
|
|
* @param OrderLoyaltyApplyRequest $request
|
|
|
|
*
|
|
|
|
* @return OrderLoyaltyApplyResponse|null
|
|
|
|
* @throws ReflectionException
|
2022-03-02 15:40:53 +03:00
|
|
|
*/
|
|
|
|
public function loyaltyOrderApply(OrderLoyaltyApplyRequest $request): ?OrderLoyaltyApplyResponse
|
|
|
|
{
|
|
|
|
$serialized = Serializer::serializeArray($request);
|
|
|
|
$response = $this->client->loyaltyOrderApply($serialized);
|
|
|
|
|
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), OrderLoyaltyApplyResponse::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-09-01 10:10:38 +03:00
|
|
|
* @param LoyaltyCalculateRequest $request
|
|
|
|
*
|
|
|
|
* @return LoyaltyCalculateResponse|null
|
|
|
|
* @throws ReflectionException
|
2022-03-02 15:40:53 +03:00
|
|
|
*/
|
|
|
|
public function loyaltyCalculate(LoyaltyCalculateRequest $request): ?LoyaltyCalculateResponse
|
|
|
|
{
|
|
|
|
$serialized = Serializer::serializeArray($request);
|
|
|
|
$response = $this->client->loyaltyOrderCalculate($serialized);
|
|
|
|
|
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), LoyaltyCalculateResponse::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-09-01 10:10:38 +03:00
|
|
|
* @param int $accountId
|
|
|
|
*
|
|
|
|
* @return LoyaltyAccountGetResponse|null
|
|
|
|
*/
|
|
|
|
public function getLoyaltyAccount(int $accountId): ?LoyaltyAccountGetResponse
|
|
|
|
{
|
|
|
|
$response = $this->client->getLoyaltyAccount($accountId);
|
|
|
|
|
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), LoyaltyAccountGetResponse::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param LoyaltyAccountRequest $request
|
|
|
|
*
|
|
|
|
* @return LoyaltyAccountsResponse|null
|
|
|
|
* @throws ReflectionException
|
|
|
|
*/
|
|
|
|
public function getLoyaltyAccounts(LoyaltyAccountRequest $request): ?LoyaltyAccountsResponse
|
|
|
|
{
|
|
|
|
$serialized = Serializer::serializeArray($request);
|
|
|
|
$response = $this->client->getLoyaltyAccounts($serialized);
|
|
|
|
|
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), LoyaltyAccountsResponse::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param LoyaltyAccountCreateRequest $request
|
|
|
|
*
|
|
|
|
* @return LoyaltyAccountCreateResponse|null
|
|
|
|
* @throws ReflectionException
|
2022-03-02 15:40:53 +03:00
|
|
|
*/
|
|
|
|
public function createLoyaltyAccount(LoyaltyAccountCreateRequest $request): ?LoyaltyAccountCreateResponse
|
|
|
|
{
|
|
|
|
$serialized = Serializer::serializeArray($request);
|
|
|
|
$response = $this->client->createLoyaltyAccount($serialized);
|
|
|
|
|
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), LoyaltyAccountCreateResponse::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-09-01 10:10:38 +03:00
|
|
|
* @param LoyaltyAccountEditRequest $request
|
|
|
|
*
|
|
|
|
* @return LoyaltyAccountEditResponse|null
|
|
|
|
* @throws ReflectionException
|
2022-03-02 15:40:53 +03:00
|
|
|
*/
|
2023-09-01 10:10:38 +03:00
|
|
|
public function editLoyaltyAccount(LoyaltyAccountEditRequest $request): ?LoyaltyAccountEditResponse
|
2022-03-02 15:40:53 +03:00
|
|
|
{
|
|
|
|
$serialized = Serializer::serializeArray($request);
|
2023-09-01 10:10:38 +03:00
|
|
|
$response = $this->client->editLoyaltyAccount($serialized, $request->id);
|
2022-03-02 15:40:53 +03:00
|
|
|
|
2023-09-01 10:10:38 +03:00
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), LoyaltyAccountEditResponse::class);
|
2022-03-02 15:40:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-09-01 10:10:38 +03:00
|
|
|
* @param LoyaltyAccountActivateRequest $request
|
|
|
|
*
|
|
|
|
* @return LoyaltyAccountActivateResponse|null
|
|
|
|
* @throws ReflectionException
|
2022-03-02 15:40:53 +03:00
|
|
|
*/
|
2023-09-01 10:10:38 +03:00
|
|
|
public function activateLoyaltyAccount(LoyaltyAccountActivateRequest $request): ?LoyaltyAccountActivateResponse
|
2022-03-02 15:40:53 +03:00
|
|
|
{
|
|
|
|
$serialized = Serializer::serializeArray($request);
|
2023-09-01 10:10:38 +03:00
|
|
|
$response = $this->client->activateLoyaltyAccount($serialized['id']);
|
2022-03-02 15:40:53 +03:00
|
|
|
|
2023-09-01 10:10:38 +03:00
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), LoyaltyAccountActivateResponse::class);
|
2022-03-02 15:40:53 +03:00
|
|
|
}
|
|
|
|
|
2023-09-01 10:10:38 +03:00
|
|
|
|
2022-03-02 15:40:53 +03:00
|
|
|
/**
|
2023-09-01 10:10:38 +03:00
|
|
|
* @param SmsVerificationConfirmRequest $request
|
|
|
|
*
|
|
|
|
* @return LoyaltyAccountActivateResponse|null
|
|
|
|
* @throws ReflectionException
|
2022-03-02 15:40:53 +03:00
|
|
|
*/
|
2023-09-01 10:10:38 +03:00
|
|
|
public function sendVerificationCode(SmsVerificationConfirmRequest $request): ?SmsVerificationConfirmResponse
|
2022-03-02 15:40:53 +03:00
|
|
|
{
|
|
|
|
$serialized = Serializer::serializeArray($request);
|
2023-09-01 10:10:38 +03:00
|
|
|
$response = $this->client->sendVerificationCode($serialized);
|
2022-03-02 15:40:53 +03:00
|
|
|
|
2023-09-01 10:10:38 +03:00
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), SmsVerificationConfirmResponse::class);
|
2022-03-02 15:40:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $loyaltyId
|
|
|
|
*
|
2023-09-01 10:10:38 +03:00
|
|
|
* @return LoyaltyLoyaltyResponse|null
|
2022-03-02 15:40:53 +03:00
|
|
|
*/
|
|
|
|
public function getLoyaltyLoyalty(int $loyaltyId): ?LoyaltyLoyaltyResponse
|
|
|
|
{
|
|
|
|
$response = $this->client->getLoyaltyLoyalty($loyaltyId);
|
|
|
|
|
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), LoyaltyLoyaltyResponse::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-09-01 10:10:38 +03:00
|
|
|
* @return LoyaltyLoyaltiesResponse|null
|
2022-03-02 15:40:53 +03:00
|
|
|
*/
|
|
|
|
public function getLoyaltyLoyalties(): ?LoyaltyLoyaltiesResponse
|
|
|
|
{
|
|
|
|
$response = $this->client->getLoyaltyLoyalties();
|
|
|
|
|
|
|
|
return Deserializer::deserializeArray($response->getResponseBody(), LoyaltyLoyaltiesResponse::class);
|
|
|
|
}
|
2024-04-29 11:44:31 +03:00
|
|
|
}
|