checkout-intents 0.2.0__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checkout_intents/_version.py +1 -1
- checkout_intents/pagination.py +89 -0
- checkout_intents/resources/brands.py +4 -4
- checkout_intents/resources/checkout_intents.py +128 -8
- checkout_intents/types/__init__.py +1 -0
- checkout_intents/types/checkout_intent.py +5 -0
- checkout_intents/types/checkout_intent_list_params.py +22 -0
- checkout_intents/types/payment_method.py +22 -3
- checkout_intents/types/payment_method_param.py +22 -3
- checkout_intents/types/variant_selection.py +0 -8
- checkout_intents/types/variant_selection_param.py +0 -8
- {checkout_intents-0.2.0.dist-info → checkout_intents-0.3.1.dist-info}/METADATA +89 -12
- {checkout_intents-0.2.0.dist-info → checkout_intents-0.3.1.dist-info}/RECORD +15 -13
- {checkout_intents-0.2.0.dist-info → checkout_intents-0.3.1.dist-info}/WHEEL +0 -0
- {checkout_intents-0.2.0.dist-info → checkout_intents-0.3.1.dist-info}/licenses/LICENSE +0 -0
checkout_intents/_version.py
CHANGED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import List, Generic, TypeVar, Optional
|
|
4
|
+
from typing_extensions import override
|
|
5
|
+
|
|
6
|
+
from pydantic import Field as FieldInfo
|
|
7
|
+
|
|
8
|
+
from ._models import BaseModel
|
|
9
|
+
from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage
|
|
10
|
+
|
|
11
|
+
__all__ = ["CursorPaginationPageInfo", "SyncCursorPagination", "AsyncCursorPagination"]
|
|
12
|
+
|
|
13
|
+
_T = TypeVar("_T")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class CursorPaginationPageInfo(BaseModel):
|
|
17
|
+
end_cursor: Optional[str] = FieldInfo(alias="endCursor", default=None)
|
|
18
|
+
|
|
19
|
+
has_next_page: Optional[bool] = FieldInfo(alias="hasNextPage", default=None)
|
|
20
|
+
|
|
21
|
+
has_previous_page: Optional[bool] = FieldInfo(alias="hasPreviousPage", default=None)
|
|
22
|
+
|
|
23
|
+
start_cursor: Optional[str] = FieldInfo(alias="startCursor", default=None)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class SyncCursorPagination(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
|
|
27
|
+
data: List[_T]
|
|
28
|
+
page_info: Optional[CursorPaginationPageInfo] = FieldInfo(alias="pageInfo", default=None)
|
|
29
|
+
|
|
30
|
+
@override
|
|
31
|
+
def _get_page_items(self) -> List[_T]:
|
|
32
|
+
data = self.data
|
|
33
|
+
if not data:
|
|
34
|
+
return []
|
|
35
|
+
return data
|
|
36
|
+
|
|
37
|
+
@override
|
|
38
|
+
def next_page_info(self) -> Optional[PageInfo]:
|
|
39
|
+
if self._options.params.get("before"):
|
|
40
|
+
start_cursor = None
|
|
41
|
+
if self.page_info is not None:
|
|
42
|
+
if self.page_info.start_cursor is not None:
|
|
43
|
+
start_cursor = self.page_info.start_cursor
|
|
44
|
+
if not start_cursor:
|
|
45
|
+
return None
|
|
46
|
+
|
|
47
|
+
return PageInfo(params={"before": start_cursor})
|
|
48
|
+
|
|
49
|
+
end_cursor = None
|
|
50
|
+
if self.page_info is not None:
|
|
51
|
+
if self.page_info.end_cursor is not None:
|
|
52
|
+
end_cursor = self.page_info.end_cursor
|
|
53
|
+
if not end_cursor:
|
|
54
|
+
return None
|
|
55
|
+
|
|
56
|
+
return PageInfo(params={"after": end_cursor})
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class AsyncCursorPagination(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
|
|
60
|
+
data: List[_T]
|
|
61
|
+
page_info: Optional[CursorPaginationPageInfo] = FieldInfo(alias="pageInfo", default=None)
|
|
62
|
+
|
|
63
|
+
@override
|
|
64
|
+
def _get_page_items(self) -> List[_T]:
|
|
65
|
+
data = self.data
|
|
66
|
+
if not data:
|
|
67
|
+
return []
|
|
68
|
+
return data
|
|
69
|
+
|
|
70
|
+
@override
|
|
71
|
+
def next_page_info(self) -> Optional[PageInfo]:
|
|
72
|
+
if self._options.params.get("before"):
|
|
73
|
+
start_cursor = None
|
|
74
|
+
if self.page_info is not None:
|
|
75
|
+
if self.page_info.start_cursor is not None:
|
|
76
|
+
start_cursor = self.page_info.start_cursor
|
|
77
|
+
if not start_cursor:
|
|
78
|
+
return None
|
|
79
|
+
|
|
80
|
+
return PageInfo(params={"before": start_cursor})
|
|
81
|
+
|
|
82
|
+
end_cursor = None
|
|
83
|
+
if self.page_info is not None:
|
|
84
|
+
if self.page_info.end_cursor is not None:
|
|
85
|
+
end_cursor = self.page_info.end_cursor
|
|
86
|
+
if not end_cursor:
|
|
87
|
+
return None
|
|
88
|
+
|
|
89
|
+
return PageInfo(params={"after": end_cursor})
|
|
@@ -53,8 +53,8 @@ class BrandsResource(SyncAPIResource):
|
|
|
53
53
|
"""
|
|
54
54
|
Retrieve brand information by domain name
|
|
55
55
|
|
|
56
|
-
Look up a brand by its domain name (e.g. "aloyoga.com").
|
|
57
|
-
information including the marketplace type if the lookup succeeds.
|
|
56
|
+
Look up a brand by its domain name (e.g. "aloyoga.com" or "www.amazon.com").
|
|
57
|
+
Returns brand information including the marketplace type if the lookup succeeds.
|
|
58
58
|
|
|
59
59
|
Args:
|
|
60
60
|
domain: Represents a valid domain name string.
|
|
@@ -112,8 +112,8 @@ class AsyncBrandsResource(AsyncAPIResource):
|
|
|
112
112
|
"""
|
|
113
113
|
Retrieve brand information by domain name
|
|
114
114
|
|
|
115
|
-
Look up a brand by its domain name (e.g. "aloyoga.com").
|
|
116
|
-
information including the marketplace type if the lookup succeeds.
|
|
115
|
+
Look up a brand by its domain name (e.g. "aloyoga.com" or "www.amazon.com").
|
|
116
|
+
Returns brand information including the marketplace type if the lookup succeeds.
|
|
117
117
|
|
|
118
118
|
Args:
|
|
119
119
|
domain: Represents a valid domain name string.
|
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import logging
|
|
6
|
-
from typing import Any, Union, TypeVar, Callable, Iterable, cast
|
|
7
|
-
from typing_extensions import TypeGuard
|
|
6
|
+
from typing import Any, List, Union, TypeVar, Callable, Iterable, cast
|
|
7
|
+
from typing_extensions import Literal, TypeGuard
|
|
8
8
|
|
|
9
9
|
import httpx
|
|
10
10
|
|
|
11
11
|
from ..types import (
|
|
12
|
+
checkout_intent_list_params,
|
|
12
13
|
checkout_intent_create_params,
|
|
13
14
|
checkout_intent_confirm_params,
|
|
14
15
|
checkout_intent_add_payment_params,
|
|
15
16
|
)
|
|
16
|
-
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
17
|
+
from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
|
|
17
18
|
from .._utils import maybe_transform, async_maybe_transform
|
|
18
19
|
from .._compat import cached_property
|
|
19
20
|
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
@@ -23,8 +24,9 @@ from .._response import (
|
|
|
23
24
|
async_to_raw_response_wrapper,
|
|
24
25
|
async_to_streamed_response_wrapper,
|
|
25
26
|
)
|
|
27
|
+
from ..pagination import SyncCursorPagination, AsyncCursorPagination
|
|
26
28
|
from .._exceptions import PollTimeoutError
|
|
27
|
-
from .._base_client import make_request_options
|
|
29
|
+
from .._base_client import AsyncPaginator, make_request_options
|
|
28
30
|
from ..types.buyer_param import BuyerParam
|
|
29
31
|
from ..types.checkout_intent import (
|
|
30
32
|
CheckoutIntent,
|
|
@@ -146,6 +148,59 @@ class CheckoutIntentsResource(SyncAPIResource):
|
|
|
146
148
|
),
|
|
147
149
|
)
|
|
148
150
|
|
|
151
|
+
def list(
|
|
152
|
+
self,
|
|
153
|
+
*,
|
|
154
|
+
id: SequenceNotStr[str] | Omit = omit,
|
|
155
|
+
after: str | Omit = omit,
|
|
156
|
+
before: str | Omit = omit,
|
|
157
|
+
limit: float | Omit = omit,
|
|
158
|
+
state: List[Literal["retrieving_offer", "awaiting_confirmation", "placing_order", "completed", "failed"]]
|
|
159
|
+
| Omit = omit,
|
|
160
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
161
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
162
|
+
extra_headers: Headers | None = None,
|
|
163
|
+
extra_query: Query | None = None,
|
|
164
|
+
extra_body: Body | None = None,
|
|
165
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
166
|
+
) -> SyncCursorPagination[CheckoutIntent]:
|
|
167
|
+
"""
|
|
168
|
+
Retrieve a paginated list of checkout intents
|
|
169
|
+
|
|
170
|
+
Enables developers to query checkout intents associated with their account, with
|
|
171
|
+
filters and cursor-based pagination.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
extra_headers: Send extra headers
|
|
175
|
+
|
|
176
|
+
extra_query: Add additional query parameters to the request
|
|
177
|
+
|
|
178
|
+
extra_body: Add additional JSON properties to the request
|
|
179
|
+
|
|
180
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
181
|
+
"""
|
|
182
|
+
return self._get_api_list(
|
|
183
|
+
"/api/v1/checkout-intents",
|
|
184
|
+
page=SyncCursorPagination[CheckoutIntent],
|
|
185
|
+
options=make_request_options(
|
|
186
|
+
extra_headers=extra_headers,
|
|
187
|
+
extra_query=extra_query,
|
|
188
|
+
extra_body=extra_body,
|
|
189
|
+
timeout=timeout,
|
|
190
|
+
query=maybe_transform(
|
|
191
|
+
{
|
|
192
|
+
"id": id,
|
|
193
|
+
"after": after,
|
|
194
|
+
"before": before,
|
|
195
|
+
"limit": limit,
|
|
196
|
+
"state": state,
|
|
197
|
+
},
|
|
198
|
+
checkout_intent_list_params.CheckoutIntentListParams,
|
|
199
|
+
),
|
|
200
|
+
),
|
|
201
|
+
model=cast(Any, CheckoutIntent), # Union types cannot be passed in as arguments in the type system
|
|
202
|
+
)
|
|
203
|
+
|
|
149
204
|
def add_payment(
|
|
150
205
|
self,
|
|
151
206
|
id: str,
|
|
@@ -485,11 +540,11 @@ class CheckoutIntentsResource(SyncAPIResource):
|
|
|
485
540
|
buyer={
|
|
486
541
|
"address1": "123 Main St",
|
|
487
542
|
"city": "New York",
|
|
488
|
-
"country": "
|
|
543
|
+
"country": "US",
|
|
489
544
|
"email": "john.doe@example.com",
|
|
490
545
|
"first_name": "John",
|
|
491
546
|
"last_name": "Doe",
|
|
492
|
-
"phone": "
|
|
547
|
+
"phone": "1234567890",
|
|
493
548
|
"postal_code": "10001",
|
|
494
549
|
"province": "NY",
|
|
495
550
|
},
|
|
@@ -694,6 +749,59 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
|
|
|
694
749
|
),
|
|
695
750
|
)
|
|
696
751
|
|
|
752
|
+
def list(
|
|
753
|
+
self,
|
|
754
|
+
*,
|
|
755
|
+
id: SequenceNotStr[str] | Omit = omit,
|
|
756
|
+
after: str | Omit = omit,
|
|
757
|
+
before: str | Omit = omit,
|
|
758
|
+
limit: float | Omit = omit,
|
|
759
|
+
state: List[Literal["retrieving_offer", "awaiting_confirmation", "placing_order", "completed", "failed"]]
|
|
760
|
+
| Omit = omit,
|
|
761
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
762
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
763
|
+
extra_headers: Headers | None = None,
|
|
764
|
+
extra_query: Query | None = None,
|
|
765
|
+
extra_body: Body | None = None,
|
|
766
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
767
|
+
) -> AsyncPaginator[CheckoutIntent, AsyncCursorPagination[CheckoutIntent]]:
|
|
768
|
+
"""
|
|
769
|
+
Retrieve a paginated list of checkout intents
|
|
770
|
+
|
|
771
|
+
Enables developers to query checkout intents associated with their account, with
|
|
772
|
+
filters and cursor-based pagination.
|
|
773
|
+
|
|
774
|
+
Args:
|
|
775
|
+
extra_headers: Send extra headers
|
|
776
|
+
|
|
777
|
+
extra_query: Add additional query parameters to the request
|
|
778
|
+
|
|
779
|
+
extra_body: Add additional JSON properties to the request
|
|
780
|
+
|
|
781
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
782
|
+
"""
|
|
783
|
+
return self._get_api_list(
|
|
784
|
+
"/api/v1/checkout-intents",
|
|
785
|
+
page=AsyncCursorPagination[CheckoutIntent],
|
|
786
|
+
options=make_request_options(
|
|
787
|
+
extra_headers=extra_headers,
|
|
788
|
+
extra_query=extra_query,
|
|
789
|
+
extra_body=extra_body,
|
|
790
|
+
timeout=timeout,
|
|
791
|
+
query=maybe_transform(
|
|
792
|
+
{
|
|
793
|
+
"id": id,
|
|
794
|
+
"after": after,
|
|
795
|
+
"before": before,
|
|
796
|
+
"limit": limit,
|
|
797
|
+
"state": state,
|
|
798
|
+
},
|
|
799
|
+
checkout_intent_list_params.CheckoutIntentListParams,
|
|
800
|
+
),
|
|
801
|
+
),
|
|
802
|
+
model=cast(Any, CheckoutIntent), # Union types cannot be passed in as arguments in the type system
|
|
803
|
+
)
|
|
804
|
+
|
|
697
805
|
async def add_payment(
|
|
698
806
|
self,
|
|
699
807
|
id: str,
|
|
@@ -1033,11 +1141,11 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
|
|
|
1033
1141
|
buyer={
|
|
1034
1142
|
"address1": "123 Main St",
|
|
1035
1143
|
"city": "New York",
|
|
1036
|
-
"country": "
|
|
1144
|
+
"country": "US",
|
|
1037
1145
|
"email": "john.doe@example.com",
|
|
1038
1146
|
"first_name": "John",
|
|
1039
1147
|
"last_name": "Doe",
|
|
1040
|
-
"phone": "
|
|
1148
|
+
"phone": "1234567890",
|
|
1041
1149
|
"postal_code": "10001",
|
|
1042
1150
|
"province": "NY",
|
|
1043
1151
|
},
|
|
@@ -1148,6 +1256,9 @@ class CheckoutIntentsResourceWithRawResponse:
|
|
|
1148
1256
|
self.retrieve = to_raw_response_wrapper(
|
|
1149
1257
|
checkout_intents.retrieve,
|
|
1150
1258
|
)
|
|
1259
|
+
self.list = to_raw_response_wrapper(
|
|
1260
|
+
checkout_intents.list,
|
|
1261
|
+
)
|
|
1151
1262
|
self.add_payment = to_raw_response_wrapper(
|
|
1152
1263
|
checkout_intents.add_payment,
|
|
1153
1264
|
)
|
|
@@ -1178,6 +1289,9 @@ class AsyncCheckoutIntentsResourceWithRawResponse:
|
|
|
1178
1289
|
self.retrieve = async_to_raw_response_wrapper(
|
|
1179
1290
|
checkout_intents.retrieve,
|
|
1180
1291
|
)
|
|
1292
|
+
self.list = async_to_raw_response_wrapper(
|
|
1293
|
+
checkout_intents.list,
|
|
1294
|
+
)
|
|
1181
1295
|
self.add_payment = async_to_raw_response_wrapper(
|
|
1182
1296
|
checkout_intents.add_payment,
|
|
1183
1297
|
)
|
|
@@ -1208,6 +1322,9 @@ class CheckoutIntentsResourceWithStreamingResponse:
|
|
|
1208
1322
|
self.retrieve = to_streamed_response_wrapper(
|
|
1209
1323
|
checkout_intents.retrieve,
|
|
1210
1324
|
)
|
|
1325
|
+
self.list = to_streamed_response_wrapper(
|
|
1326
|
+
checkout_intents.list,
|
|
1327
|
+
)
|
|
1211
1328
|
self.add_payment = to_streamed_response_wrapper(
|
|
1212
1329
|
checkout_intents.add_payment,
|
|
1213
1330
|
)
|
|
@@ -1238,6 +1355,9 @@ class AsyncCheckoutIntentsResourceWithStreamingResponse:
|
|
|
1238
1355
|
self.retrieve = async_to_streamed_response_wrapper(
|
|
1239
1356
|
checkout_intents.retrieve,
|
|
1240
1357
|
)
|
|
1358
|
+
self.list = async_to_streamed_response_wrapper(
|
|
1359
|
+
checkout_intents.list,
|
|
1360
|
+
)
|
|
1241
1361
|
self.add_payment = async_to_streamed_response_wrapper(
|
|
1242
1362
|
checkout_intents.add_payment,
|
|
1243
1363
|
)
|
|
@@ -13,6 +13,7 @@ from .base_checkout_intent import BaseCheckoutIntent as BaseCheckoutIntent
|
|
|
13
13
|
from .payment_method_param import PaymentMethodParam as PaymentMethodParam
|
|
14
14
|
from .brand_retrieve_response import BrandRetrieveResponse as BrandRetrieveResponse
|
|
15
15
|
from .variant_selection_param import VariantSelectionParam as VariantSelectionParam
|
|
16
|
+
from .checkout_intent_list_params import CheckoutIntentListParams as CheckoutIntentListParams
|
|
16
17
|
from .checkout_intent_create_params import CheckoutIntentCreateParams as CheckoutIntentCreateParams
|
|
17
18
|
from .checkout_intent_confirm_params import CheckoutIntentConfirmParams as CheckoutIntentConfirmParams
|
|
18
19
|
from .checkout_intent_add_payment_params import CheckoutIntentAddPaymentParams as CheckoutIntentAddPaymentParams
|
|
@@ -30,6 +30,8 @@ class AwaitingConfirmationCheckoutIntent(BaseCheckoutIntent):
|
|
|
30
30
|
|
|
31
31
|
state: Literal["awaiting_confirmation"]
|
|
32
32
|
|
|
33
|
+
payment_method: Optional[PaymentMethod] = FieldInfo(alias="paymentMethod", default=None)
|
|
34
|
+
|
|
33
35
|
|
|
34
36
|
class PlacingOrderCheckoutIntent(BaseCheckoutIntent):
|
|
35
37
|
offer: Offer
|
|
@@ -42,6 +44,8 @@ class PlacingOrderCheckoutIntent(BaseCheckoutIntent):
|
|
|
42
44
|
class CompletedCheckoutIntent(BaseCheckoutIntent):
|
|
43
45
|
offer: Offer
|
|
44
46
|
|
|
47
|
+
order_id: Optional[str] = FieldInfo(alias="orderId", default=None)
|
|
48
|
+
|
|
45
49
|
payment_method: PaymentMethod = FieldInfo(alias="paymentMethod")
|
|
46
50
|
|
|
47
51
|
state: Literal["completed"]
|
|
@@ -58,6 +62,7 @@ class FailedCheckoutIntentFailureReason(BaseModel):
|
|
|
58
62
|
"developer_not_found",
|
|
59
63
|
"missing_shipping_method",
|
|
60
64
|
"unsupported_currency",
|
|
65
|
+
"invalid_input",
|
|
61
66
|
"unsupported_store_no_guest_checkout",
|
|
62
67
|
]
|
|
63
68
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import List
|
|
6
|
+
from typing_extensions import Literal, TypedDict
|
|
7
|
+
|
|
8
|
+
from .._types import SequenceNotStr
|
|
9
|
+
|
|
10
|
+
__all__ = ["CheckoutIntentListParams"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class CheckoutIntentListParams(TypedDict, total=False):
|
|
14
|
+
id: SequenceNotStr[str]
|
|
15
|
+
|
|
16
|
+
after: str
|
|
17
|
+
|
|
18
|
+
before: str
|
|
19
|
+
|
|
20
|
+
limit: float
|
|
21
|
+
|
|
22
|
+
state: List[Literal["retrieving_offer", "awaiting_confirmation", "placing_order", "completed", "failed"]]
|
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from typing import Dict, Union, Optional
|
|
4
|
+
from typing_extensions import Literal, TypeAlias
|
|
4
5
|
|
|
5
6
|
from pydantic import Field as FieldInfo
|
|
6
7
|
|
|
7
8
|
from .._models import BaseModel
|
|
8
9
|
|
|
9
|
-
__all__ = ["PaymentMethod"]
|
|
10
|
+
__all__ = ["PaymentMethod", "StripeTokenPaymentMethod", "BasisTheoryPaymentMethod", "NekudaPaymentMethod"]
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
class
|
|
13
|
+
class StripeTokenPaymentMethod(BaseModel):
|
|
13
14
|
stripe_token: str = FieldInfo(alias="stripeToken")
|
|
14
15
|
|
|
15
16
|
type: Literal["stripe_token"]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BasisTheoryPaymentMethod(BaseModel):
|
|
20
|
+
basis_theory_token: str = FieldInfo(alias="basisTheoryToken")
|
|
21
|
+
|
|
22
|
+
type: Literal["basis_theory_token"]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class NekudaPaymentMethod(BaseModel):
|
|
26
|
+
nekuda_user_id: str = FieldInfo(alias="nekudaUserId")
|
|
27
|
+
|
|
28
|
+
type: Literal["nekuda_token"]
|
|
29
|
+
|
|
30
|
+
nekuda_mandate_data: Optional[Dict[str, Union[str, float]]] = FieldInfo(alias="nekudaMandateData", default=None)
|
|
31
|
+
"""Construct a type with a set of properties K of type T"""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
PaymentMethod: TypeAlias = Union[StripeTokenPaymentMethod, BasisTheoryPaymentMethod, NekudaPaymentMethod]
|
|
@@ -2,14 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from
|
|
5
|
+
from typing import Dict, Union
|
|
6
|
+
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
|
|
6
7
|
|
|
7
8
|
from .._utils import PropertyInfo
|
|
8
9
|
|
|
9
|
-
__all__ = ["PaymentMethodParam"]
|
|
10
|
+
__all__ = ["PaymentMethodParam", "StripeTokenPaymentMethod", "BasisTheoryPaymentMethod", "NekudaPaymentMethod"]
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
class
|
|
13
|
+
class StripeTokenPaymentMethod(TypedDict, total=False):
|
|
13
14
|
stripe_token: Required[Annotated[str, PropertyInfo(alias="stripeToken")]]
|
|
14
15
|
|
|
15
16
|
type: Required[Literal["stripe_token"]]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BasisTheoryPaymentMethod(TypedDict, total=False):
|
|
20
|
+
basis_theory_token: Required[Annotated[str, PropertyInfo(alias="basisTheoryToken")]]
|
|
21
|
+
|
|
22
|
+
type: Required[Literal["basis_theory_token"]]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class NekudaPaymentMethod(TypedDict, total=False):
|
|
26
|
+
nekuda_user_id: Required[Annotated[str, PropertyInfo(alias="nekudaUserId")]]
|
|
27
|
+
|
|
28
|
+
type: Required[Literal["nekuda_token"]]
|
|
29
|
+
|
|
30
|
+
nekuda_mandate_data: Annotated[Dict[str, Union[str, float]], PropertyInfo(alias="nekudaMandateData")]
|
|
31
|
+
"""Construct a type with a set of properties K of type T"""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
PaymentMethodParam: TypeAlias = Union[StripeTokenPaymentMethod, BasisTheoryPaymentMethod, NekudaPaymentMethod]
|
|
@@ -9,13 +9,5 @@ __all__ = ["VariantSelection"]
|
|
|
9
9
|
|
|
10
10
|
class VariantSelection(BaseModel):
|
|
11
11
|
label: str
|
|
12
|
-
"""The label of the variant being selected.
|
|
13
|
-
|
|
14
|
-
Match this label with what is used on the product page.
|
|
15
|
-
"""
|
|
16
12
|
|
|
17
13
|
value: Union[str, float]
|
|
18
|
-
"""The value of the variant being selected.
|
|
19
|
-
|
|
20
|
-
Match this value with what is used on the product page.
|
|
21
|
-
"""
|
|
@@ -10,13 +10,5 @@ __all__ = ["VariantSelectionParam"]
|
|
|
10
10
|
|
|
11
11
|
class VariantSelectionParam(TypedDict, total=False):
|
|
12
12
|
label: Required[str]
|
|
13
|
-
"""The label of the variant being selected.
|
|
14
|
-
|
|
15
|
-
Match this label with what is used on the product page.
|
|
16
|
-
"""
|
|
17
13
|
|
|
18
14
|
value: Required[Union[str, float]]
|
|
19
|
-
"""The value of the variant being selected.
|
|
20
|
-
|
|
21
|
-
Match this value with what is used on the product page.
|
|
22
|
-
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: checkout-intents
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: The official Python library for the Checkout Intents API
|
|
5
5
|
Project-URL: Homepage, https://github.com/rye-com/checkout-intents-python
|
|
6
6
|
Project-URL: Repository, https://github.com/rye-com/checkout-intents-python
|
|
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
23
|
Classifier: Typing :: Typed
|
|
23
24
|
Requires-Python: >=3.9
|
|
@@ -59,9 +60,11 @@ pip install checkout-intents
|
|
|
59
60
|
The full API of this library can be found in [api.md](https://github.com/rye-com/checkout-intents-python/tree/main/api.md).
|
|
60
61
|
|
|
61
62
|
```python
|
|
63
|
+
import os
|
|
62
64
|
from checkout_intents import CheckoutIntents
|
|
63
65
|
|
|
64
66
|
client = CheckoutIntents(
|
|
67
|
+
api_key=os.environ.get("CHECKOUT_INTENTS_API_KEY"), # This is the default and can be omitted
|
|
65
68
|
# defaults to "staging".
|
|
66
69
|
environment="production",
|
|
67
70
|
)
|
|
@@ -74,7 +77,7 @@ checkout_intent = client.checkout_intents.create(
|
|
|
74
77
|
"email": "john.doe@example.com",
|
|
75
78
|
"first_name": "John",
|
|
76
79
|
"last_name": "Doe",
|
|
77
|
-
"phone": "
|
|
80
|
+
"phone": "1234567890",
|
|
78
81
|
"postal_code": "10001",
|
|
79
82
|
"province": "NY",
|
|
80
83
|
},
|
|
@@ -106,7 +109,7 @@ intent = client.checkout_intents.create_and_poll(
|
|
|
106
109
|
"email": "john.doe@example.com",
|
|
107
110
|
"first_name": "John",
|
|
108
111
|
"last_name": "Doe",
|
|
109
|
-
"phone": "
|
|
112
|
+
"phone": "1234567890",
|
|
110
113
|
"postal_code": "10001",
|
|
111
114
|
"province": "NY",
|
|
112
115
|
},
|
|
@@ -185,10 +188,12 @@ except PollTimeoutError as e:
|
|
|
185
188
|
Simply import `AsyncCheckoutIntents` instead of `CheckoutIntents` and use `await` with each API call:
|
|
186
189
|
|
|
187
190
|
```python
|
|
191
|
+
import os
|
|
188
192
|
import asyncio
|
|
189
193
|
from checkout_intents import AsyncCheckoutIntents
|
|
190
194
|
|
|
191
195
|
client = AsyncCheckoutIntents(
|
|
196
|
+
api_key=os.environ.get("CHECKOUT_INTENTS_API_KEY"), # This is the default and can be omitted
|
|
192
197
|
# defaults to "staging".
|
|
193
198
|
environment="production",
|
|
194
199
|
)
|
|
@@ -203,7 +208,7 @@ async def main() -> None:
|
|
|
203
208
|
"email": "john.doe@example.com",
|
|
204
209
|
"first_name": "John",
|
|
205
210
|
"last_name": "Doe",
|
|
206
|
-
"phone": "
|
|
211
|
+
"phone": "1234567890",
|
|
207
212
|
"postal_code": "10001",
|
|
208
213
|
"province": "NY",
|
|
209
214
|
},
|
|
@@ -238,6 +243,7 @@ from checkout_intents import AsyncCheckoutIntents
|
|
|
238
243
|
|
|
239
244
|
async def main() -> None:
|
|
240
245
|
async with AsyncCheckoutIntents(
|
|
246
|
+
api_key="My API Key",
|
|
241
247
|
http_client=DefaultAioHttpClient(),
|
|
242
248
|
) as client:
|
|
243
249
|
checkout_intent = await client.checkout_intents.create(
|
|
@@ -248,7 +254,7 @@ async def main() -> None:
|
|
|
248
254
|
"email": "john.doe@example.com",
|
|
249
255
|
"first_name": "John",
|
|
250
256
|
"last_name": "Doe",
|
|
251
|
-
"phone": "
|
|
257
|
+
"phone": "1234567890",
|
|
252
258
|
"postal_code": "10001",
|
|
253
259
|
"province": "NY",
|
|
254
260
|
},
|
|
@@ -269,6 +275,77 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
|
|
|
269
275
|
|
|
270
276
|
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
|
|
271
277
|
|
|
278
|
+
## Pagination
|
|
279
|
+
|
|
280
|
+
List methods in the Checkout Intents API are paginated.
|
|
281
|
+
|
|
282
|
+
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
|
|
283
|
+
|
|
284
|
+
```python
|
|
285
|
+
from checkout_intents import CheckoutIntents
|
|
286
|
+
|
|
287
|
+
client = CheckoutIntents()
|
|
288
|
+
|
|
289
|
+
all_checkout_intents = []
|
|
290
|
+
# Automatically fetches more pages as needed.
|
|
291
|
+
for checkout_intent in client.checkout_intents.list(
|
|
292
|
+
limit=20,
|
|
293
|
+
):
|
|
294
|
+
# Do something with checkout_intent here
|
|
295
|
+
all_checkout_intents.append(checkout_intent)
|
|
296
|
+
print(all_checkout_intents)
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Or, asynchronously:
|
|
300
|
+
|
|
301
|
+
```python
|
|
302
|
+
import asyncio
|
|
303
|
+
from checkout_intents import AsyncCheckoutIntents
|
|
304
|
+
|
|
305
|
+
client = AsyncCheckoutIntents()
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
async def main() -> None:
|
|
309
|
+
all_checkout_intents = []
|
|
310
|
+
# Iterate through items across all pages, issuing requests as needed.
|
|
311
|
+
async for checkout_intent in client.checkout_intents.list(
|
|
312
|
+
limit=20,
|
|
313
|
+
):
|
|
314
|
+
all_checkout_intents.append(checkout_intent)
|
|
315
|
+
print(all_checkout_intents)
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
asyncio.run(main())
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
|
|
322
|
+
|
|
323
|
+
```python
|
|
324
|
+
first_page = await client.checkout_intents.list(
|
|
325
|
+
limit=20,
|
|
326
|
+
)
|
|
327
|
+
if first_page.has_next_page():
|
|
328
|
+
print(f"will fetch next page using these details: {first_page.next_page_info()}")
|
|
329
|
+
next_page = await first_page.get_next_page()
|
|
330
|
+
print(f"number of items we just fetched: {len(next_page.data)}")
|
|
331
|
+
|
|
332
|
+
# Remove `await` for non-async usage.
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Or just work directly with the returned data:
|
|
336
|
+
|
|
337
|
+
```python
|
|
338
|
+
first_page = await client.checkout_intents.list(
|
|
339
|
+
limit=20,
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
print(f"next page cursor: {first_page.page_info.end_cursor}") # => "next page cursor: ..."
|
|
343
|
+
for checkout_intent in first_page.data:
|
|
344
|
+
print(checkout_intent)
|
|
345
|
+
|
|
346
|
+
# Remove `await` for non-async usage.
|
|
347
|
+
```
|
|
348
|
+
|
|
272
349
|
## Nested params
|
|
273
350
|
|
|
274
351
|
Nested parameters are dictionaries, typed using `TypedDict`, for example:
|
|
@@ -286,12 +363,12 @@ checkout_intent = client.checkout_intents.create(
|
|
|
286
363
|
"email": "john.doe@example.com",
|
|
287
364
|
"first_name": "John",
|
|
288
365
|
"last_name": "Doe",
|
|
289
|
-
"phone": "
|
|
366
|
+
"phone": "1234567890",
|
|
290
367
|
"postal_code": "10001",
|
|
291
368
|
"province": "NY",
|
|
292
369
|
},
|
|
293
370
|
product_url="productUrl",
|
|
294
|
-
quantity=
|
|
371
|
+
quantity=1,
|
|
295
372
|
)
|
|
296
373
|
print(checkout_intent.buyer)
|
|
297
374
|
```
|
|
@@ -320,7 +397,7 @@ try:
|
|
|
320
397
|
"email": "john.doe@example.com",
|
|
321
398
|
"first_name": "John",
|
|
322
399
|
"last_name": "Doe",
|
|
323
|
-
"phone": "
|
|
400
|
+
"phone": "1234567890",
|
|
324
401
|
"postal_code": "10001",
|
|
325
402
|
"province": "NY",
|
|
326
403
|
},
|
|
@@ -397,7 +474,7 @@ client.with_options(max_retries=5).checkout_intents.create(
|
|
|
397
474
|
"email": "john.doe@example.com",
|
|
398
475
|
"first_name": "John",
|
|
399
476
|
"last_name": "Doe",
|
|
400
|
-
"phone": "
|
|
477
|
+
"phone": "1234567890",
|
|
401
478
|
"postal_code": "10001",
|
|
402
479
|
"province": "NY",
|
|
403
480
|
},
|
|
@@ -434,7 +511,7 @@ client.with_options(timeout=5.0).checkout_intents.create(
|
|
|
434
511
|
"email": "john.doe@example.com",
|
|
435
512
|
"first_name": "John",
|
|
436
513
|
"last_name": "Doe",
|
|
437
|
-
"phone": "
|
|
514
|
+
"phone": "1234567890",
|
|
438
515
|
"postal_code": "10001",
|
|
439
516
|
"province": "NY",
|
|
440
517
|
},
|
|
@@ -489,7 +566,7 @@ response = client.checkout_intents.with_raw_response.create(
|
|
|
489
566
|
"email": "john.doe@example.com",
|
|
490
567
|
"first_name": "John",
|
|
491
568
|
"last_name": "Doe",
|
|
492
|
-
"phone": "
|
|
569
|
+
"phone": "1234567890",
|
|
493
570
|
"postal_code": "10001",
|
|
494
571
|
"province": "NY",
|
|
495
572
|
},
|
|
@@ -521,7 +598,7 @@ with client.checkout_intents.with_streaming_response.create(
|
|
|
521
598
|
"email": "john.doe@example.com",
|
|
522
599
|
"first_name": "John",
|
|
523
600
|
"last_name": "Doe",
|
|
524
|
-
"phone": "
|
|
601
|
+
"phone": "1234567890",
|
|
525
602
|
"postal_code": "10001",
|
|
526
603
|
"province": "NY",
|
|
527
604
|
},
|
|
@@ -11,7 +11,8 @@ checkout_intents/_resource.py,sha256=X-eWffEBAgzTZvakLqNUjwgidMKfBFRmCeeOiuko4lg
|
|
|
11
11
|
checkout_intents/_response.py,sha256=sLqxWBxzmVqPsdr2x5z6d87h8jb1U-Huvh2YFg-U6nE,28876
|
|
12
12
|
checkout_intents/_streaming.py,sha256=XOY20ljJEmOSf-nT8_KvPZipmgllR5sO400ePyMVLIY,10185
|
|
13
13
|
checkout_intents/_types.py,sha256=4l2pVH65co-2pua9stzq-WV2VcGg9Hl4nRHd0lz5cko,7246
|
|
14
|
-
checkout_intents/_version.py,sha256=
|
|
14
|
+
checkout_intents/_version.py,sha256=GGGuPk3OpdTlt_j2eo1Fr3Aqy8nvF8glUnxNJQWdHEQ,168
|
|
15
|
+
checkout_intents/pagination.py,sha256=VMe3ftq-qqAku2ERRTOz7iZOoMQ_KKp2HIUl_I8oAXE,2908
|
|
15
16
|
checkout_intents/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
17
|
checkout_intents/_utils/__init__.py,sha256=7fch0GT9zpNnErbciSpUNa-SjTxxjY6kxHxKMOM4AGs,2305
|
|
17
18
|
checkout_intents/_utils/_compat.py,sha256=rN17SSvjMoQE1GmKFTLniRuG1sKj2WAD5VjdLPeRlF0,1231
|
|
@@ -27,24 +28,25 @@ checkout_intents/_utils/_typing.py,sha256=N_5PPuFNsaygbtA_npZd98SVN1LQQvFTKL6bkW
|
|
|
27
28
|
checkout_intents/_utils/_utils.py,sha256=g9ftElB09kVT6EVfCIlD_nUfANhDX5_vZO61FDWoIQI,12334
|
|
28
29
|
checkout_intents/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
|
|
29
30
|
checkout_intents/resources/__init__.py,sha256=sHRW0nwo1GnFBFPoTNohkEbvOk7au-R3MdfVn_yb8Ds,1120
|
|
30
|
-
checkout_intents/resources/brands.py,sha256=
|
|
31
|
-
checkout_intents/resources/checkout_intents.py,sha256=
|
|
32
|
-
checkout_intents/types/__init__.py,sha256=
|
|
31
|
+
checkout_intents/resources/brands.py,sha256=jJ5Jn2GG3MPkdKSg6_OG89dSQTaSGM9e7lBtovn-ABE,6389
|
|
32
|
+
checkout_intents/resources/checkout_intents.py,sha256=C59jKLf-FxbtNfuSSxxCtp6Ona7hP4S26kV342xAlic,54375
|
|
33
|
+
checkout_intents/types/__init__.py,sha256=bcfwLNTB5CbPquNwxpMRoJkL5LM6HckISeGRPlVX2js,1192
|
|
33
34
|
checkout_intents/types/base_checkout_intent.py,sha256=56Qp3ssWYmcdu6A9Z0pvL3ewm1LTvQHiboiJ7Aogx2M,644
|
|
34
35
|
checkout_intents/types/brand_retrieve_response.py,sha256=1Z7yjrXl3NO1u9NFO5lDBJ-sucpEH501MUfUS_XeqbY,550
|
|
35
36
|
checkout_intents/types/buyer.py,sha256=Ov6mVD-Hjm9A-i9p2dWCXtniLhYpG_6jvy9DReC54YQ,530
|
|
36
37
|
checkout_intents/types/buyer_param.py,sha256=DAtEoK4VSzv2qDBBlC4RRE4FbHd87pieTOlfRntbjqg,695
|
|
37
|
-
checkout_intents/types/checkout_intent.py,sha256=
|
|
38
|
+
checkout_intents/types/checkout_intent.py,sha256=Vkn0Q3fXr5a776luw06mjl6AkL8geBOdpIVTIvO7Quk,2315
|
|
38
39
|
checkout_intents/types/checkout_intent_add_payment_params.py,sha256=s8KKWVM3XainGTLCwdfUjb5vgS80o2_W0wwUwRCFbk0,479
|
|
39
40
|
checkout_intents/types/checkout_intent_confirm_params.py,sha256=v_fcmuH5GoEwUJLbV7N9BDti63dg8z1nmhpcr4-1qcs,473
|
|
40
41
|
checkout_intents/types/checkout_intent_create_params.py,sha256=nQ5l74ABrn7t-nE7Hnw50hQ8VKyvu54LYia2hnp1twE,693
|
|
42
|
+
checkout_intents/types/checkout_intent_list_params.py,sha256=zc8_xwBHChOcl7bTMSjU7ZbHKIyQGYeUy5UrxeloJj0,521
|
|
41
43
|
checkout_intents/types/money.py,sha256=-AfFFrfnUy6cAaFykF_gWZQxDGlzA1r_dJzJZRxhUto,328
|
|
42
44
|
checkout_intents/types/offer.py,sha256=pxem4nhE9pMd-o9sfKipPuxyZg5WWur1w46oBfwHpB8,809
|
|
43
|
-
checkout_intents/types/payment_method.py,sha256
|
|
44
|
-
checkout_intents/types/payment_method_param.py,sha256=
|
|
45
|
-
checkout_intents/types/variant_selection.py,sha256=
|
|
46
|
-
checkout_intents/types/variant_selection_param.py,sha256=
|
|
47
|
-
checkout_intents-0.
|
|
48
|
-
checkout_intents-0.
|
|
49
|
-
checkout_intents-0.
|
|
50
|
-
checkout_intents-0.
|
|
45
|
+
checkout_intents/types/payment_method.py,sha256=-v5-L5RPojm8IDrdAhIMGmhVb89vwqT1jhgb-ZWOG7Q,1069
|
|
46
|
+
checkout_intents/types/payment_method_param.py,sha256=_yzwZ5nw7bStK4U2-1ybtpjdJz5funCOMN7MALtF0xk,1225
|
|
47
|
+
checkout_intents/types/variant_selection.py,sha256=y6mlU-qGwDfE77mU-x1GTXkDsmn6vuPpy5lBYXqXCBw,259
|
|
48
|
+
checkout_intents/types/variant_selection_param.py,sha256=ahwTmDVIUMV8jvpggEo2jDUTIm9xvXbntDxmIZqT2_k,355
|
|
49
|
+
checkout_intents-0.3.1.dist-info/METADATA,sha256=2wIoYlT0XK4ECPzUw9-GFUOl0fdgEAiH0IkUoQaW6l8,23677
|
|
50
|
+
checkout_intents-0.3.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
51
|
+
checkout_intents-0.3.1.dist-info/licenses/LICENSE,sha256=dRDmL6lFnLaphTaman8kAc21qY1IQ_qsAETk1F-b6jY,1056
|
|
52
|
+
checkout_intents-0.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|