add loyalty trait
This commit is contained in:
parent
94296303e0
commit
ae34da0214
9 changed files with 130 additions and 64 deletions
|
@ -2941,50 +2941,43 @@ class ApiClient
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationConfirmRequest $request
|
||||
* @return \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationConfirmResponse|null
|
||||
* @param array $request
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
protected function confirmLpVerificationBySMS(SmsVerificationConfirmRequest $request): ?SmsVerificationConfirmResponse
|
||||
protected function confirmLpVerificationBySMS(array $request): ApiResponse
|
||||
{
|
||||
$serialized = Serializer::serializeArray($request);
|
||||
$response = $this->client->makeRequest(
|
||||
return $this->client->makeRequest(
|
||||
'/verification/sms/confirm',
|
||||
Client::METHOD_POST,
|
||||
$serialized
|
||||
$request
|
||||
);
|
||||
|
||||
return Deserializer::deserializeArray($response->getResponseBody(), SmsVerificationConfirmResponse::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationCreateRequest $request
|
||||
* @return \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationCreateResponse|null
|
||||
* @param array $request
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
protected function sendSmsForLpVerification(SmsVerificationCreateRequest $request): ?SmsVerificationCreateResponse
|
||||
protected function sendSmsForLpVerification(array $request): ApiResponse
|
||||
{
|
||||
$serialized = Serializer::serializeArray($request);
|
||||
$response = $this->client->makeRequest(
|
||||
return $this->client->makeRequest(
|
||||
'/verification/sms/send',
|
||||
Client::METHOD_POST,
|
||||
$serialized
|
||||
$request
|
||||
);
|
||||
|
||||
return Deserializer::deserializeArray($response->getResponseBody(), SmsVerificationCreateResponse::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationStatusRequest $request
|
||||
* @return \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationStatusResponse|null
|
||||
* @param array $request
|
||||
* @param int $checkId
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
protected function checkStatusPlVerification(SmsVerificationStatusRequest $request): ?SmsVerificationStatusResponse
|
||||
protected function checkStatusPlVerification(array $request, int $checkId): ApiResponse
|
||||
{
|
||||
$serialized = Serializer::serializeArray($request);
|
||||
$response = $this->client->makeRequest(
|
||||
"/verification/sms/$request->checkId/status",
|
||||
return $this->client->makeRequest(
|
||||
"/verification/sms/$checkId/status",
|
||||
Client::METHOD_GET,
|
||||
$serialized
|
||||
$request
|
||||
);
|
||||
|
||||
return Deserializer::deserializeArray($response->getResponseBody(), SmsVerificationStatusResponse::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Intaro\RetailCrm\Component\ApiClient;
|
|||
|
||||
use Intaro\RetailCrm\Component\ApiClient\Traits\CustomersCorporateTrait;
|
||||
use Intaro\RetailCrm\Component\ApiClient\Traits\CustomersTrait;
|
||||
use Intaro\RetailCrm\Component\ApiClient\Traits\LoyaltyTrait;
|
||||
use Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationConfirmRequest;
|
||||
use Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationCreateRequest;
|
||||
use Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationStatusRequest;
|
||||
|
@ -108,6 +109,7 @@ class ClientAdapter
|
|||
{
|
||||
use CustomersTrait;
|
||||
use CustomersCorporateTrait;
|
||||
use LoyaltyTrait;
|
||||
|
||||
/** @var string */
|
||||
public const ID = 'id';
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?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\Component\Json\Serializer;
|
||||
use Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationConfirmRequest;
|
||||
use Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationCreateRequest;
|
||||
use Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationConfirmResponse;
|
||||
use Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationCreateResponse;
|
||||
use Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationStatusRequest;
|
||||
use Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationStatusResponse;
|
||||
|
||||
trait LoyaltyTrait
|
||||
{
|
||||
/**
|
||||
* @param \Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationConfirmRequest $request
|
||||
* @return \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationConfirmResponse|null
|
||||
*/
|
||||
protected function confirmLpVerificationBySMS(SmsVerificationConfirmRequest $request): ?SmsVerificationConfirmResponse
|
||||
{
|
||||
$serialized = Serializer::serializeArray($request);
|
||||
$response = $this->client->confirmLpVerificationBySMS($serialized);
|
||||
|
||||
return Deserializer::deserializeArray($response->getResponseBody(), SmsVerificationConfirmResponse::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationCreateRequest $request
|
||||
* @return \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationCreateResponse|null
|
||||
*/
|
||||
protected function sendSmsForLpVerification(SmsVerificationCreateRequest $request): ?SmsVerificationCreateResponse
|
||||
{
|
||||
$serialized = Serializer::serializeArray($request);
|
||||
$response = $this->client->sendSmsForLpVerification($serialized);
|
||||
|
||||
return Deserializer::deserializeArray($response->getResponseBody(), SmsVerificationCreateResponse::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationStatusRequest $request
|
||||
* @return \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationStatusResponse|null
|
||||
*/
|
||||
protected function checkStatusPlVerification(SmsVerificationStatusRequest $request): ?SmsVerificationStatusResponse
|
||||
{
|
||||
$serialized = Serializer::serializeArray($request);
|
||||
$response = $this->client->checkStatusPlVerification($serialized, $request->checkId);
|
||||
|
||||
return Deserializer::deserializeArray($response->getResponseBody(), SmsVerificationStatusResponse::class);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Model\Api\Request\SmsVerification
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
namespace Intaro\RetailCrm\Model\Api\Request\SmsVerification;
|
||||
|
||||
use Intaro\RetailCrm\Component\Json\Mapping;
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Model\Api\Request\SmsVerification
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
namespace Intaro\RetailCrm\Model\Api\Request\SmsVerification;
|
||||
|
||||
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Model\Api\Response\SmsVerification
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
namespace Intaro\RetailCrm\Model\Api\Response\SmsVerification;
|
||||
|
||||
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Model\Api
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
namespace Intaro\RetailCrm\Model\Api;
|
||||
|
||||
use Intaro\RetailCrm\Component\Json\Mapping;
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Model\Api
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
namespace Intaro\RetailCrm\Model\Api;
|
||||
|
||||
use Intaro\RetailCrm\Component\Json\Mapping;
|
||||
|
@ -99,4 +108,4 @@ class SmsVerificationCreate extends AbstractApiModel
|
|||
{
|
||||
$this->orderId = $orderId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
namespace Tests\Intaro\RetailCrm\Component\Factory;
|
||||
|
||||
use Intaro\RetailCrm\Component\ApiClient\ClientAdapter;
|
||||
use Intaro\RetailCrm\Component\ConfigProvider;
|
||||
use Intaro\RetailCrm\Component\Factory\ClientFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ClientFactoryTest extends TestCase
|
||||
{
|
||||
|
||||
public function testCreacteClientAdapter(): void
|
||||
{
|
||||
$configProvider = $this->createMock(ConfigProvider::class);
|
||||
|
||||
$configProvider->method('getApiUrl')
|
||||
->willReturn('http://test.ru');
|
||||
$configProvider->method('getApiKey')
|
||||
->willReturn('qwerty123');
|
||||
|
||||
$client = ClientFactory::creacteClientAdapter();
|
||||
|
||||
self::assertEquals(ClientAdapter::class, get_class($client));
|
||||
$configProvider->method('getApiUrl')
|
||||
->willReturn('');
|
||||
|
||||
$configProvider->method('getApiKey')
|
||||
->willReturn('');
|
||||
|
||||
$client = ClientFactory::creacteClientAdapter();
|
||||
|
||||
self::assertEquals(null, $client);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue