|
| 1 | +import urllib.parse |
| 2 | + |
| 3 | +from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse |
| 4 | + |
| 5 | + |
| 6 | +class EasyShip(Client): |
| 7 | + """ |
| 8 | + Easy_ SP-API Client |
| 9 | + :link: |
| 10 | +
|
| 11 | + Use the Selling Partner API for Easy Ship to build applications for sellers to manage and ship Amazon Easy Ship orders. With this API, you can get available time slots, schedule and reschedule Easy Ship orders, and print shipping labels, invoices, and warranties. To review the differences in Easy Ship operations by marketplace, refer to [Marketplace support](https://developer-docs.amazon.com/sp-api/docs/easyship-api-v2022-03-23-use-case-guide#marketplace-support). |
| 12 | + """ |
| 13 | + |
| 14 | + |
| 15 | + @sp_endpoint('/easyShip/2022-03-23/timeSlot', method='POST') |
| 16 | + def list_handover_slots(self, **kwargs) -> ApiResponse: |
| 17 | + """ |
| 18 | + list_handover_slots(self, **kwargs) -> ApiResponse |
| 19 | +
|
| 20 | + Returns time slots available for Easy Ship orders to be scheduled based on the package weight and dimensions that the seller specifies. |
| 21 | +
|
| 22 | +This operation is available for scheduled and unscheduled orders based on marketplace support. See **Get Time Slots** in the [Marketplace Support Table](doc:easyship-api-v2022-03-23-use-case-guide#marketplace-support-table). |
| 23 | +
|
| 24 | +This operation can return time slots that have either pickup or drop-off handover methods - see **Supported Handover Methods** in the [Marketplace Support Table](doc:easyship-api-v2022-03-23-use-case-guide#marketplace-support-table). |
| 25 | +
|
| 26 | +**Usage Plan:** |
| 27 | +
|
| 28 | +| Rate (requests per second) | Burst | |
| 29 | +| ---- | ---- | |
| 30 | +| 1 | 5 | |
| 31 | +
|
| 32 | +The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api). |
| 33 | +
|
| 34 | + Args: |
| 35 | + |
| 36 | + ListHandoverSlotsRequest: | {'description': 'The request schema for the `listHandoverSlots` operation.', |
| 37 | + 'properties': {'amazonOrderId': {'$ref': '#/definitions/AmazonOrderId'}, 'marketplaceId': {'$ref': '#/definitions/String'}, 'packageDimensions': {'$ref': '#/definitions/Dimensions'}, 'packageWeight': {'$ref': '#/definitions/Weight'}}, |
| 38 | + 'required': ['marketplaceId', 'amazonOrderId', 'packageDimensions', 'packageWeight'], |
| 39 | + 'type': 'object'} |
| 40 | + |
| 41 | +
|
| 42 | + Returns: |
| 43 | + ApiResponse: |
| 44 | + """ |
| 45 | + |
| 46 | + return self._request(kwargs.pop('path'), data=kwargs) |
| 47 | + |
| 48 | + |
| 49 | + @sp_endpoint('/easyShip/2022-03-23/package', method='GET') |
| 50 | + def get_scheduled_package(self, **kwargs) -> ApiResponse: |
| 51 | + """ |
| 52 | + get_scheduled_package(self, **kwargs) -> ApiResponse |
| 53 | +
|
| 54 | + Returns information about a package, including dimensions, weight, time slot information for handover, invoice and item information, and status. |
| 55 | +
|
| 56 | +**Usage Plan:** |
| 57 | +
|
| 58 | +| Rate (requests per second) | Burst | |
| 59 | +| ---- | ---- | |
| 60 | +| 1 | 5 | |
| 61 | +
|
| 62 | +The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api). |
| 63 | +
|
| 64 | + Args: |
| 65 | + |
| 66 | + key amazonOrderId:string | * REQUIRED An Amazon-defined order identifier. Identifies the order that the seller wants to deliver using Amazon Easy Ship. |
| 67 | + |
| 68 | + key marketplaceId:string | * REQUIRED An identifier for the marketplace in which the seller is selling. |
| 69 | + |
| 70 | +
|
| 71 | + Returns: |
| 72 | + ApiResponse: |
| 73 | + """ |
| 74 | + |
| 75 | + return self._request(kwargs.pop('path'), params=kwargs) |
| 76 | + |
| 77 | + |
| 78 | + @sp_endpoint('/easyShip/2022-03-23/package', method='POST') |
| 79 | + def create_scheduled_package(self, **kwargs) -> ApiResponse: |
| 80 | + """ |
| 81 | + create_scheduled_package(self, **kwargs) -> ApiResponse |
| 82 | +
|
| 83 | + Schedules an Easy Ship order and returns the scheduled package information. |
| 84 | +
|
| 85 | +This operation does the following: |
| 86 | +
|
| 87 | +* Specifies the time slot and handover method for the order to be scheduled for delivery. |
| 88 | +
|
| 89 | +* Updates the Easy Ship order status. |
| 90 | +
|
| 91 | +* Generates a shipping label and an invoice. Calling `createScheduledPackage` also generates a warranty document if you specify a `SerialNumber` value. To get these documents, see [How to get invoice, shipping label, and warranty documents](doc:easyship-api-v2022-03-23-use-case-guide). |
| 92 | +
|
| 93 | +* Shows the status of Easy Ship orders when you call the `getOrders` operation of the Selling Partner API for Orders and examine the `EasyShipShipmentStatus` property in the response body. |
| 94 | +
|
| 95 | +See the **Shipping Label**, **Invoice**, and **Warranty** columns in the [Marketplace Support Table](doc:easyship-api-v2022-03-23-use-case-guide#marketplace-support-table) to see which documents are supported in each marketplace. |
| 96 | +
|
| 97 | +**Usage Plan:** |
| 98 | +
|
| 99 | +| Rate (requests per second) | Burst | |
| 100 | +| ---- | ---- | |
| 101 | +| 1 | 5 | |
| 102 | +
|
| 103 | +The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api). |
| 104 | +
|
| 105 | + Args: |
| 106 | + |
| 107 | + CreateScheduledPackageRequest: | * REQUIRED {'description': 'The request schema for the `createScheduledPackage` operation.', |
| 108 | + 'properties': {'amazonOrderId': {'$ref': '#/definitions/AmazonOrderId'}, 'marketplaceId': {'$ref': '#/definitions/String'}, 'packageDetails': {'$ref': '#/definitions/PackageDetails'}}, |
| 109 | + 'required': ['amazonOrderId', 'marketplaceId', 'packageDetails'], |
| 110 | + 'type': 'object'} |
| 111 | + |
| 112 | +
|
| 113 | + Returns: |
| 114 | + ApiResponse: |
| 115 | + """ |
| 116 | + |
| 117 | + return self._request(kwargs.pop('path'), data=kwargs) |
| 118 | + |
| 119 | + |
| 120 | + @sp_endpoint('/easyShip/2022-03-23/package', method='PATCH') |
| 121 | + def update_scheduled_packages(self, **kwargs) -> ApiResponse: |
| 122 | + """ |
| 123 | + update_scheduled_packages(self, **kwargs) -> ApiResponse |
| 124 | +
|
| 125 | + Updates the time slot for handing over the package indicated by the specified `scheduledPackageId`. You can get the new `slotId` value for the time slot by calling the `listHandoverSlots` operation before making another `patch` call. |
| 126 | +
|
| 127 | +See the **Update Package** column in the [Marketplace Support Table](doc:easyship-api-v2022-03-23-use-case-guide#marketplace-support-table) to see which marketplaces this operation is supported in. |
| 128 | +
|
| 129 | +**Usage Plan:** |
| 130 | +
|
| 131 | +| Rate (requests per second) | Burst | |
| 132 | +| ---- | ---- | |
| 133 | +| 1 | 5 | |
| 134 | +
|
| 135 | +The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api). |
| 136 | +
|
| 137 | + Args: |
| 138 | + |
| 139 | + UpdateScheduledPackagesRequest: | {'description': 'The request schema for the `updateScheduledPackages` operation.', |
| 140 | + 'properties': {'marketplaceId': {'$ref': '#/definitions/String'}, 'updatePackageDetailsList': {'$ref': '#/definitions/UpdatePackageDetailsList'}}, |
| 141 | + 'required': ['marketplaceId', 'updatePackageDetailsList'], |
| 142 | + 'type': 'object'} |
| 143 | + |
| 144 | +
|
| 145 | + Returns: |
| 146 | + ApiResponse: |
| 147 | + """ |
| 148 | + |
| 149 | + return self._request(kwargs.pop('path'), data=kwargs) |
| 150 | + |
| 151 | + |
| 152 | + @sp_endpoint('/easyShip/2022-03-23/packages/bulk', method='POST') |
| 153 | + def create_scheduled_package_bulk(self, **kwargs) -> ApiResponse: |
| 154 | + """ |
| 155 | + create_scheduled_package_bulk(self, **kwargs) -> ApiResponse |
| 156 | +
|
| 157 | + This operation automatically schedules a time slot for all the `amazonOrderId`s given as input, generating the associated shipping labels, along with other compliance documents according to the marketplace (refer to the [marketplace document support table](doc:easyship-api-v2022-03-23-use-case-guide#marketplace-support-table)). |
| 158 | +
|
| 159 | +Developers calling this operation may optionally assign a `packageDetails` object, allowing them to input a preferred time slot for each order in their request. In this case, Amazon will try to schedule the respective packages using their optional settings. On the other hand, *i.e.*, if the time slot is not provided, Amazon will then pick the earliest time slot possible. |
| 160 | +
|
| 161 | +Regarding the shipping label's file format, external developers are able to choose between PDF or ZPL, and Amazon will create the label accordingly. |
| 162 | +
|
| 163 | +This operation returns an array composed of the scheduled packages, and a short-lived URL pointing to a zip file containing the generated shipping labels and the other documents enabled for your marketplace. If at least an order couldn't be scheduled, then Amazon adds the `rejectedOrders` list into the response, which contains an entry for each order we couldn't process. Each entry is composed of an error message describing the reason of the failure, so that sellers can take action. |
| 164 | +
|
| 165 | +The table below displays the supported request and burst maximum rates: |
| 166 | +
|
| 167 | +**Usage Plan:** |
| 168 | +
|
| 169 | +| Rate (requests per second) | Burst | |
| 170 | +| ---- | ---- | |
| 171 | +| 1 | 5 | |
| 172 | +
|
| 173 | +The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api). |
| 174 | +
|
| 175 | + Args: |
| 176 | + |
| 177 | + CreateScheduledPackagesRequest: | * REQUIRED {'description': 'The request body for the POST /easyShip/2022-03-23/packages/bulk API.', |
| 178 | + 'properties': {'labelFormat': {'$ref': '#/definitions/LabelFormat'}, |
| 179 | + 'marketplaceId': {'$ref': '#/definitions/String'}, |
| 180 | + 'orderScheduleDetailsList': {'description': 'An array allowing users to specify orders to be scheduled.', 'items': {'$ref': '#/definitions/OrderScheduleDetails'}, 'minItems': 1, 'type': 'array'}}, |
| 181 | + 'required': ['marketplaceId', 'orderScheduleDetailsList', 'labelFormat'], |
| 182 | + 'type': 'object'} |
| 183 | + |
| 184 | +
|
| 185 | + Returns: |
| 186 | + ApiResponse: |
| 187 | + """ |
| 188 | + |
| 189 | + return self._request(kwargs.pop('path'), data=kwargs) |
| 190 | + |
0 commit comments