add applyRound and loyaltyLevelId params (#119)
This commit is contained in:
parent
fa93c2bc8d
commit
9c6029fa0d
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -147,4 +147,12 @@ class LoyaltyAccount
|
||||
* @JMS\SerializedName("loyalty")
|
||||
*/
|
||||
public $loyalty;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @JMS\Type("int")
|
||||
* @JMS\SerializedName("loyaltyLevelId")
|
||||
*/
|
||||
public $loyaltyLevelId;
|
||||
}
|
||||
|
@ -68,4 +68,12 @@ class SerializedOrder
|
||||
* @JMS\SerializedName("delivery")
|
||||
*/
|
||||
public $delivery;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
* @JMS\Type("bool")
|
||||
* @JMS\SerializedName("applyRound")
|
||||
*/
|
||||
public $applyRound;
|
||||
}
|
||||
|
@ -503,4 +503,12 @@ class Order
|
||||
* @JMS\SerializedName("loyaltyEventId")
|
||||
*/
|
||||
public $loyaltyEventId;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
* @JMS\Type("bool")
|
||||
* @JMS\SerializedName("applyRound")
|
||||
*/
|
||||
public $applyRound;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user