Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
DeliveryRequest: option to specify CallCourier
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmai committed Oct 29, 2018
1 parent 8c11e90 commit 0ff1fc1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Requests/DeliveryRequest.php
Expand Up @@ -28,6 +28,7 @@

namespace CdekSDK\Requests;

use CdekSDK\Common\CallCourier;
use CdekSDK\Common\Fillable;
use CdekSDK\Common\Order;
use CdekSDK\Contracts\ShouldAuthorize;
Expand Down Expand Up @@ -79,6 +80,13 @@ class DeliveryRequest implements XmlRequest, ShouldAuthorize
*/
protected $Currency;

/**
* @JMS\Type("CdekSDK\Common\CallCourier")
*
* @var CallCourier
*/
protected $CallCourier;

/**
* @JMS\XmlAttribute
* @JMS\SerializedName("OrderCount")
Expand Down
32 changes: 32 additions & 0 deletions tests/Serialization/DeliveryRequestTest.php
Expand Up @@ -30,6 +30,7 @@

use CdekSDK\Common\AdditionalService;
use CdekSDK\Common\Address;
use CdekSDK\Common\CallCourier;
use CdekSDK\Common\City;
use CdekSDK\Common\Item;
use CdekSDK\Common\Order;
Expand Down Expand Up @@ -261,6 +262,37 @@ public function test_can_serialize_foreign_delivery_request()
<Passport Series="5004" Number="123456"/>
</Order>
</DeliveryRequest>
', $request);
}

public function test_with_call_courier()
{
$request = DeliveryRequest::create([
'Number' => 'foo',
'CallCourier' => CallCourier::create([
'Comment' => 'foo',
'Date' => new \DateTime('2017-05-06T11:20:45.680+07:00'),
'LunchBeg' => new \DateTime('14:00'),
'LunchEnd' => new \DateTime('14:30'),
'SendCityCode' => 44,
'SenderName' => 'Testing',
'SendPhone' => '+79138739944',
'TimeBeg' => new \DateTime('10:00'),
'TimeEnd' => new \DateTime('17:00'),
'Weight' => '20',
])->setAddress(Address::create([
'Street' => 'Тестовая',
'House' => '8',
'Flat' => '32',
])),
]);

$this->assertSameAsXML('<?xml version="1.0" encoding="UTF-8"?>
<DeliveryRequest OrderCount="0" Number="foo">
<CallCourier Date="2017-05-06" TimeBeg="10:00" TimeEnd="17:00" LunchBeg="14:00" LunchEnd="14:30" SendCityCode="44" SendPhone="+79138739944" SenderName="Testing" Weight="20" Comment="foo">
<Address Street="Тестовая" House="8" Flat="32"/>
</CallCourier>
</DeliveryRequest>
', $request);
}
}

0 comments on commit 0ff1fc1

Please sign in to comment.