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,6 +43,14 @@ class SerializedEntityOrder
*/
public $number;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("applyRound")
*/
public $applyRound;
/**
* SerializedEntityOrder constructor.
*
@ -101,4 +109,18 @@ class SerializedEntityOrder
{
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")
*/
public $loyalty;
/**
* @var int
*
* @JMS\Type("int")
* @JMS\SerializedName("loyaltyLevelId")
*/
public $loyaltyLevelId;
}

View File

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

View File

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

View File

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