Skip to content

Commit

Permalink
Fix #7
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbrink committed Oct 11, 2021
1 parent a28a253 commit 3c57dd9
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ class PalletSchema extends DataTransferObject

public ?WeightSchema $weight;

public bool $is_stacked;
public ?bool $is_stacked;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Jasara\AmznSPA\DataTransferObjects\Schemas\WeightSchema;
use Jasara\AmznSPA\DataTransferObjects\Validators\StringEnumValidator;
use Spatie\DataTransferObject\Attributes\CastWith;
use Spatie\DataTransferObject\Casters\ArrayCaster;
use Spatie\DataTransferObject\DataTransferObject;

class PartneredLtlDataOutputSchema extends DataTransferObject
Expand All @@ -24,28 +25,29 @@ class PartneredLtlDataOutputSchema extends DataTransferObject
#[CastWith(CarbonFromStringCaster::class)]
public CarbonImmutable $freight_ready_date;

#[CastWith(ArrayCaster::class, itemType: PalletSchema::class)]
public PalletListSchema $pallet_list;

public WeightSchema $total_weight;
public ?WeightSchema $total_weight;

public ?AmountSchema $seller_declared_value;

public AmountSchema $amazon_calculated_value;

#[CastWith(CarbonFromStringCaster::class)]
public CarbonImmutable $preview_pickup_date;
public ?CarbonImmutable $preview_pickup_date;

#[CastWith(CarbonFromStringCaster::class)]
public CarbonImmutable $preview_delivery_date;
public ?CarbonImmutable $preview_delivery_date;

#[StringEnumValidator(AmazonEnums::SELLER_FREIGHT_CLASSES)]
public string $preview_freight_class;
public ?string $preview_freight_class;

public string $amazon_reference_id;
public ?string $amazon_reference_id;

public bool $is_bill_of_lading_available;
public ?bool $is_bill_of_lading_available;

public ?PartneredEstimateSchema $partnered_estimate;

public string $carrier_name;
public ?string $carrier_name;
}
20 changes: 20 additions & 0 deletions tests/Unit/Resources/FulfillmentInboundResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,26 @@ public function testGetTransportDetails_Issue6_TrackingIDNull()
});
}

public function testGetTransportDetails_Issue7_PalletListArray()
{
list($config, $http) = $this->setupConfigWithFakeHttp('fulfillment-inbound/issues/issue-7-pallet-list-array');

$shipment_id = Str::random();

$amzn = new AmznSPA($config);
$amzn = $amzn->usingMarketplace('ATVPDKIKX0DER');
$response = $amzn->fulfillment_inbound->getTransportDetails($shipment_id);

$this->assertInstanceOf(GetTransportDetailsResponse::class, $response);

$http->assertSent(function (Request $request) use ($shipment_id) {
$this->assertEquals('GET', $request->method());
$this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/transport', urldecode($request->url()));

return true;
});
}

public function testPutTransportDetails()
{
list($config, $http) = $this->setupConfigWithFakeHttp('fulfillment-inbound/put-transport-details');
Expand Down
141 changes: 141 additions & 0 deletions tests/stubs/fulfillment-inbound/issues/issue-7-pallet-list-array.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"payload": {
"TransportContent": {
"TransportHeader": {
"SellerId": "AABBCC",
"ShipmentId": "FBAAABBCC",
"IsPartnered": true,
"ShipmentType": "LTL"
},
"TransportDetails": {
"PartneredLtlData": {
"Contact": {
"Name": "x",
"Phone": "1",
"Email": "x@x.com",
"Fax": "1"
},
"BoxCount": 108,
"FreightReadyDate": "Sun Jul 18 00:00:00 GMT 2021",
"PalletList": [
{
"Dimensions": {
"Length": 40,
"Width": 48,
"Height": 64,
"Unit": "IN"
},
"Weight": {
"Value": 451,
"Unit": "pounds"
}
},
{
"Dimensions": {
"Length": 40,
"Width": 48,
"Height": 58,
"Unit": "IN"
},
"Weight": {
"Value": 372,
"Unit": "pounds"
}
},
{
"Dimensions": {
"Length": 40,
"Width": 48,
"Height": 66,
"Unit": "IN"
},
"Weight": {
"Value": 325,
"Unit": "pounds"
}
},
{
"Dimensions": {
"Length": 40,
"Width": 48,
"Height": 66,
"Unit": "IN"
},
"Weight": {
"Value": 520,
"Unit": "pounds"
}
},
{
"Dimensions": {
"Length": 40,
"Width": 48,
"Height": 66,
"Unit": "IN"
},
"Weight": {
"Value": 366,
"Unit": "pounds"
}
},
{
"Dimensions": {
"Length": 40,
"Width": 48,
"Height": 67,
"Unit": "IN"
},
"Weight": {
"Value": 372,
"Unit": "pounds"
}
},
{
"Dimensions": {
"Length": 40,
"Width": 48,
"Height": 64,
"Unit": "IN"
},
"Weight": {
"Value": 438,
"Unit": "pounds"
}
},
{
"Dimensions": {
"Length": 40,
"Width": 48,
"Height": 59,
"Unit": "IN"
},
"Weight": {
"Value": 420,
"Unit": "pounds"
}
},
{
"Dimensions": {
"Length": 40,
"Width": 48,
"Height": 58,
"Unit": "IN"
},
"Weight": {
"Value": 275,
"Unit": "pounds"
}
}
],
"AmazonCalculatedValue": {
"CurrencyCode": "USD",
"Value": 122.5
}
}
},
"TransportResult": {
"TransportStatus": "WORKING"
}
}
}
}

0 comments on commit 3c57dd9

Please sign in to comment.