checkout-intents 0.2.0__tar.gz → 0.3.0__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.0/.release-please-manifest.json +3 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/CHANGELOG.md +18 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/PKG-INFO +88 -12
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/README.md +87 -11
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/api.md +1 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/pyproject.toml +1 -1
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_version.py +1 -1
- checkout_intents-0.3.0/src/checkout_intents/pagination.py +89 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/resources/brands.py +4 -4
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/resources/checkout_intents.py +128 -8
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/__init__.py +1 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/checkout_intent.py +5 -0
- checkout_intents-0.3.0/src/checkout_intents/types/checkout_intent_list_params.py +22 -0
- checkout_intents-0.3.0/src/checkout_intents/types/payment_method.py +34 -0
- checkout_intents-0.3.0/src/checkout_intents/types/payment_method_param.py +34 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/variant_selection.py +0 -8
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/variant_selection_param.py +0 -8
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/api_resources/test_checkout_intents.py +145 -16
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/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.0}/.gitignore +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/CONTRIBUTING.md +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/LICENSE +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/SECURITY.md +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/bin/check-release-environment +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/bin/publish-pypi +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/examples/.keep +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/examples/complete-checkout-intent.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/examples/error-handling.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/noxfile.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/release-please-config.json +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/requirements-dev.lock +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/requirements.lock +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/__init__.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_base_client.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_client.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_compat.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_constants.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_exceptions.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_files.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_models.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_qs.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_resource.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_response.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_streaming.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_types.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_utils/__init__.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_utils/_compat.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_utils/_datetime_parse.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_utils/_logs.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_utils/_proxy.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_utils/_reflection.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_utils/_resources_proxy.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_utils/_streams.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_utils/_sync.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_utils/_transform.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_utils/_typing.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/_utils/_utils.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/lib/.keep +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/py.typed +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/resources/__init__.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/base_checkout_intent.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/brand_retrieve_response.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/buyer.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/buyer_param.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/checkout_intent_add_payment_params.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/checkout_intent_confirm_params.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/checkout_intent_create_params.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/money.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/src/checkout_intents/types/offer.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/__init__.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/api_resources/__init__.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/api_resources/test_brands.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/conftest.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/sample_file.txt +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_deepcopy.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_environment_inference.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_extract_files.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_files.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_models.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_polling.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_qs.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_required_args.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_response.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_streaming.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_transform.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_utils/test_datetime_parse.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_utils/test_proxy.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/test_utils/test_typing.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/tests/utils.py +0 -0
- {checkout_intents-0.2.0 → checkout_intents-0.3.0}/uv.lock +0 -0
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 (2025-11-18)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.2.0...v0.3.0](https://github.com/rye-com/checkout-intents-python/compare/v0.2.0...v0.3.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* Add python sdk target to stainless config ([eea256f](https://github.com/rye-com/checkout-intents-python/commit/eea256fef46bb35554488dba5a0818345096a66a))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **docs:** supply valid buyer details ([12d25b1](https://github.com/rye-com/checkout-intents-python/commit/12d25b12808a05aaedcf48fc97384b5da40ca7e4))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Chores
|
|
18
|
+
|
|
19
|
+
* **internal:** format code ([445dea0](https://github.com/rye-com/checkout-intents-python/commit/445dea070ddcc8574d0304001e79bd25ca2f9de7))
|
|
20
|
+
|
|
3
21
|
## 0.2.0 (2025-11-13)
|
|
4
22
|
|
|
5
23
|
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.0
|
|
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
|
|
@@ -59,9 +59,11 @@ pip install checkout-intents
|
|
|
59
59
|
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
60
|
|
|
61
61
|
```python
|
|
62
|
+
import os
|
|
62
63
|
from checkout_intents import CheckoutIntents
|
|
63
64
|
|
|
64
65
|
client = CheckoutIntents(
|
|
66
|
+
api_key=os.environ.get("CHECKOUT_INTENTS_API_KEY"), # This is the default and can be omitted
|
|
65
67
|
# defaults to "staging".
|
|
66
68
|
environment="production",
|
|
67
69
|
)
|
|
@@ -74,7 +76,7 @@ checkout_intent = client.checkout_intents.create(
|
|
|
74
76
|
"email": "john.doe@example.com",
|
|
75
77
|
"first_name": "John",
|
|
76
78
|
"last_name": "Doe",
|
|
77
|
-
"phone": "
|
|
79
|
+
"phone": "1234567890",
|
|
78
80
|
"postal_code": "10001",
|
|
79
81
|
"province": "NY",
|
|
80
82
|
},
|
|
@@ -106,7 +108,7 @@ intent = client.checkout_intents.create_and_poll(
|
|
|
106
108
|
"email": "john.doe@example.com",
|
|
107
109
|
"first_name": "John",
|
|
108
110
|
"last_name": "Doe",
|
|
109
|
-
"phone": "
|
|
111
|
+
"phone": "1234567890",
|
|
110
112
|
"postal_code": "10001",
|
|
111
113
|
"province": "NY",
|
|
112
114
|
},
|
|
@@ -185,10 +187,12 @@ except PollTimeoutError as e:
|
|
|
185
187
|
Simply import `AsyncCheckoutIntents` instead of `CheckoutIntents` and use `await` with each API call:
|
|
186
188
|
|
|
187
189
|
```python
|
|
190
|
+
import os
|
|
188
191
|
import asyncio
|
|
189
192
|
from checkout_intents import AsyncCheckoutIntents
|
|
190
193
|
|
|
191
194
|
client = AsyncCheckoutIntents(
|
|
195
|
+
api_key=os.environ.get("CHECKOUT_INTENTS_API_KEY"), # This is the default and can be omitted
|
|
192
196
|
# defaults to "staging".
|
|
193
197
|
environment="production",
|
|
194
198
|
)
|
|
@@ -203,7 +207,7 @@ async def main() -> None:
|
|
|
203
207
|
"email": "john.doe@example.com",
|
|
204
208
|
"first_name": "John",
|
|
205
209
|
"last_name": "Doe",
|
|
206
|
-
"phone": "
|
|
210
|
+
"phone": "1234567890",
|
|
207
211
|
"postal_code": "10001",
|
|
208
212
|
"province": "NY",
|
|
209
213
|
},
|
|
@@ -238,6 +242,7 @@ from checkout_intents import AsyncCheckoutIntents
|
|
|
238
242
|
|
|
239
243
|
async def main() -> None:
|
|
240
244
|
async with AsyncCheckoutIntents(
|
|
245
|
+
api_key="My API Key",
|
|
241
246
|
http_client=DefaultAioHttpClient(),
|
|
242
247
|
) as client:
|
|
243
248
|
checkout_intent = await client.checkout_intents.create(
|
|
@@ -248,7 +253,7 @@ async def main() -> None:
|
|
|
248
253
|
"email": "john.doe@example.com",
|
|
249
254
|
"first_name": "John",
|
|
250
255
|
"last_name": "Doe",
|
|
251
|
-
"phone": "
|
|
256
|
+
"phone": "1234567890",
|
|
252
257
|
"postal_code": "10001",
|
|
253
258
|
"province": "NY",
|
|
254
259
|
},
|
|
@@ -269,6 +274,77 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
|
|
|
269
274
|
|
|
270
275
|
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
276
|
|
|
277
|
+
## Pagination
|
|
278
|
+
|
|
279
|
+
List methods in the Checkout Intents API are paginated.
|
|
280
|
+
|
|
281
|
+
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
|
|
282
|
+
|
|
283
|
+
```python
|
|
284
|
+
from checkout_intents import CheckoutIntents
|
|
285
|
+
|
|
286
|
+
client = CheckoutIntents()
|
|
287
|
+
|
|
288
|
+
all_checkout_intents = []
|
|
289
|
+
# Automatically fetches more pages as needed.
|
|
290
|
+
for checkout_intent in client.checkout_intents.list(
|
|
291
|
+
limit=20,
|
|
292
|
+
):
|
|
293
|
+
# Do something with checkout_intent here
|
|
294
|
+
all_checkout_intents.append(checkout_intent)
|
|
295
|
+
print(all_checkout_intents)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Or, asynchronously:
|
|
299
|
+
|
|
300
|
+
```python
|
|
301
|
+
import asyncio
|
|
302
|
+
from checkout_intents import AsyncCheckoutIntents
|
|
303
|
+
|
|
304
|
+
client = AsyncCheckoutIntents()
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
async def main() -> None:
|
|
308
|
+
all_checkout_intents = []
|
|
309
|
+
# Iterate through items across all pages, issuing requests as needed.
|
|
310
|
+
async for checkout_intent in client.checkout_intents.list(
|
|
311
|
+
limit=20,
|
|
312
|
+
):
|
|
313
|
+
all_checkout_intents.append(checkout_intent)
|
|
314
|
+
print(all_checkout_intents)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
asyncio.run(main())
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
|
|
321
|
+
|
|
322
|
+
```python
|
|
323
|
+
first_page = await client.checkout_intents.list(
|
|
324
|
+
limit=20,
|
|
325
|
+
)
|
|
326
|
+
if first_page.has_next_page():
|
|
327
|
+
print(f"will fetch next page using these details: {first_page.next_page_info()}")
|
|
328
|
+
next_page = await first_page.get_next_page()
|
|
329
|
+
print(f"number of items we just fetched: {len(next_page.data)}")
|
|
330
|
+
|
|
331
|
+
# Remove `await` for non-async usage.
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Or just work directly with the returned data:
|
|
335
|
+
|
|
336
|
+
```python
|
|
337
|
+
first_page = await client.checkout_intents.list(
|
|
338
|
+
limit=20,
|
|
339
|
+
)
|
|
340
|
+
|
|
341
|
+
print(f"next page cursor: {first_page.page_info.end_cursor}") # => "next page cursor: ..."
|
|
342
|
+
for checkout_intent in first_page.data:
|
|
343
|
+
print(checkout_intent)
|
|
344
|
+
|
|
345
|
+
# Remove `await` for non-async usage.
|
|
346
|
+
```
|
|
347
|
+
|
|
272
348
|
## Nested params
|
|
273
349
|
|
|
274
350
|
Nested parameters are dictionaries, typed using `TypedDict`, for example:
|
|
@@ -286,12 +362,12 @@ checkout_intent = client.checkout_intents.create(
|
|
|
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
|
},
|
|
293
369
|
product_url="productUrl",
|
|
294
|
-
quantity=
|
|
370
|
+
quantity=1,
|
|
295
371
|
)
|
|
296
372
|
print(checkout_intent.buyer)
|
|
297
373
|
```
|
|
@@ -320,7 +396,7 @@ try:
|
|
|
320
396
|
"email": "john.doe@example.com",
|
|
321
397
|
"first_name": "John",
|
|
322
398
|
"last_name": "Doe",
|
|
323
|
-
"phone": "
|
|
399
|
+
"phone": "1234567890",
|
|
324
400
|
"postal_code": "10001",
|
|
325
401
|
"province": "NY",
|
|
326
402
|
},
|
|
@@ -397,7 +473,7 @@ client.with_options(max_retries=5).checkout_intents.create(
|
|
|
397
473
|
"email": "john.doe@example.com",
|
|
398
474
|
"first_name": "John",
|
|
399
475
|
"last_name": "Doe",
|
|
400
|
-
"phone": "
|
|
476
|
+
"phone": "1234567890",
|
|
401
477
|
"postal_code": "10001",
|
|
402
478
|
"province": "NY",
|
|
403
479
|
},
|
|
@@ -434,7 +510,7 @@ client.with_options(timeout=5.0).checkout_intents.create(
|
|
|
434
510
|
"email": "john.doe@example.com",
|
|
435
511
|
"first_name": "John",
|
|
436
512
|
"last_name": "Doe",
|
|
437
|
-
"phone": "
|
|
513
|
+
"phone": "1234567890",
|
|
438
514
|
"postal_code": "10001",
|
|
439
515
|
"province": "NY",
|
|
440
516
|
},
|
|
@@ -489,7 +565,7 @@ response = client.checkout_intents.with_raw_response.create(
|
|
|
489
565
|
"email": "john.doe@example.com",
|
|
490
566
|
"first_name": "John",
|
|
491
567
|
"last_name": "Doe",
|
|
492
|
-
"phone": "
|
|
568
|
+
"phone": "1234567890",
|
|
493
569
|
"postal_code": "10001",
|
|
494
570
|
"province": "NY",
|
|
495
571
|
},
|
|
@@ -521,7 +597,7 @@ with client.checkout_intents.with_streaming_response.create(
|
|
|
521
597
|
"email": "john.doe@example.com",
|
|
522
598
|
"first_name": "John",
|
|
523
599
|
"last_name": "Doe",
|
|
524
|
-
"phone": "
|
|
600
|
+
"phone": "1234567890",
|
|
525
601
|
"postal_code": "10001",
|
|
526
602
|
"province": "NY",
|
|
527
603
|
},
|
|
@@ -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
|
|
|
@@ -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.
|