Skip to content

Commit ac853da

Browse files
committed
Add Delivery by Amazon API (v2022-07-01)
1 parent 87f4fb2 commit ac853da

File tree

13 files changed

+2024
-3
lines changed

13 files changed

+2024
-3
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ A PHP library for connecting to Amazon's [Selling Partner API](https://github.co
2525

2626
---
2727

28-
**I'm available for consulting work!** If you need support designing and building applications with Amazon, Walmart, or other e-commerce APIs, or building SDKs in PHP, I can help. Shoot me an email at [jesse@highsidelabs.co](mailto:jesse@highsidelabs.co).
29-
3028
If you've found any of my packages useful, please consider [becoming a Sponsor](https://github.com/sponsors/jlevers), or making a one-time donation via the button below. I appreciate any and all support! Keeping open source projects alive is a community effort.
3129

3230
<p align="center">
@@ -35,14 +33,16 @@ If you've found any of my packages useful, please consider [becoming a Sponsor](
3533

3634
### Sponsored by **[Tesmo](https://tesmollc.com)**.
3735

36+
### Sponsored by **[Highside Labs](https://tools.highsidelabs.co/starter-kit)**. Get started with SP API development on Laravel in minutes.
37+
3838
---
3939

4040
> [!NOTE]
4141
> If you're looking for the documentation for v5 of this package, you can find it [here](https://github.com/jlevers/selling-partner-api/tree/v5.0).
4242
4343
## Features
4444

45-
* Supports all Selling Partner API operations (for Sellers and Vendors) as of 10/27/2025
45+
* Supports all Selling Partner API operations (for Sellers and Vendors) as of 12/6/2025
4646
* Automatically generates Restricted Data Tokens for all calls that require them -- no extra calls to the Tokens API needed
4747
* Includes a [`Document` helper class](#uploading-and-downloading-documents) for uploading and downloading feed/report documents
4848
* Can handle the end-to-end OAuth flow, from building authorization URLs to converting authorization codes into refresh tokens
@@ -259,6 +259,10 @@ $sellerConnector = SellingPartnerApi::seller(/* ... */);
259259
```php
260260
$dataKioskApi = $sellerConnector->dataKioskV20231115();
261261
```
262+
* **Delivery by Amazon API (v2022-07-01)** ([docs](https://developer-docs.amazon.com/sp-api/reference/delivery-by-amazon-v2022-07-01))
263+
```php
264+
$deliveryByAmazonApi = $sellerConnector->deliveryByAmazonV20220701();
265+
```
262266
* **EasyShip API (v2022-03-23)** ([docs](https://developer-docs.amazon.com/sp-api/docs/easy-ship-api-v2022-03-23-reference))
263267
```php
264268
$easyShipApi = $sellerConnector->easyShipV20220323();

resources/apis.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@
7171
}
7272
]
7373
},
74+
"delivery-by-amazon": {
75+
"name": "Delivery by Amazon",
76+
"versions": [
77+
{
78+
"version": "2022-07-01",
79+
"url": "https://raw.githubusercontent.com/amzn/selling-partner-api-models/refs/heads/main/models/delivery-by-amazon/deliveryShipmentInvoiceV2022-07-01.json"
80+
}
81+
]
82+
},
7483
"easy-ship": {
7584
"name": "Easy Ship",
7685
"versions": [

resources/models/raw/seller/delivery-by-amazon/v2022-07-01.json

Lines changed: 835 additions & 0 deletions
Large diffs are not rendered by default.

resources/models/seller/delivery-by-amazon/v2022-07-01.json

Lines changed: 844 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace SellingPartnerApi\Seller\DeliveryByAmazonV20220701;
4+
5+
use Saloon\Http\Response;
6+
use SellingPartnerApi\BaseResource;
7+
use SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Dto\SubmitInvoiceRequest;
8+
use SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Requests\GetInvoiceStatus;
9+
use SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Requests\SubmitInvoice;
10+
11+
class Api extends BaseResource
12+
{
13+
/**
14+
* @param SubmitInvoiceRequest $submitInvoiceRequest The request schema for the `submitInvoice` operation.
15+
* @param ?string $orderId The identifier for the order.
16+
* @param ?string $shipmentId The identifier for the shipment.
17+
*/
18+
public function submitInvoice(
19+
SubmitInvoiceRequest $submitInvoiceRequest,
20+
?string $orderId = null,
21+
?string $shipmentId = null,
22+
): Response {
23+
$request = new SubmitInvoice($submitInvoiceRequest, $orderId, $shipmentId);
24+
25+
return $this->connector->send($request);
26+
}
27+
28+
/**
29+
* @param string $marketplaceId The marketplace identifier.
30+
* @param string $invoiceType The invoice's type.
31+
* @param string $programType The Amazon program that seller is currently enrolled.
32+
* @param ?string $orderId The order identifier.
33+
* @param ?string $shipmentId The shipment identifier.
34+
*/
35+
public function getInvoiceStatus(
36+
string $marketplaceId,
37+
string $invoiceType,
38+
string $programType,
39+
?string $orderId = null,
40+
?string $shipmentId = null,
41+
): Response {
42+
$request = new GetInvoiceStatus($marketplaceId, $invoiceType, $programType, $orderId, $shipmentId);
43+
44+
return $this->connector->send($request);
45+
}
46+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated by Saloon SDK Generator
5+
* Generator: Crescat\SaloonSdkGenerator\Generators\DtoGenerator
6+
* Do not modify it directly.
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
namespace SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Dto;
12+
13+
use SellingPartnerApi\Dto;
14+
15+
final class Error extends Dto
16+
{
17+
/**
18+
* @param string $code An error code that identifies the type of error that occurred.
19+
* @param string $message A message that describes the error condition.
20+
* @param ?string $details Additional details that can help the caller understand or fix the issue.
21+
*/
22+
public function __construct(
23+
public string $code,
24+
public string $message,
25+
public ?string $details = null,
26+
) {}
27+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated by Saloon SDK Generator
5+
* Generator: Crescat\SaloonSdkGenerator\Generators\DtoGenerator
6+
* Do not modify it directly.
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
namespace SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Dto;
12+
13+
use SellingPartnerApi\Dto;
14+
15+
final class SubmitInvoiceRequest extends Dto
16+
{
17+
protected static array $attributeMap = ['contentMd5value' => 'contentMD5Value'];
18+
19+
/**
20+
* @param string $invoiceContent Shipment invoice document content.
21+
* @param string $marketplaceId An Amazon marketplace identifier.
22+
* @param string $contentMd5value MD5 sum for validating the invoice data. For more information about calculating this value, see [Working with Content-MD5 Checksums](https://docs.developer.amazonservices.com/en_US/dev_guide/DG_MD5.html).
23+
* @param string $invoiceType The invoice type.
24+
* @param string $programType The Amazon program type.
25+
*/
26+
public function __construct(
27+
public string $invoiceContent,
28+
public string $marketplaceId,
29+
public string $contentMd5value,
30+
public string $invoiceType,
31+
public string $programType,
32+
) {}
33+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated by Saloon SDK Generator
5+
* Generator: SellingPartnerApi\Generator\Generators\RequestGenerator
6+
* Do not modify it directly.
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
namespace SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Requests;
12+
13+
use Exception;
14+
use Saloon\Enums\Method;
15+
use Saloon\Http\Response;
16+
use SellingPartnerApi\Request;
17+
use SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Responses\ErrorList;
18+
use SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Responses\GetInvoiceStatusResponse;
19+
20+
/**
21+
* getInvoiceStatus
22+
*/
23+
class GetInvoiceStatus extends Request
24+
{
25+
protected Method $method = Method::GET;
26+
27+
/**
28+
* @param string $marketplaceId The marketplace identifier.
29+
* @param string $invoiceType The invoice's type.
30+
* @param string $programType The Amazon program that seller is currently enrolled.
31+
* @param ?string $orderId The order identifier.
32+
* @param ?string $shipmentId The shipment identifier.
33+
*/
34+
public function __construct(
35+
protected string $marketplaceId,
36+
protected string $invoiceType,
37+
protected string $programType,
38+
protected ?string $orderId = null,
39+
protected ?string $shipmentId = null,
40+
) {}
41+
42+
public function resolveEndpoint(): string
43+
{
44+
return '/delivery/2022-07-01/invoice/status';
45+
}
46+
47+
public function createDtoFromResponse(Response $response): GetInvoiceStatusResponse|ErrorList
48+
{
49+
$status = $response->status();
50+
$responseCls = match ($status) {
51+
200, 400, 401, 403, 404, 415, 429, 500, 503 => GetInvoiceStatusResponse::class,
52+
413 => ErrorList::class,
53+
default => throw new Exception("Unhandled response status: {$status}")
54+
};
55+
56+
return $responseCls::deserialize($response->json());
57+
}
58+
59+
public function defaultQuery(): array
60+
{
61+
return array_filter([
62+
'marketplaceId' => $this->marketplaceId,
63+
'invoiceType' => $this->invoiceType,
64+
'programType' => $this->programType,
65+
'orderId' => $this->orderId,
66+
'shipmentId' => $this->shipmentId,
67+
]);
68+
}
69+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated by Saloon SDK Generator
5+
* Generator: SellingPartnerApi\Generator\Generators\RequestGenerator
6+
* Do not modify it directly.
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
namespace SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Requests;
12+
13+
use Exception;
14+
use Saloon\Contracts\Body\HasBody;
15+
use Saloon\Enums\Method;
16+
use Saloon\Http\Response;
17+
use Saloon\Traits\Body\HasJsonBody;
18+
use SellingPartnerApi\Request;
19+
use SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Dto\SubmitInvoiceRequest;
20+
use SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Responses\ErrorList;
21+
use SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Responses\SubmitInvoiceResponse;
22+
23+
/**
24+
* submitInvoice
25+
*/
26+
class SubmitInvoice extends Request implements HasBody
27+
{
28+
use HasJsonBody;
29+
30+
protected Method $method = Method::POST;
31+
32+
/**
33+
* @param SubmitInvoiceRequest $submitInvoiceRequest The request schema for the `submitInvoice` operation.
34+
* @param ?string $orderId The identifier for the order.
35+
* @param ?string $shipmentId The identifier for the shipment.
36+
*/
37+
public function __construct(
38+
public SubmitInvoiceRequest $submitInvoiceRequest,
39+
protected ?string $orderId = null,
40+
protected ?string $shipmentId = null,
41+
) {}
42+
43+
public function resolveEndpoint(): string
44+
{
45+
return '/delivery/2022-07-01/invoice';
46+
}
47+
48+
public function createDtoFromResponse(Response $response): SubmitInvoiceResponse|ErrorList
49+
{
50+
$status = $response->status();
51+
$responseCls = match ($status) {
52+
200, 400, 401, 403, 404, 415, 429, 500, 503 => SubmitInvoiceResponse::class,
53+
413 => ErrorList::class,
54+
default => throw new Exception("Unhandled response status: {$status}")
55+
};
56+
57+
return $responseCls::deserialize($response->json());
58+
}
59+
60+
public function defaultBody(): array
61+
{
62+
return $this->submitInvoiceRequest->toArray();
63+
}
64+
65+
public function defaultQuery(): array
66+
{
67+
return array_filter(['orderId' => $this->orderId, 'shipmentId' => $this->shipmentId]);
68+
}
69+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated by Saloon SDK Generator
5+
* Generator: SellingPartnerApi\Generator\Generators\ResponseGenerator
6+
* Do not modify it directly.
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
namespace SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Responses;
12+
13+
use SellingPartnerApi\Response;
14+
use SellingPartnerApi\Seller\DeliveryByAmazonV20220701\Dto\Error;
15+
16+
final class ErrorList extends Response
17+
{
18+
protected static array $complexArrayTypes = ['errors' => Error::class];
19+
20+
/**
21+
* @param Error[] $errors A list of error responses returned when a request is unsuccessful.
22+
*/
23+
public function __construct(
24+
public readonly array $errors,
25+
) {}
26+
}

0 commit comments

Comments
 (0)