1
0
Fork 0
mirror of synced 2025-04-20 01:21:01 +00:00

delete SmsVerificationCreate api method

This commit is contained in:
Sergey Chazov 2020-09-29 14:04:23 +03:00
parent 60afeef610
commit cec2080701
7 changed files with 6 additions and 294 deletions

View file

@ -14,9 +14,7 @@ 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;
@ -38,18 +36,6 @@ trait LoyaltyTrait
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

View file

@ -40,23 +40,6 @@ class AdminPanel extends Controller
parent::__construct($request);
}
/**
* Send verification sms
*
* @param string $actionType
* @param int|null $orderId
* @param int $verificationLength
* @return \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationCreateResponse|null
* @throws \Exception
*/
public function sendSmsAction(
string $actionType = 'verify_customer',
int $orderId = null,
int $verificationLength = self::DEFAULT_CODE_LENGHT
) {
return $this->service->sendSms($actionType, $orderId, $verificationLength);
}
/**
* Контроллер получает статус текущего состояния верификации
*

View file

@ -1,31 +0,0 @@
<?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;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class SmsVerificationCreateRequest
*
* @package Intaro\RetailCrm\Model\Api\Response\SmsVerification
*/
class SmsVerificationCreateRequest extends AbstractApiModel
{
/**
* @var \Intaro\RetailCrm\Model\Api\SmsVerificationCreate
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SmsVerificationCreate")
* @Mapping\SerializedName("verification")
*/
public $verification;
}

View file

@ -1,25 +0,0 @@
<?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;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class SmsVerificationCreateResponse
*
* @package Intaro\RetailCrm\Model\Api\Response\SmsVerification
*/
class SmsVerificationCreateResponse extends SmsVerificationConfirmResponse
{
}

View file

@ -1,111 +0,0 @@
<?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;
/**
* Class SmsVerificationCreate
* @package Intaro\RetailCrm\Model\Api
*/
class SmsVerificationCreate extends AbstractApiModel
{
/**
* Длина кода в сообщении (по умолчанию 4 символа)
*
* @var integer $length
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("length")
*/
protected $length;
/**
* Номер телефона для отправки сообщения
*
* @var string $phone
*
* @Mapping\Type("string")
* @Mapping\SerializedName("phone")
*/
protected $phone;
/**
* Тип события, для которого необходима верификация
*
* @var string $actionType
*
* @Mapping\Type("string")
* @Mapping\SerializedName("actionType")
*/
protected $actionType;
/**
* ID клиента
*
* @var integer $customerId
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("customerId")
*/
protected $customerId;
/**
* ID заказа
*
* @var integer $orderId
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("orderId")
*/
protected $orderId;
/**
* @param int $length
*/
public function setLength(int $length): void
{
$this->length = $length;
}
/**
* @param string $phone
*/
public function setPhone(string $phone): void
{
$this->phone = $phone;
}
/**
* @param string $actionType
*/
public function setActionType(string $actionType): void
{
$this->actionType = $actionType;
}
/**
* @param int $customerId
*/
public function setCustomerId(int $customerId): void
{
$this->customerId = $customerId;
}
/**
* @param int $orderId
*/
public function setOrderId(int $orderId): void
{
$this->orderId = $orderId;
}
}

View file

@ -14,10 +14,8 @@ namespace Intaro\RetailCrm\Service;
use Exception;
use Intaro\RetailCrm\Component\Factory\ClientFactory;
use Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationConfirmRequest;
use Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationCreateRequest;
use Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationStatusRequest;
use Intaro\RetailCrm\Model\Api\SmsVerificationConfirm;
use Intaro\RetailCrm\Model\Api\SmsVerificationCreate;
use Intaro\RetailCrm\Repository\UserRepository;
/**
@ -32,53 +30,11 @@ class UserAccountService
*/
private $client;
/**
* @var \CAllUser|\CUser
*/
private $user;
public function __construct()
{
$this->client = ClientFactory::createClientAdapter();
}
/**
* send verification sms
*
* @param string $actionType [verify_customer|verify_privacy]
* @param int|null $orderId
* @param int $verificationLength
* @return \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationCreateResponse|null
* @throws \Exception
*/
public function sendSms(
string $actionType = 'verify_customer',
int $orderId = null,
int $verificationLength = self::DEFAULT_CODE_LENGHT
) {
$this->checkAuth();
$userId = $this->user->GetID();
/** @var \Intaro\RetailCrm\Model\Bitrix\User $user */
$user = UserRepository::getFirstByParams(
[
['ID', '=', $userId]
],
['PERSONAL_PHONE']
);
$request = new SmsVerificationCreateRequest();
$request->verification = new SmsVerificationCreate();
$request->verification->setLength($verificationLength);
$request->verification->setPhone($user->getPersonalPhone());
$request->verification->setPhone($this->userId);
$request->verification->setActionType($actionType);
$request->verification->setCustomerId($userId);
$request->verification->setOrderId($orderId);
return $this->client->sendSmsForLpVerification($request);
}
/**
* Получает статус текущего состояния верификации
*
@ -128,9 +84,9 @@ class UserAccountService
private function checkAuth()
{
global $USER;
$this->user = $USER;
$user = $USER;
if (!$this->user->IsAuthorized()) {
if (!$user->IsAuthorized()) {
throw new Exception(self::NOT_AUTHORIZE);
}
}

View file

@ -14,11 +14,8 @@ namespace Intaro\RetailCrm\Service;
use Exception;
use Intaro\RetailCrm\Component\Factory\ClientFactory;
use Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationConfirmRequest;
use Intaro\RetailCrm\Model\Api\Request\SmsVerification\SmsVerificationCreateRequest;
use Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationStatusRequest;
use Intaro\RetailCrm\Model\Api\SmsVerificationConfirm;
use Intaro\RetailCrm\Model\Api\SmsVerificationCreate;
use Intaro\RetailCrm\Repository\UserRepository;
/**
* Class UserVerificationService
@ -32,55 +29,12 @@ class UserVerificationService
* @var \Intaro\RetailCrm\Component\ApiClient\ClientAdapter
*/
private $client;
private $userId;
/**
* @var \CAllUser|\CUser
*/
private $user;
public function __construct()
{
$this->client = ClientFactory::createClientAdapter();
}
/**
* send verification sms
*
* @param string $actionType [verify_customer|verify_privacy]
* @param int|null $orderId
* @param int $verificationLength
* @return \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationCreateResponse|null
* @throws \Exception
*/
public function sendSms(
string $actionType = 'verify_customer',
int $orderId = null,
int $verificationLength = self::DEFAULT_CODE_LENGHT
) {
$this->checkAuth();
$userId = $this->user->GetID();
/** @var \Intaro\RetailCrm\Model\Bitrix\User $user */
$user = UserRepository::getFirstByParams(
[
['ID', '=', $userId]
],
['PERSONAL_PHONE']
);
$request = new SmsVerificationCreateRequest();
$request->verification = new SmsVerificationCreate();
$request->verification->setLength($verificationLength);
$request->verification->setPhone($user->getPersonalPhone());
$request->verification->setPhone($this->userId);
$request->verification->setActionType($actionType);
$request->verification->setCustomerId($userId);
$request->verification->setOrderId($orderId);
return $this->client->sendSmsForLpVerification($request);
}
/**
* Получает статус текущего состояния верификации
*
@ -121,7 +75,7 @@ class UserVerificationService
public function checkPlRegistrationStatus(int $userId)
{
//TODO когда метод будет реализован в АПИ, нужно будет написать реализацию
return true;
return $userId;
}
/**
@ -130,9 +84,9 @@ class UserVerificationService
private function checkAuth()
{
global $USER;
$this->user = $USER;
$user = $USER;
if (!$this->user->IsAuthorized()) {
if (!$user->IsAuthorized()) {
throw new Exception(self::NOT_AUTHORIZE);
}
}