checkout-intents 0.2.0__tar.gz → 0.3.1__tar.gz
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-0.3.1/.release-please-manifest.json +3 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/CHANGELOG.md +26 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/PKG-INFO +89 -12
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/README.md +87 -11
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/api.md +1 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/pyproject.toml +2 -1
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_version.py +1 -1
- checkout_intents-0.3.1/src/checkout_intents/pagination.py +89 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/resources/brands.py +4 -4
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/resources/checkout_intents.py +128 -8
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/__init__.py +1 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/checkout_intent.py +5 -0
- checkout_intents-0.3.1/src/checkout_intents/types/checkout_intent_list_params.py +22 -0
- checkout_intents-0.3.1/src/checkout_intents/types/payment_method.py +34 -0
- checkout_intents-0.3.1/src/checkout_intents/types/payment_method_param.py +34 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/variant_selection.py +0 -8
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/variant_selection_param.py +0 -8
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/api_resources/test_checkout_intents.py +145 -16
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_client.py +20 -20
- checkout_intents-0.2.0/.release-please-manifest.json +0 -3
- checkout_intents-0.2.0/src/checkout_intents/types/payment_method.py +0 -15
- checkout_intents-0.2.0/src/checkout_intents/types/payment_method_param.py +0 -15
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/.gitignore +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/CONTRIBUTING.md +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/LICENSE +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/SECURITY.md +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/bin/check-release-environment +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/bin/publish-pypi +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/examples/.keep +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/examples/complete-checkout-intent.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/examples/error-handling.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/noxfile.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/release-please-config.json +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/requirements-dev.lock +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/requirements.lock +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/__init__.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_base_client.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_client.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_compat.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_constants.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_exceptions.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_files.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_models.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_qs.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_resource.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_response.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_streaming.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_types.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_utils/__init__.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_utils/_compat.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_utils/_datetime_parse.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_utils/_logs.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_utils/_proxy.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_utils/_reflection.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_utils/_resources_proxy.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_utils/_streams.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_utils/_sync.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_utils/_transform.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_utils/_typing.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/_utils/_utils.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/lib/.keep +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/py.typed +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/resources/__init__.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/base_checkout_intent.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/brand_retrieve_response.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/buyer.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/buyer_param.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/checkout_intent_add_payment_params.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/checkout_intent_confirm_params.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/checkout_intent_create_params.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/money.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/src/checkout_intents/types/offer.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/__init__.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/api_resources/__init__.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/api_resources/test_brands.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/conftest.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/sample_file.txt +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_deepcopy.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_environment_inference.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_extract_files.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_files.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_models.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_polling.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_qs.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_required_args.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_response.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_streaming.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_transform.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_utils/test_datetime_parse.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_utils/test_proxy.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/test_utils/test_typing.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/tests/utils.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.1}/uv.lock +0 -0
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.1 (2025-11-22)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.3.0...v0.3.1](https://github.com/rye-com/checkout-intents-python/compare/v0.3.0...v0.3.1)
|
|
6
|
+
|
|
7
|
+
### Chores
|
|
8
|
+
|
|
9
|
+
* add Python 3.14 classifier and testing ([c5e5f48](https://github.com/rye-com/checkout-intents-python/commit/c5e5f4878211b638fad6db325ee1ea2971571c1e))
|
|
10
|
+
|
|
11
|
+
## 0.3.0 (2025-11-18)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v0.2.0...v0.3.0](https://github.com/rye-com/checkout-intents-python/compare/v0.2.0...v0.3.0)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* Add python sdk target to stainless config ([eea256f](https://github.com/rye-com/checkout-intents-python/commit/eea256fef46bb35554488dba5a0818345096a66a))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **docs:** supply valid buyer details ([12d25b1](https://github.com/rye-com/checkout-intents-python/commit/12d25b12808a05aaedcf48fc97384b5da40ca7e4))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Chores
|
|
26
|
+
|
|
27
|
+
* **internal:** format code ([445dea0](https://github.com/rye-com/checkout-intents-python/commit/445dea070ddcc8574d0304001e79bd25ca2f9de7))
|
|
28
|
+
|
|
3
29
|
## 0.2.0 (2025-11-13)
|
|
4
30
|
|
|
5
31
|
Full Changelog: [v0.1.0...v0.2.0](https://github.com/rye-com/checkout-intents-python/compare/v0.1.0...v0.2.0)
|
|
@@ -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
|
},
|
|
@@ -25,9 +25,11 @@ pip install checkout-intents
|
|
|
25
25
|
The full API of this library can be found in [api.md](api.md).
|
|
26
26
|
|
|
27
27
|
```python
|
|
28
|
+
import os
|
|
28
29
|
from checkout_intents import CheckoutIntents
|
|
29
30
|
|
|
30
31
|
client = CheckoutIntents(
|
|
32
|
+
api_key=os.environ.get("CHECKOUT_INTENTS_API_KEY"), # This is the default and can be omitted
|
|
31
33
|
# defaults to "staging".
|
|
32
34
|
environment="production",
|
|
33
35
|
)
|
|
@@ -40,7 +42,7 @@ checkout_intent = client.checkout_intents.create(
|
|
|
40
42
|
"email": "john.doe@example.com",
|
|
41
43
|
"first_name": "John",
|
|
42
44
|
"last_name": "Doe",
|
|
43
|
-
"phone": "
|
|
45
|
+
"phone": "1234567890",
|
|
44
46
|
"postal_code": "10001",
|
|
45
47
|
"province": "NY",
|
|
46
48
|
},
|
|
@@ -72,7 +74,7 @@ intent = client.checkout_intents.create_and_poll(
|
|
|
72
74
|
"email": "john.doe@example.com",
|
|
73
75
|
"first_name": "John",
|
|
74
76
|
"last_name": "Doe",
|
|
75
|
-
"phone": "
|
|
77
|
+
"phone": "1234567890",
|
|
76
78
|
"postal_code": "10001",
|
|
77
79
|
"province": "NY",
|
|
78
80
|
},
|
|
@@ -151,10 +153,12 @@ except PollTimeoutError as e:
|
|
|
151
153
|
Simply import `AsyncCheckoutIntents` instead of `CheckoutIntents` and use `await` with each API call:
|
|
152
154
|
|
|
153
155
|
```python
|
|
156
|
+
import os
|
|
154
157
|
import asyncio
|
|
155
158
|
from checkout_intents import AsyncCheckoutIntents
|
|
156
159
|
|
|
157
160
|
client = AsyncCheckoutIntents(
|
|
161
|
+
api_key=os.environ.get("CHECKOUT_INTENTS_API_KEY"), # This is the default and can be omitted
|
|
158
162
|
# defaults to "staging".
|
|
159
163
|
environment="production",
|
|
160
164
|
)
|
|
@@ -169,7 +173,7 @@ async def main() -> None:
|
|
|
169
173
|
"email": "john.doe@example.com",
|
|
170
174
|
"first_name": "John",
|
|
171
175
|
"last_name": "Doe",
|
|
172
|
-
"phone": "
|
|
176
|
+
"phone": "1234567890",
|
|
173
177
|
"postal_code": "10001",
|
|
174
178
|
"province": "NY",
|
|
175
179
|
},
|
|
@@ -204,6 +208,7 @@ from checkout_intents import AsyncCheckoutIntents
|
|
|
204
208
|
|
|
205
209
|
async def main() -> None:
|
|
206
210
|
async with AsyncCheckoutIntents(
|
|
211
|
+
api_key="My API Key",
|
|
207
212
|
http_client=DefaultAioHttpClient(),
|
|
208
213
|
) as client:
|
|
209
214
|
checkout_intent = await client.checkout_intents.create(
|
|
@@ -214,7 +219,7 @@ async def main() -> None:
|
|
|
214
219
|
"email": "john.doe@example.com",
|
|
215
220
|
"first_name": "John",
|
|
216
221
|
"last_name": "Doe",
|
|
217
|
-
"phone": "
|
|
222
|
+
"phone": "1234567890",
|
|
218
223
|
"postal_code": "10001",
|
|
219
224
|
"province": "NY",
|
|
220
225
|
},
|
|
@@ -235,6 +240,77 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
|
|
|
235
240
|
|
|
236
241
|
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`.
|
|
237
242
|
|
|
243
|
+
## Pagination
|
|
244
|
+
|
|
245
|
+
List methods in the Checkout Intents API are paginated.
|
|
246
|
+
|
|
247
|
+
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
from checkout_intents import CheckoutIntents
|
|
251
|
+
|
|
252
|
+
client = CheckoutIntents()
|
|
253
|
+
|
|
254
|
+
all_checkout_intents = []
|
|
255
|
+
# Automatically fetches more pages as needed.
|
|
256
|
+
for checkout_intent in client.checkout_intents.list(
|
|
257
|
+
limit=20,
|
|
258
|
+
):
|
|
259
|
+
# Do something with checkout_intent here
|
|
260
|
+
all_checkout_intents.append(checkout_intent)
|
|
261
|
+
print(all_checkout_intents)
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Or, asynchronously:
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
import asyncio
|
|
268
|
+
from checkout_intents import AsyncCheckoutIntents
|
|
269
|
+
|
|
270
|
+
client = AsyncCheckoutIntents()
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
async def main() -> None:
|
|
274
|
+
all_checkout_intents = []
|
|
275
|
+
# Iterate through items across all pages, issuing requests as needed.
|
|
276
|
+
async for checkout_intent in client.checkout_intents.list(
|
|
277
|
+
limit=20,
|
|
278
|
+
):
|
|
279
|
+
all_checkout_intents.append(checkout_intent)
|
|
280
|
+
print(all_checkout_intents)
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
asyncio.run(main())
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
first_page = await client.checkout_intents.list(
|
|
290
|
+
limit=20,
|
|
291
|
+
)
|
|
292
|
+
if first_page.has_next_page():
|
|
293
|
+
print(f"will fetch next page using these details: {first_page.next_page_info()}")
|
|
294
|
+
next_page = await first_page.get_next_page()
|
|
295
|
+
print(f"number of items we just fetched: {len(next_page.data)}")
|
|
296
|
+
|
|
297
|
+
# Remove `await` for non-async usage.
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Or just work directly with the returned data:
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
first_page = await client.checkout_intents.list(
|
|
304
|
+
limit=20,
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
print(f"next page cursor: {first_page.page_info.end_cursor}") # => "next page cursor: ..."
|
|
308
|
+
for checkout_intent in first_page.data:
|
|
309
|
+
print(checkout_intent)
|
|
310
|
+
|
|
311
|
+
# Remove `await` for non-async usage.
|
|
312
|
+
```
|
|
313
|
+
|
|
238
314
|
## Nested params
|
|
239
315
|
|
|
240
316
|
Nested parameters are dictionaries, typed using `TypedDict`, for example:
|
|
@@ -252,12 +328,12 @@ checkout_intent = client.checkout_intents.create(
|
|
|
252
328
|
"email": "john.doe@example.com",
|
|
253
329
|
"first_name": "John",
|
|
254
330
|
"last_name": "Doe",
|
|
255
|
-
"phone": "
|
|
331
|
+
"phone": "1234567890",
|
|
256
332
|
"postal_code": "10001",
|
|
257
333
|
"province": "NY",
|
|
258
334
|
},
|
|
259
335
|
product_url="productUrl",
|
|
260
|
-
quantity=
|
|
336
|
+
quantity=1,
|
|
261
337
|
)
|
|
262
338
|
print(checkout_intent.buyer)
|
|
263
339
|
```
|
|
@@ -286,7 +362,7 @@ try:
|
|
|
286
362
|
"email": "john.doe@example.com",
|
|
287
363
|
"first_name": "John",
|
|
288
364
|
"last_name": "Doe",
|
|
289
|
-
"phone": "
|
|
365
|
+
"phone": "1234567890",
|
|
290
366
|
"postal_code": "10001",
|
|
291
367
|
"province": "NY",
|
|
292
368
|
},
|
|
@@ -363,7 +439,7 @@ client.with_options(max_retries=5).checkout_intents.create(
|
|
|
363
439
|
"email": "john.doe@example.com",
|
|
364
440
|
"first_name": "John",
|
|
365
441
|
"last_name": "Doe",
|
|
366
|
-
"phone": "
|
|
442
|
+
"phone": "1234567890",
|
|
367
443
|
"postal_code": "10001",
|
|
368
444
|
"province": "NY",
|
|
369
445
|
},
|
|
@@ -400,7 +476,7 @@ client.with_options(timeout=5.0).checkout_intents.create(
|
|
|
400
476
|
"email": "john.doe@example.com",
|
|
401
477
|
"first_name": "John",
|
|
402
478
|
"last_name": "Doe",
|
|
403
|
-
"phone": "
|
|
479
|
+
"phone": "1234567890",
|
|
404
480
|
"postal_code": "10001",
|
|
405
481
|
"province": "NY",
|
|
406
482
|
},
|
|
@@ -455,7 +531,7 @@ response = client.checkout_intents.with_raw_response.create(
|
|
|
455
531
|
"email": "john.doe@example.com",
|
|
456
532
|
"first_name": "John",
|
|
457
533
|
"last_name": "Doe",
|
|
458
|
-
"phone": "
|
|
534
|
+
"phone": "1234567890",
|
|
459
535
|
"postal_code": "10001",
|
|
460
536
|
"province": "NY",
|
|
461
537
|
},
|
|
@@ -487,7 +563,7 @@ with client.checkout_intents.with_streaming_response.create(
|
|
|
487
563
|
"email": "john.doe@example.com",
|
|
488
564
|
"first_name": "John",
|
|
489
565
|
"last_name": "Doe",
|
|
490
|
-
"phone": "
|
|
566
|
+
"phone": "1234567890",
|
|
491
567
|
"postal_code": "10001",
|
|
492
568
|
"province": "NY",
|
|
493
569
|
},
|
|
@@ -18,6 +18,7 @@ Methods:
|
|
|
18
18
|
|
|
19
19
|
- <code title="post /api/v1/checkout-intents">client.checkout_intents.<a href="./src/checkout_intents/resources/checkout_intents.py">create</a>(\*\*<a href="src/checkout_intents/types/checkout_intent_create_params.py">params</a>) -> <a href="./src/checkout_intents/types/checkout_intent.py">CheckoutIntent</a></code>
|
|
20
20
|
- <code title="get /api/v1/checkout-intents/{id}">client.checkout_intents.<a href="./src/checkout_intents/resources/checkout_intents.py">retrieve</a>(id) -> <a href="./src/checkout_intents/types/checkout_intent.py">CheckoutIntent</a></code>
|
|
21
|
+
- <code title="get /api/v1/checkout-intents">client.checkout_intents.<a href="./src/checkout_intents/resources/checkout_intents.py">list</a>(\*\*<a href="src/checkout_intents/types/checkout_intent_list_params.py">params</a>) -> <a href="./src/checkout_intents/types/checkout_intent.py">SyncCursorPagination[CheckoutIntent]</a></code>
|
|
21
22
|
- <code title="post /api/v1/checkout-intents/{id}/payment">client.checkout_intents.<a href="./src/checkout_intents/resources/checkout_intents.py">add_payment</a>(id, \*\*<a href="src/checkout_intents/types/checkout_intent_add_payment_params.py">params</a>) -> <a href="./src/checkout_intents/types/checkout_intent.py">CheckoutIntent</a></code>
|
|
22
23
|
- <code title="post /api/v1/checkout-intents/{id}/confirm">client.checkout_intents.<a href="./src/checkout_intents/resources/checkout_intents.py">confirm</a>(id, \*\*<a href="src/checkout_intents/types/checkout_intent_confirm_params.py">params</a>) -> <a href="./src/checkout_intents/types/checkout_intent.py">CheckoutIntent</a></code>
|
|
23
24
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "checkout-intents"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.1"
|
|
4
4
|
description = "The official Python library for the Checkout Intents API"
|
|
5
5
|
dynamic = ["readme"]
|
|
6
6
|
license = "MIT"
|
|
@@ -24,6 +24,7 @@ classifiers = [
|
|
|
24
24
|
"Programming Language :: Python :: 3.11",
|
|
25
25
|
"Programming Language :: Python :: 3.12",
|
|
26
26
|
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Programming Language :: Python :: 3.14",
|
|
27
28
|
"Operating System :: OS Independent",
|
|
28
29
|
"Operating System :: POSIX",
|
|
29
30
|
"Operating System :: MacOS",
|
|
@@ -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.
|