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

Lp update api client

This commit is contained in:
Alex Lushpai 2020-09-30 18:15:22 +03:00 committed by GitHub
commit 3d09cb1480
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 1441 additions and 290 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

@ -0,0 +1,30 @@
<?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;
/**
* Class AbstractLoyaltyEvent
*
* @package Intaro\RetailCrm\Model\Api
*/
class AbstractLoyaltyEvent
{
/**
* ID события
*
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
}

View file

@ -0,0 +1,38 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Response\Loyalty
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
/**
* Class CalculateMaximum
*
* @package Intaro\RetailCrm\Model\Api
*/
class CalculateMaximum
{
/**
* Привилегия с максимальной выгодой
*
* @var string $privilegeType
*
* @Mapping\Type("string")
* @Mapping\SerializedName("privilegeType")
*/
public $privilegeType;
/**
* @var \Intaro\RetailCrm\Model\Api\AbstractLoyaltyEvent
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\AbstractLoyaltyEvent")
* @Mapping\SerializedName("loyaltyEvent")
*/
public $loyaltyEvent;
}

View file

@ -11,6 +11,7 @@
*/
namespace Intaro\RetailCrm\Model\Api;
use DateTime;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
@ -299,4 +300,14 @@ class Customer extends AbstractApiModel
* @Mapping\SerializedName("mainCustomerContact")
*/
public $mainCustomerContact;
/**
* Персональная скидка
*
* @var double $mainCustomerContact
*
* @Mapping\Type("double")
* @Mapping\SerializedName("personalDiscount")
*/
public $personalDiscount;
}

View file

@ -0,0 +1,98 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Loyalty\Account
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
/**
* Class LoyaltyAccount
*
* @package Intaro\RetailCrm\Model\Api
*/
class LoyaltyAccount
{
/**
* Номер телефона
*
* @var boolean $active
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("active")
*/
public $active;
/**
* Номер телефона
*
* @var string $phoneNumber
*
* @Mapping\Type("string")
* @Mapping\SerializedName("phoneNumber")
*/
public $phoneNumber;
/**
* Номер карты
*
* @var string $cardNumber
*
* @Mapping\Type("string")
* @Mapping\SerializedName("cardNumber")
*/
public $cardNumber;
/**
* Id участия в программе лояльности
*
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* Количество бонусов
*
* @var float $amount
*
* @Mapping\Type("float")
* @Mapping\SerializedName("amount")
*/
public $amount;
/**
* Дата создания
*
* @var \DateTime $createdAt
*
* @Mapping\Type("DateTime<'Y-m-d H:i:s'>")
* @Mapping\SerializedName("createdAt")
*/
public $createdAt;
/**
* @var \DateTime $activatedAt
*
* @Mapping\Type("DateTime<'Y-m-d H:i:s'>")
* @Mapping\SerializedName("activatedAt")
*/
public $activatedAt;
/**
* Идентификатор последней смс-верификации
*
* @var string $lastCheckId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("lastCheckId")
*/
public $lastCheckId;
}

View file

@ -0,0 +1,60 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Response\Loyalty
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
/**
* Class LoyaltyCalculation
*
* @package Intaro\RetailCrm\Model\Api
*/
class LoyaltyCalculation
{
/**
* Тип привилегии
*
* @var string $privilegeType
*
* @Mapping\Type("string")
* @Mapping\SerializedName("privilegeType")
*/
public $privilegeType;
/**
* Суммарная скидка на заказ
*
* @var float $amount
*
* @Mapping\Type("float")
* @Mapping\SerializedName("amount")
*/
public $amount;
/**
* Будет начислено бонусов
*
* @var float $bonuses
*
* @Mapping\Type("float")
* @Mapping\SerializedName("bonuses")
*/
public $bonuses;
/**
* Итоговая сумма выгоды
*
* @var float $total
*
* @Mapping\Type("float")
* @Mapping\SerializedName("total")
*/
public $total;
}

View file

@ -0,0 +1,40 @@
<?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;
/**
* Class LoyaltyLevel
*
* @package Intaro\RetailCrm\Model\Api
*/
class LoyaltyLevel
{
/**
* ID уровня
*
* @var integer $id
*
* @Mapping\Type("string")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* Название уровня
*
* @var string $name
*
* @Mapping\Type("string")
* @Mapping\SerializedName("name")
*/
public $name;
}

View file

@ -0,0 +1,90 @@
<?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;
/**
* Class OrderProduct
*
* @package Intaro\RetailCrm\Model\Api
*/
class OrderProduct
{
/**
* Количество списанных бонусов
*
* @var double $bonusesChargeTotal
*
* @Mapping\Type("double")
* @Mapping\SerializedName("bonusesChargeTotal")
*/
public $bonusesChargeTotal;
/**
* Количество начисленных бонусов
*
* @var double $bonusesCreditTotal
*
* @Mapping\Type("double")
* @Mapping\SerializedName("bonusesCreditTotal")
*/
public $bonusesCreditTotal;
/**
* Тип цены
*
* @var \Intaro\RetailCrm\Model\Api\PriceType
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\PriceType")
* @Mapping\SerializedName("priceType")
*/
public $priceType;
/**
* Цена товара/SKU
*
* @var double $initialPrice
*
* @Mapping\Type("double")
* @Mapping\SerializedName("initialPrice")
*/
public $initialPrice;
/**
* Итоговая денежная скидка на единицу товара c учетом всех скидок на товар и заказ
*
* @var double $discountTotal
*
* @Mapping\Type("double")
* @Mapping\SerializedName("discountTotal")
*/
public $discountTotal;
/**
* Ставка НДС
*
* @var string $vatRate
*
* @Mapping\Type("string")
* @Mapping\SerializedName("vatRate")
*/
public $vatRate;
/**
* Количество
*
* @var float $quantity
*
* @Mapping\Type("float")
* @Mapping\SerializedName("quantity")
*/
public $quantity;
}

View file

@ -0,0 +1,30 @@
<?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;
/**
* Class PriceType
*
* @package Intaro\RetailCrm\Model\Api
*/
class PriceType
{
/**
* Код типа цены
*
* @var string $code
*
* @Mapping\Type("string")
* @Mapping\SerializedName("code")
*/
public $code;
}

View file

@ -0,0 +1,33 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Loyalty\Account
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Loyalty\Account;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
/**
* Class LoyaltyAccountActivateRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Loyalty\Account
*/
class LoyaltyAccountActivateRequest extends AbstractApiModel
{
/**
* Id участия в программе лояльности
*
* @var integer $loyaltyId
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $loyaltyId;
}

View file

@ -0,0 +1,32 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Loyalty\Account
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Loyalty\Account;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\SerializedCreateLoyaltyAccount;
/**
* Class LoyaltyAccountCreateRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Loyalty\Account
*/
class LoyaltyAccountCreateRequest extends AbstractApiModel
{
/**
* @var \Intaro\RetailCrm\Model\Api\SerializedCreateLoyaltyAccount
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SerializedCreateLoyaltyAccount")
* @Mapping\SerializedName("loyalty_account")
*/
public $loyaltyAccount;
}

View file

@ -0,0 +1,32 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Loyalty\Account
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Loyalty\Account;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\LoyaltyAccount;
/**
* Class LoyaltyAccountEditRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Loyalty\Account
*/
class LoyaltyAccountEditRequest extends AbstractApiModel
{
/**
* @var \Intaro\RetailCrm\Model\Api\LoyaltyAccount
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\LoyaltyAccount")
* @Mapping\SerializedName("loyalty_account")
*/
public $loyaltyAccount;
}

View file

@ -0,0 +1,40 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Loyalty
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Loyalty;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\SerializedOrder;
/**
* Class LoyaltyCalculateRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Loyalty
*/
class LoyaltyCalculateRequest extends AbstractApiModel
{
/**
* @var string $site
*
* @Mapping\Type("string")
* @Mapping\SerializedName("site")
*/
public $site;
/**
* @var \Intaro\RetailCrm\Model\Api\SerializedOrder
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SerializedOrder")
* @Mapping\SerializedName("order")
*/
public $order;
}

View file

@ -0,0 +1,32 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Order\Loyalty
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Order\Loyalty;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\SerializedOrderReference;
/**
* Class OrderLoyaltyApplyRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Order\Loyalty
*/
class OrderLoyaltyApplyRequest extends AbstractApiModel
{
/**
* @var \Intaro\RetailCrm\Model\Api\SerializedOrderReference
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SerializedOrderReference")
* @Mapping\SerializedName("order")
*/
public $order;
}

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

@ -22,9 +22,9 @@ use Intaro\RetailCrm\Component\Json\Mapping;
class SmsVerificationStatusRequest extends AbstractApiModel
{
/**
* Номер телефона для отправки сообщения
* Идентификатор проверки кода
*
* @var string $phone
* @var string $checkId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("checkId")

View file

@ -0,0 +1,51 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Response\Loyalty\Account
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Response\Loyalty\Account;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\LoyaltyAccount;
use Intaro\RetailCrm\Model\Api\SmsVerification;
/**
* Class LoyaltyAccountActivateResponse
*
* @package Intaro\RetailCrm\Model\Api\Response\Loyalty\Account
*/
class LoyaltyAccountActivateResponse extends AbstractApiModel
{
/**
* Результат запроса (успешный/неуспешный)
*
* @var boolean $success
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("success")
*/
public $success;
/**
* @var \Intaro\RetailCrm\Model\Api\LoyaltyAccount
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\LoyaltyAccount")
* @Mapping\SerializedName("loyalty_account")
*/
public $loyaltyAccount;
/**
* @var \Intaro\RetailCrm\Model\Api\SmsVerification
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SmsVerification")
* @Mapping\SerializedName("verification")
*/
public $verification;
}

View file

@ -0,0 +1,49 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Response\Loyalty\Account
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Response\Loyalty\Account;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\LoyaltyAccount;
/**
* Class LoyaltyAccountCreateResponse
*
* @package Intaro\RetailCrm\Model\Api\Response\Loyalty\Account
*/
class LoyaltyAccountCreateResponse extends AbstractApiModel
{
/**
* Результат запроса (успешный/неуспешный)
*
* @var boolean $success
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("success")
*/
public $success;
/**
* @var \Intaro\RetailCrm\Model\Api\LoyaltyAccount
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\LoyaltyAccount")
* @Mapping\SerializedName("loyalty_account")
*/
public $loyaltyAccount;
/**
* @var array $warnings
*
* @Mapping\Type("array")
* @Mapping\SerializedName("warnings")
*/
public $warnings;
}

View file

@ -0,0 +1,50 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Response\Loyalty\Account
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Response\Loyalty\Account;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\LoyaltyAccount;
/**
* Class LoyaltyAccountEditResponse
*
* @package Intaro\RetailCrm\Model\Api\Response\Loyalty\Account
*/
class LoyaltyAccountEditResponse extends AbstractApiModel
{
/**
* Результат запроса (успешный/неуспешный)
*
* @var boolean $success
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("success")
*/
public $success;
/**
* @var \Intaro\RetailCrm\Model\Api\LoyaltyAccount
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\LoyaltyAccount")
* @Mapping\SerializedName("loyalty_account")
*/
public $loyaltyAccount;
/**
* @var array $warnings
*
* @Mapping\Type("array")
* @Mapping\SerializedName("warnings")
*/
public $warnings;
}

View file

@ -0,0 +1,60 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Response\Loyalty
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Response\Loyalty;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\CalculateMaximum;
use Intaro\RetailCrm\Model\Api\SerializedLoyaltyOrder;
/**
* Class LoyaltyCalculateResponse
*
* @package Intaro\RetailCrm\Model\Api\Response\Loyalty
*/
class LoyaltyCalculateResponse extends AbstractApiModel
{
/**
* Результат запроса (успешный/неуспешный)
*
* @var boolean $success
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("success")
*/
public $success;
/**
* @var \Intaro\RetailCrm\Model\Api\SerializedLoyaltyOrder
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SerializedLoyaltyOrder")
* @Mapping\SerializedName("order")
*/
public $order;
/**
* @var \Intaro\RetailCrm\Model\Api\CalculateMaximum
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\CalculateMaximum")
* @Mapping\SerializedName("maximum")
*/
public $maximum;
/**
* Позиция в заказе
*
* @var array $calculations
*
* @Mapping\Type("array<Intaro\RetailCrm\Model\Api\LoyaltyCalculation>")
* @Mapping\SerializedName("calculations")
*/
public $calculations;
}

View file

@ -0,0 +1,51 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Response\Order\Loyalty
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Response\Order\Loyalty;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\SerializedLoyaltyOrder;
use Intaro\RetailCrm\Model\Api\SmsVerification;
/**
* Class OrderLoyaltyApplyResponse
*
* @package Intaro\RetailCrm\Model\Api\Response\SmsVerification
*/
class OrderLoyaltyApplyResponse extends AbstractApiModel
{
/**
* Результат запроса (успешный/неуспешный)
*
* @var boolean $success
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("success")
*/
public $success;
/**
* @var \Intaro\RetailCrm\Model\Api\SerializedLoyaltyOrder
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SerializedLoyaltyOrder")
* @Mapping\SerializedName("order")
*/
public $order;
/**
* @var \Intaro\RetailCrm\Model\Api\SmsVerification
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SerializedLoyaltyOrder")
* @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

@ -9,11 +9,11 @@
* @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;
use Intaro\RetailCrm\Model\Api\SmsVerification;
/**
* Class SmsVerificationStatusResponse
@ -22,4 +22,22 @@ use Intaro\RetailCrm\Component\Json\Mapping;
*/
class SmsVerificationStatusResponse extends SmsVerificationConfirmResponse
{
/**
* Результат запроса (успешный/неуспешный)
*
* @var boolean $success
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("success")
*/
public $success;
/**
* @var \Intaro\RetailCrm\Model\Api\SmsVerification
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SmsVerification")
* @Mapping\SerializedName("verification")
*/
public $verification;
}

View file

@ -0,0 +1,60 @@
<?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;
/**
* Class SerializedCreateLoyaltyAccount
*
* @package Intaro\RetailCrm\Model\Api
*/
class SerializedCreateLoyaltyAccount
{
/**
* Номер телефона
*
* @var string $phoneNumber
*
* @Mapping\Type("string")
* @Mapping\SerializedName("phoneNumber")
*/
public $phoneNumber;
/**
* Номер карты
*
* @var string $cardNumber
*
* @Mapping\Type("string")
* @Mapping\SerializedName("cardNumber")
*/
public $cardNumber;
/**
* ID участия
*
* @var integer $loyaltyId
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("loyaltyId")
*/
public $loyaltyId;
/**
* ID клиента
*
* @var integer $customerId
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("customerId")
*/
public $customerId;
}

View file

@ -0,0 +1,121 @@
<?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;
/**
* Метод применения бонусов по программе лояльности
* Class SerializedLoyaltyOrder
*
* @package Intaro\RetailCrm\Model\Api
*/
class SerializedLoyaltyOrder
{
/**
* Количество начисленных бонусов
*
* @var double $bonusesCreditTotal
*
* @Mapping\Type("double")
* @Mapping\SerializedName("bonusesCreditTotal")
*/
public $bonusesCreditTotal;
/**
* Количество списанных бонусов
*
* @var double $bonusesChargeTotal
*
* @Mapping\Type("double")
* @Mapping\SerializedName("bonusesChargeTotal")
*/
public $bonusesChargeTotal;
/**
* Общая сумма с учетом скидки
*
* @var double $totalSumm
*
* @Mapping\Type("double")
* @Mapping\SerializedName("totalSumm")
*/
public $totalSumm;
/**
* Персональная скидка на заказ
*
* @var double $personalDiscountPercent
*
* @Mapping\Type("double")
* @Mapping\SerializedName("personalDiscountPercent")
*/
public $personalDiscountPercent;
/**
* @var \Intaro\RetailCrm\Model\Api\LoyaltyAccount
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\LoyaltyAccount")
* @Mapping\SerializedName("loyaltyAccount")
*/
public $loyaltyAccount;
/**
* @var \Intaro\RetailCrm\Model\Api\LoyaltyLevel
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\LoyaltyLevel")
* @Mapping\SerializedName("loyaltyLevel")
*/
public $loyaltyLevel;
/**
* @var \Intaro\RetailCrm\Model\Api\AbstractLoyaltyEvent
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\AbstractLoyaltyEvent")
* @Mapping\SerializedName("loyaltyEvent")
*/
public $loyaltyEvent;
/**
* @var \Intaro\RetailCrm\Model\Api\Customer
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\Customer")
* @Mapping\SerializedName("customer")
*/
public $customer;
/**
* @var \Intaro\RetailCrm\Model\Api\SerializedOrderDelivery
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SerializedOrderDelivery")
* @Mapping\SerializedName("delivery")
*/
public $delivery;
/**
* Магазин
*
* @var string $site
*
* @Mapping\Type("string")
* @Mapping\SerializedName("site")
*/
public $site;
/**
* Позиция в заказе
*
* @var array $items
*
* @Mapping\Type("array<Intaro\RetailCrm\Model\Api\OrderProduct>")
* @Mapping\SerializedName("items")
*/
public $items;
}

View file

@ -0,0 +1,66 @@
<?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;
/**
* Class SerializedOrder
*
* @package Intaro\RetailCrm\Model\Api
*/
class SerializedOrder
{
/**
* Денежная скидка на весь заказ
*
* @var double $discountManualAmount
*
* @Mapping\Type("double")
* @Mapping\SerializedName("discountManualAmount")
*/
public $discountManualAmount;
/**
* Процентная скидка на весь заказ. Система округляет это значение до 2 знаков после запятой
*
* @var double $discountManualPercent
*
* @Mapping\Type("double")
* @Mapping\SerializedName("discountManualPercent")
*/
public $discountManualPercent;
/**
* Клиент
*
* @var \Intaro\RetailCrm\Model\Api\SerializedRelationCustomer
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SerializedRelationCustomer")
* @Mapping\SerializedName("customer")
*/
public $customer;
/**
* @var array $items
*
* @Mapping\Type("array<Intaro\RetailCrm\Model\Api\SerializedOrderProduct>")
* @Mapping\SerializedName("items")
*/
public $items;
/**
* @var \Intaro\RetailCrm\Model\Api\SerializedOrderDelivery
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SerializedOrderDelivery")
* @Mapping\SerializedName("delivery")
*/
public $delivery;
}

View file

@ -0,0 +1,30 @@
<?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;
/**
* Class SerializedOrderDelivery
*
* @package Intaro\RetailCrm\Model\Api
*/
class SerializedOrderDelivery
{
/**
* Цена товара/SKU/Стоимость доставки
*
* @var double $cost
*
* @Mapping\Type("double")
* @Mapping\SerializedName("cost")
*/
public $cost;
}

View file

@ -0,0 +1,90 @@
<?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;
/**
* Class SerializedOrderProduct
*
* @package Intaro\RetailCrm\Model\Api
*/
class SerializedOrderProduct
{
/**
* Цена товара/SKU
*
* @var double $initialPrice
*
* @Mapping\Type("double")
* @Mapping\SerializedName("initialPrice")
*/
public $initialPrice;
/**
* Денежная скидка на единицу товара
*
* @var double $discountManualAmount
*
* @Mapping\Type("double")
* @Mapping\SerializedName("discountManualAmount")
*/
public $discountManualAmount;
/**
* Процентная скидка на единицу товара. Система округляет это значение до 2 знаков после запятой
*
* @var double $discountManualPercent
*
* @Mapping\Type("double")
* @Mapping\SerializedName("discountManualPercent")
*/
public $discountManualPercent;
/**
* Количество
*
* @var float $quantity
*
* @Mapping\Type("float")
* @Mapping\SerializedName("quantity")
*/
public $quantity;
/**
* Торговое предложение
*
* @var \Intaro\RetailCrm\Model\Api\SerializedOrderProductOffer
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SerializedOrderProductOffer")
* @Mapping\SerializedName("offer")
*/
public $offer;
/**
* Тип цены
*
* @var \Intaro\RetailCrm\Model\Api\PriceType
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\PriceType")
* @Mapping\SerializedName("priceType")
*/
public $priceType;
/**
* Данные о доставке
*
* @var \Intaro\RetailCrm\Model\Api\SerializedOrderDelivery
*
* @Mapping\Type("\Intaro\RetailCrm\Model\Api\SerializedOrderDelivery")
* @Mapping\SerializedName("delivery")
*/
public $delivery;
}

View file

@ -0,0 +1,50 @@
<?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;
/**
* Class SerializedOrderProductOffer
*
* @package Intaro\RetailCrm\Model\Api
*/
class SerializedOrderProductOffer
{
/**
* ID торгового предложения
*
* @var integer $initialPrice
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* Внешний ID торгового предложения
*
* @var string $externalId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("externalId")
*/
public $externalId;
/**
* ID торгового предложения в складской системе
*
* @var string $xmlId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("xmlId")
*/
public $xmlId;
}

View file

@ -0,0 +1,36 @@
<?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;
/**
* Class LoyaltyCalculateRequest
*
* @package Intaro\RetailCrm\Model\Api\Response\SmsVerification
*/
class SerializedOrderReference
{
/**
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* @var float $bonuses
*
* @Mapping\Type("float")
* @Mapping\SerializedName("bonuses")
*/
public $bonuses;
}

View file

@ -0,0 +1,40 @@
<?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;
/**
* Class SerializedRelationCustomer
*
* @package Intaro\RetailCrm\Model\Api
*/
class SerializedRelationCustomer
{
/**
* Денежная скидка на весь заказ
*
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* Процентная скидка на весь заказ. Система округляет это значение до 2 знаков после запятой
*
* @var string $externalId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("externalId")
*/
public $externalId;
}

View file

@ -11,8 +11,11 @@
*/
namespace Intaro\RetailCrm\Model\Api;
use DateTime;
/**
* Class SmsVerification
*
* @package Intaro\RetailCrm\Model\Api
*/
class SmsVerification extends AbstractApiModel
@ -66,44 +69,4 @@ class SmsVerification extends AbstractApiModel
* @Mapping\SerializedName("actionType")
*/
public $actionType;
/**
* @param \DateTime $createdAt
*/
public function setCreatedAt(\DateTime $createdAt): void
{
$this->createdAt = $createdAt;
}
/**
* @param string $actionType
*/
public function setActionType(string $actionType): void
{
$this->actionType = $actionType;
}
/**
* @param string $checkId
*/
public function setCheckId(string $checkId): void
{
$this->checkId = $checkId;
}
/**
* @param \DateTime $verifiedAt
*/
public function setVerifiedAt(\DateTime $verifiedAt): void
{
$this->verifiedAt = $verifiedAt;
}
/**
* @param \DateTime $expiredAt
*/
public function setExpiredAt(\DateTime $expiredAt): void
{
$this->expiredAt = $expiredAt;
}
}

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

@ -0,0 +1,94 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Service
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
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\Response\SmsVerification\SmsVerificationStatusRequest;
use Intaro\RetailCrm\Model\Api\SmsVerificationConfirm;
use Intaro\RetailCrm\Repository\UserRepository;
/**
* Class UserVerificationService
*/
class UserAccountService
{
/**
* @var \Intaro\RetailCrm\Component\ApiClient\ClientAdapter
*/
private $client;
/**
* UserAccountService constructor.
*/
public function __construct()
{
$this->client = ClientFactory::createClientAdapter();
}
/**
* Получает статус текущего состояния верификации
*
* @param string $checkId Идентификатор проверки кода
* @return \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationStatusResponse|null
*/
public function getSmsStatus(string $checkId)
{
$request = new SmsVerificationStatusRequest();
$request->checkId = $checkId;
return $this->client->checkStatusPlVerification($request);
}
/**
* Подтверждает верификацию
*
* @param string $code Проверочный код
* @param string $checkId Идентификатор проверки кода
* @return \Intaro\RetailCrm\Model\Api\Response\SmsVerification\SmsVerificationConfirmResponse|null
*/
public function confirmVerification(string $code, string $checkId)
{
$request = new SmsVerificationConfirmRequest();
$request->verification = new SmsVerificationConfirm();
$request->verification->setCode($code);
$request->verification->setCheckId($checkId);
return $this->client->confirmLpVerificationBySMS($request);
}
/**
* Проверяем статус регистрации пользователя в ПЛ
*
* @param int $userId
* @return bool
*/
public function checkPlRegistrationStatus(int $userId)
{
//TODO когда метод будет реализован в АПИ, нужно будет написать реализацию
return true;
}
/**
* @throws \Exception
*/
private function checkAuth()
{
global $USER;
$user = $USER;
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);
}
}