1
0
mirror of synced 2024-11-21 21:06:07 +03:00

add applyRound and loyaltyLevelId params (#119)

This commit is contained in:
tishmaria90 2021-09-28 11:20:48 +03:00 committed by GitHub
parent fa93c2bc8d
commit 9c6029fa0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 79 additions and 3 deletions

View File

@ -43,10 +43,18 @@ class SerializedEntityOrder
*/ */
public $number; public $number;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("applyRound")
*/
public $applyRound;
/** /**
* SerializedEntityOrder constructor. * SerializedEntityOrder constructor.
* *
* @param int $id * @param int $id
* @param string $externalId * @param string $externalId
* @param string $number * @param string $number
*/ */
@ -101,4 +109,18 @@ class SerializedEntityOrder
{ {
return new self(0, '', $number); return new self(0, '', $number);
} }
/**
* Set applyRound and return this entity
*
* @param bool $applyRound
*
* @return $this
*/
public function setApplyRound(bool $applyRound): self
{
$this->applyRound = $applyRound;
return $this;
}
} }

View File

@ -147,4 +147,12 @@ class LoyaltyAccount
* @JMS\SerializedName("loyalty") * @JMS\SerializedName("loyalty")
*/ */
public $loyalty; public $loyalty;
/**
* @var int
*
* @JMS\Type("int")
* @JMS\SerializedName("loyaltyLevelId")
*/
public $loyaltyLevelId;
} }

View File

@ -68,4 +68,12 @@ class SerializedOrder
* @JMS\SerializedName("delivery") * @JMS\SerializedName("delivery")
*/ */
public $delivery; public $delivery;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("applyRound")
*/
public $applyRound;
} }

View File

@ -503,4 +503,12 @@ class Order
* @JMS\SerializedName("loyaltyEventId") * @JMS\SerializedName("loyaltyEventId")
*/ */
public $loyaltyEventId; public $loyaltyEventId;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("applyRound")
*/
public $applyRound;
} }

View File

@ -12,6 +12,7 @@ namespace RetailCrm\Tests\ResourceGroup;
use DateInterval; use DateInterval;
use DateTime; use DateTime;
use DateTimeInterface; use DateTimeInterface;
use Psr\Http\Message\RequestInterface;
use RetailCrm\Api\Component\Transformer\DateTimeTransformer; use RetailCrm\Api\Component\Transformer\DateTimeTransformer;
use RetailCrm\Api\Enum\Loyalty\AccountStatus; use RetailCrm\Api\Enum\Loyalty\AccountStatus;
use RetailCrm\Api\Enum\Loyalty\PrivilegeType; use RetailCrm\Api\Enum\Loyalty\PrivilegeType;
@ -234,12 +235,19 @@ EOF;
$account = new LoyaltyAccount(); $account = new LoyaltyAccount();
$account->cardNumber = '4444 5555 6666 7777'; $account->cardNumber = '4444 5555 6666 7777';
$account->phoneNumber = '88005553000'; $account->phoneNumber = '88005553000';
$account->loyaltyLevelId = 1;
$request = new LoyaltyAccountEditRequest($account); $request = new LoyaltyAccountEditRequest($account);
$mock = static::createApiMockBuilder('loyalty/account/159/edit'); $mock = static::createApiMockBuilder('loyalty/account/159/edit');
$mock->matchMethod(RequestMethod::POST) $mock->matchMethod(RequestMethod::POST)
->matchBody(static::encodeForm($request)) ->matchBody(static::encodeForm($request))
->matchCallback(static function (RequestInterface $request) {
$data = [];
parse_str((string) $request->getBody(), $data);
return false !== strpos($data['loyaltyAccount'] ?? '', '"loyaltyLevelId"');
})
->reply(200) ->reply(200)
->withBody($json); ->withBody($json);
@ -700,6 +708,7 @@ EOF;
$order->items = [$item]; $order->items = [$item];
$order->delivery = new SerializedOrderDelivery(100); $order->delivery = new SerializedOrderDelivery(100);
$order->privilegeType = PrivilegeType::NONE; $order->privilegeType = PrivilegeType::NONE;
$order->applyRound = true;
$request = new LoyaltyCalculateRequest(); $request = new LoyaltyCalculateRequest();
$request->site = 'bitrix-test'; $request->site = 'bitrix-test';
@ -709,6 +718,12 @@ EOF;
$mock = static::createApiMockBuilder('loyalty/calculate'); $mock = static::createApiMockBuilder('loyalty/calculate');
$mock->matchMethod(RequestMethod::POST) $mock->matchMethod(RequestMethod::POST)
->matchBody(static::encodeForm($request)) ->matchBody(static::encodeForm($request))
->matchCallback(static function (RequestInterface $request) {
$data = [];
parse_str((string) $request->getBody(), $data);
return false !== strpos($data['order'] ?? '', '"applyRound"');
})
->reply(200) ->reply(200)
->withBody($json); ->withBody($json);

View File

@ -529,6 +529,7 @@ EOF;
"call": false, "call": false,
"expired": false, "expired": false,
"managerId": 28, "managerId": 28,
"applyRound": true,
"customer": { "customer": {
"type": "customer", "type": "customer",
"id": 4924, "id": 4924,
@ -7486,12 +7487,18 @@ EOF;
$request = new OrdersLoyaltyApplyRequest(); $request = new OrdersLoyaltyApplyRequest();
$request->site = 'bitrix-test'; $request->site = 'bitrix-test';
$request->order = SerializedEntityOrder::withNumber('7'); $request->order = SerializedEntityOrder::withNumber('7')->setApplyRound(true);
$request->bonuses = 10; $request->bonuses = 10;
$mock = static::createApiMockBuilder('orders/loyalty/apply'); $mock = static::createApiMockBuilder('orders/loyalty/apply');
$mock->matchMethod(RequestMethod::POST) $mock->matchMethod(RequestMethod::POST)
->matchBody(static::encodeForm($request)) ->matchBody(static::encodeForm($request))
->matchCallback(static function (RequestInterface $request) {
$data = [];
parse_str((string) $request->getBody(), $data);
return false !== strpos($data['order'] ?? '', '"applyRound"');
})
->reply(200) ->reply(200)
->withBody($json); ->withBody($json);
@ -7551,13 +7558,19 @@ EOF;
EOF; EOF;
$request = new OrderLoyaltyCancelBonusOperationsRequest( $request = new OrderLoyaltyCancelBonusOperationsRequest(
SerializedEntityOrder::withId(7751), SerializedEntityOrder::withId(7751)->setApplyRound(true),
'bitrix-test' 'bitrix-test'
); );
$mock = static::createApiMockBuilder('orders/loyalty/cancel-bonus-operations'); $mock = static::createApiMockBuilder('orders/loyalty/cancel-bonus-operations');
$mock->matchMethod(RequestMethod::POST) $mock->matchMethod(RequestMethod::POST)
->matchBody(static::encodeForm($request)) ->matchBody(static::encodeForm($request))
->matchCallback(static function (RequestInterface $request) {
$data = [];
parse_str((string) $request->getBody(), $data);
return false !== strpos($data['order'] ?? '', '"applyRound"');
})
->reply(200) ->reply(200)
->withBody($json); ->withBody($json);
@ -7708,6 +7721,7 @@ EOF;
"call": false, "call": false,
"expired": false, "expired": false,
"managerId": 28, "managerId": 28,
"applyRound": true,
"customer": { "customer": {
"type": "customer", "type": "customer",
"id": 4924, "id": 4924,
@ -8511,6 +8525,7 @@ EOF;
"call": false, "call": false,
"expired": false, "expired": false,
"managerComment": "Manager comment", "managerComment": "Manager comment",
"applyRound": true,
"customer": { "customer": {
"type": "customer", "type": "customer",
"id": 4976, "id": 4976,