Skip to content

Commit a2f7102

Browse files
committed
improve versions
1 parent f51010b commit a2f7102

40 files changed

Lines changed: 3324 additions & 1 deletion

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,5 @@ dmypy.json
141141
cython_debug/
142142

143143
env.env
144-
AGENTS.md
144+
AGENTS.md
145+
models

sp_api/api/delivery_by_amazon/__init__.py

Whitespace-only changes.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
from __future__ import annotations
2+
3+
import enum
4+
from typing import Any, Literal, TYPE_CHECKING, overload
5+
from sp_api.util.versioned_client import VersionedClientMeta
6+
7+
from sp_api.base import Client
8+
9+
from .delivery_by_amazon_2022_07_01 import DeliveryByAmazonV20220701
10+
11+
12+
class DeliveryByAmazonVersion(str, enum.Enum):
13+
V_2022_07_01 = "2022-07-01"
14+
LATEST = "2022-07-01"
15+
16+
17+
if TYPE_CHECKING:
18+
19+
class _DeliveryByAmazonMeta(VersionedClientMeta):
20+
@overload
21+
def __call__(
22+
cls,
23+
*args: Any,
24+
version: Literal[DeliveryByAmazonVersion.V_2022_07_01, DeliveryByAmazonVersion.LATEST, "2022-07-01"],
25+
**kwargs: Any,
26+
) -> DeliveryByAmazonV20220701: ...
27+
28+
@overload
29+
def __call__(
30+
cls,
31+
*args: Any,
32+
version: None = None,
33+
**kwargs: Any,
34+
) -> DeliveryByAmazonV20220701: ...
35+
36+
@overload
37+
def __call__(
38+
cls,
39+
*args: Any,
40+
version: str | DeliveryByAmazonVersion,
41+
**kwargs: Any,
42+
) -> Client: ...
43+
44+
45+
else:
46+
_DeliveryByAmazonMeta = VersionedClientMeta
47+
48+
49+
class DeliveryByAmazon(Client, metaclass=_DeliveryByAmazonMeta):
50+
"""DeliveryByAmazon API client.
51+
52+
This class dispatches to a versioned DeliveryByAmazon API client.
53+
54+
If you do not pass a version, the constructor returns the oldest supported implementation ("2022-07-01").
55+
"""
56+
57+
if TYPE_CHECKING:
58+
@overload
59+
def __new__(
60+
cls,
61+
*args: Any,
62+
version: Literal[DeliveryByAmazonVersion.V_2022_07_01, DeliveryByAmazonVersion.LATEST, "2022-07-01"],
63+
**kwargs: Any,
64+
) -> DeliveryByAmazonV20220701: ...
65+
66+
@overload
67+
def __new__(
68+
cls,
69+
*args: Any,
70+
version: None = None,
71+
**kwargs: Any,
72+
) -> DeliveryByAmazonV20220701: ...
73+
74+
@overload
75+
def __new__(
76+
cls,
77+
*args: Any,
78+
version: str | DeliveryByAmazonVersion,
79+
**kwargs: Any,
80+
) -> Client: ...
81+
82+
_DISPATCH = True
83+
84+
_DEFAULT_VERSION = "2022-07-01"
85+
86+
_VERSION_MAP = {
87+
"2022-07-01": DeliveryByAmazonV20220701,
88+
}
89+
90+
_VERSION_ALIASES = {
91+
"2022-07-01": "2022-07-01",
92+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse
2+
3+
4+
class DeliveryByAmazonV20220701(Client):
5+
"""
6+
DeliveryByAmazon SP-API Client
7+
:link:
8+
9+
The Selling Partner API for Delivery Shipment Invoicing helps you programmatically retrieve shipment invoice information in the Brazil marketplace for a selling partner’s orders.
10+
"""
11+
12+
@sp_endpoint("/delivery/2022-07-01/invoice", method="POST")
13+
def submit_invoice(self, **kwargs) -> ApiResponse:
14+
"""
15+
submit_invoice(self, **kwargs) -> ApiResponse
16+
17+
Submits a shipment invoice for a given order or shipment. You must specify either an `orderId` or `shipmentId` as query parameter. If both parameters are supplied, `orderId` takes precedence over `shipmentId`.
18+
19+
**Usage Plan:**
20+
21+
| Rate (requests per second) | Burst |
22+
| ---- | ---- |
23+
| 1.133 | 25 |
24+
25+
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).
26+
27+
Args:
28+
key orderId:string | The identifier for the order.
29+
key shipmentId:string | The identifier for the shipment.
30+
body: | * REQUIRED {'description': 'The request schema for the `submitInvoice` operation.',
31+
'properties': {'contentMD5Value': {'description': 'MD5 sum for validating the invoice data. For more information about calculating this value, see [Working with Content-MD5 '
32+
'Checksums](https://docs.developer.amazonservices.com/en_US/dev_guide/DG_MD5.html).',
33+
'type': 'string'},
34+
'invoiceContent': {'$ref': '#/definitions/Blob', 'description': "The binary object representing an invoice's content."},
35+
'invoiceType': {'$ref': '#/definitions/InvoiceType', 'description': 'The type of an invoice.'},
36+
'marketplaceId': {'description': 'An Amazon marketplace identifier.', 'type': 'string'},
37+
'programType': {'$ref': '#/definitions/ProgramType', 'description': 'The Amazon program that the seller is currently enrolled.'}},
38+
'required': ['contentMD5Value', 'invoiceContent', 'invoiceType', 'programType', 'marketplaceId'],
39+
'type': 'object'}
40+
41+
Returns:
42+
ApiResponse:
43+
"""
44+
params = {}
45+
if "orderId" in kwargs:
46+
params["orderId"] = kwargs.pop("orderId")
47+
if "shipmentId" in kwargs:
48+
params["shipmentId"] = kwargs.pop("shipmentId")
49+
return self._request(kwargs.pop("path"), params=params, data=kwargs, add_marketplace=False)
50+
51+
@sp_endpoint("/delivery/2022-07-01/invoice/status", method="GET")
52+
def get_invoice_status(self, **kwargs) -> ApiResponse:
53+
"""
54+
get_invoice_status(self, **kwargs) -> ApiResponse
55+
56+
Returns the invoice status for the order or shipment you specify. You must specify either an `orderId` or `shipmentId` as query parameter. If both parameters are supplied, `orderId` takes precedence over `shipmentId`.
57+
58+
**Usage Plan:**
59+
60+
| Rate (requests per second) | Burst |
61+
| ---- | ---- |
62+
| 1.133 | 25 |
63+
64+
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).
65+
66+
Args:
67+
key orderId:string | The order identifier.
68+
key shipmentId:string | The shipment identifier.
69+
key marketplaceId:string | * REQUIRED The marketplace identifier.
70+
key invoiceType:string | * REQUIRED The invoice's type.
71+
key programType:string | * REQUIRED The Amazon program that seller is currently enrolled.
72+
73+
Returns:
74+
ApiResponse:
75+
"""
76+
return self._request(kwargs.pop("path"), params=kwargs, add_marketplace=False)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse
2+
3+
4+
class FinancesV20240601(Client):
5+
"""
6+
Finances Transfers SP-API Client
7+
:link:
8+
9+
The Selling Partner API for Transfers enables selling partners to retrieve payment methods and initiate payouts for their seller accounts. This API supports the following marketplaces: DE, FR, IT, ES, SE, NL, PL, and BE.
10+
"""
11+
12+
@sp_endpoint("/finances/transfers/2024-06-01/payouts", method="POST")
13+
def initiate_payout(self, **kwargs) -> ApiResponse:
14+
"""
15+
initiate_payout(self, **kwargs) -> ApiResponse
16+
17+
Initiates an on-demand payout to the seller's default deposit method in Seller Central for the given `marketplaceId` and `accountType`, if eligible. You can only initiate one on-demand payout for each marketplace and account type within a 24-hour period.
18+
19+
**Usage Plan:**
20+
21+
| Rate (requests per second) | Burst |
22+
| ---- | ---- |
23+
| 0.017 | 2 |
24+
25+
The `x-amzn-RateLimit-Limit` response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
26+
27+
Args:
28+
body: | * REQUIRED The request body for the `initiatePayout` operation.
29+
30+
Returns:
31+
ApiResponse:
32+
"""
33+
return self._request(kwargs.pop("path"), data=kwargs, add_marketplace=False)
34+
35+
@sp_endpoint("/finances/transfers/2024-06-01/paymentMethods", method="GET")
36+
def get_payment_methods(self, **kwargs) -> ApiResponse:
37+
"""
38+
get_payment_methods(self, **kwargs) -> ApiResponse
39+
40+
Returns the list of payment methods for the seller, which can be filtered by method type.
41+
42+
**Usage Plan:**
43+
44+
| Rate (requests per second) | Burst |
45+
| ---- | ---- |
46+
| .5 | 30 |
47+
48+
The `x-amzn-RateLimit-Limit` response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
49+
50+
Args:
51+
key marketplaceId:string | * REQUIRED The identifier of the marketplace from which you want to retrieve payment methods. For the list of possible marketplace identifiers, refer to [Marketplace IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids).
52+
key paymentMethodTypes:string | A comma-separated list of the payment method types you want to include in the response.
53+
54+
Returns:
55+
ApiResponse:
56+
"""
57+
return self._request(kwargs.pop("path"), params=kwargs, add_marketplace=False)

sp_api/api/invoices/__init__.py

Whitespace-only changes.

sp_api/api/invoices/invoices.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
from __future__ import annotations
2+
3+
import enum
4+
from typing import Any, Literal, TYPE_CHECKING, overload
5+
from sp_api.util.versioned_client import VersionedClientMeta
6+
7+
from sp_api.base import Client
8+
9+
from .invoices_2024_06_19 import InvoicesV20240619
10+
11+
12+
class InvoicesVersion(str, enum.Enum):
13+
V_2024_06_19 = "2024-06-19"
14+
LATEST = "2024-06-19"
15+
16+
17+
if TYPE_CHECKING:
18+
19+
class _InvoicesMeta(VersionedClientMeta):
20+
@overload
21+
def __call__(
22+
cls,
23+
*args: Any,
24+
version: Literal[InvoicesVersion.V_2024_06_19, InvoicesVersion.LATEST, "2024-06-19"],
25+
**kwargs: Any,
26+
) -> InvoicesV20240619: ...
27+
28+
@overload
29+
def __call__(
30+
cls,
31+
*args: Any,
32+
version: None = None,
33+
**kwargs: Any,
34+
) -> InvoicesV20240619: ...
35+
36+
@overload
37+
def __call__(
38+
cls,
39+
*args: Any,
40+
version: str | InvoicesVersion,
41+
**kwargs: Any,
42+
) -> Client: ...
43+
44+
45+
else:
46+
_InvoicesMeta = VersionedClientMeta
47+
48+
49+
class Invoices(Client, metaclass=_InvoicesMeta):
50+
"""Invoices API client.
51+
52+
This class dispatches to a versioned Invoices API client.
53+
54+
If you do not pass a version, the constructor returns the oldest supported implementation ("2024-06-19").
55+
"""
56+
57+
if TYPE_CHECKING:
58+
@overload
59+
def __new__(
60+
cls,
61+
*args: Any,
62+
version: Literal[InvoicesVersion.V_2024_06_19, InvoicesVersion.LATEST, "2024-06-19"],
63+
**kwargs: Any,
64+
) -> InvoicesV20240619: ...
65+
66+
@overload
67+
def __new__(
68+
cls,
69+
*args: Any,
70+
version: None = None,
71+
**kwargs: Any,
72+
) -> InvoicesV20240619: ...
73+
74+
@overload
75+
def __new__(
76+
cls,
77+
*args: Any,
78+
version: str | InvoicesVersion,
79+
**kwargs: Any,
80+
) -> Client: ...
81+
82+
_DISPATCH = True
83+
84+
_DEFAULT_VERSION = "2024-06-19"
85+
86+
_VERSION_MAP = {
87+
"2024-06-19": InvoicesV20240619,
88+
}
89+
90+
_VERSION_ALIASES = {
91+
"2024-06-19": "2024-06-19",
92+
}

0 commit comments

Comments
 (0)