checkout-intents 0.11.0__tar.gz → 0.13.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.
Files changed (108) hide show
  1. checkout_intents-0.13.0/.release-please-manifest.json +3 -0
  2. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/CHANGELOG.md +30 -0
  3. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/PKG-INFO +1 -1
  4. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/api.md +12 -0
  5. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/pyproject.toml +1 -1
  6. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_base_client.py +5 -2
  7. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_client.py +42 -1
  8. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_compat.py +3 -3
  9. checkout_intents-0.13.0/src/checkout_intents/_utils/_json.py +35 -0
  10. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_version.py +1 -1
  11. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/resources/__init__.py +14 -0
  12. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/resources/betas/checkout_sessions.py +16 -2
  13. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/resources/checkout_intents.py +64 -8
  14. checkout_intents-0.13.0/src/checkout_intents/resources/products.py +169 -0
  15. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/__init__.py +4 -0
  16. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/base_checkout_intent.py +11 -0
  17. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/betas/checkout_session_create_params.py +11 -1
  18. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/checkout_intent_create_params.py +11 -1
  19. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/checkout_intent_purchase_params.py +11 -1
  20. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/money.py +1 -1
  21. checkout_intents-0.13.0/src/checkout_intents/types/product.py +38 -0
  22. checkout_intents-0.13.0/src/checkout_intents/types/product_availability.py +7 -0
  23. checkout_intents-0.13.0/src/checkout_intents/types/product_image.py +13 -0
  24. checkout_intents-0.13.0/src/checkout_intents/types/product_lookup_params.py +11 -0
  25. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/api_resources/betas/test_checkout_sessions.py +2 -0
  26. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/api_resources/test_checkout_intents.py +4 -0
  27. checkout_intents-0.13.0/tests/api_resources/test_products.py +92 -0
  28. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_client.py +62 -0
  29. checkout_intents-0.13.0/tests/test_utils/test_json.py +126 -0
  30. checkout_intents-0.11.0/.release-please-manifest.json +0 -3
  31. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/.gitignore +0 -0
  32. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/CONTRIBUTING.md +0 -0
  33. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/LICENSE +0 -0
  34. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/README.md +0 -0
  35. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/SECURITY.md +0 -0
  36. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/bin/check-release-environment +0 -0
  37. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/bin/publish-pypi +0 -0
  38. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/examples/.keep +0 -0
  39. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/examples/complete-checkout-intent.py +0 -0
  40. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/examples/error-handling.py +0 -0
  41. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/noxfile.py +0 -0
  42. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/release-please-config.json +0 -0
  43. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/requirements-dev.lock +0 -0
  44. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/requirements.lock +0 -0
  45. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/__init__.py +0 -0
  46. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_constants.py +0 -0
  47. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_exceptions.py +0 -0
  48. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_files.py +0 -0
  49. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_models.py +0 -0
  50. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_qs.py +0 -0
  51. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_resource.py +0 -0
  52. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_response.py +0 -0
  53. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_streaming.py +0 -0
  54. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_types.py +0 -0
  55. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_utils/__init__.py +0 -0
  56. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_utils/_compat.py +0 -0
  57. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_utils/_datetime_parse.py +0 -0
  58. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_utils/_logs.py +0 -0
  59. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_utils/_proxy.py +0 -0
  60. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_utils/_reflection.py +0 -0
  61. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_utils/_resources_proxy.py +0 -0
  62. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_utils/_streams.py +0 -0
  63. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_utils/_sync.py +0 -0
  64. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_utils/_transform.py +0 -0
  65. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_utils/_typing.py +0 -0
  66. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/_utils/_utils.py +0 -0
  67. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/lib/.keep +0 -0
  68. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/pagination.py +0 -0
  69. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/py.typed +0 -0
  70. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/resources/betas/__init__.py +0 -0
  71. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/resources/betas/betas.py +0 -0
  72. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/resources/brands.py +0 -0
  73. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/betas/__init__.py +0 -0
  74. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/brand_retrieve_response.py +0 -0
  75. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/buyer.py +0 -0
  76. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/buyer_param.py +0 -0
  77. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/checkout_intent.py +0 -0
  78. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/checkout_intent_add_payment_params.py +0 -0
  79. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/checkout_intent_confirm_params.py +0 -0
  80. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/checkout_intent_list_params.py +0 -0
  81. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/checkout_session.py +0 -0
  82. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/offer.py +0 -0
  83. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/payment_method.py +0 -0
  84. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/payment_method_param.py +0 -0
  85. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/variant_selection.py +0 -0
  86. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/src/checkout_intents/types/variant_selection_param.py +0 -0
  87. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/__init__.py +0 -0
  88. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/api_resources/__init__.py +0 -0
  89. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/api_resources/betas/__init__.py +0 -0
  90. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/api_resources/test_brands.py +0 -0
  91. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/conftest.py +0 -0
  92. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/sample_file.txt +0 -0
  93. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_deepcopy.py +0 -0
  94. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_environment_inference.py +0 -0
  95. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_extract_files.py +0 -0
  96. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_files.py +0 -0
  97. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_models.py +0 -0
  98. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_polling.py +0 -0
  99. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_qs.py +0 -0
  100. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_required_args.py +0 -0
  101. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_response.py +0 -0
  102. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_streaming.py +0 -0
  103. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_transform.py +0 -0
  104. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_utils/test_datetime_parse.py +0 -0
  105. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_utils/test_proxy.py +0 -0
  106. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/test_utils/test_typing.py +0 -0
  107. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/tests/utils.py +0 -0
  108. {checkout_intents-0.11.0 → checkout_intents-0.13.0}/uv.lock +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.13.0"
3
+ }
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.0 (2026-01-30)
4
+
5
+ Full Changelog: [v0.12.0...v0.13.0](https://github.com/rye-com/checkout-intents-python/compare/v0.12.0...v0.13.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** introduce lookup product data endpoint ([a9083d2](https://github.com/rye-com/checkout-intents-python/commit/a9083d26b9f8648033a7f433e69936f5c6f1a3e9))
10
+ * **client:** add custom JSON encoder for extended type support ([06b80ca](https://github.com/rye-com/checkout-intents-python/commit/06b80ca98bd630f63245e62a96726a13b19084ed))
11
+ * Implement shipping profile -> shipping option calculation ([b4aca4a](https://github.com/rye-com/checkout-intents-python/commit/b4aca4a8504dc530e00b2cd9ebe0f2ca77647bbe))
12
+
13
+
14
+ ### Chores
15
+
16
+ * **internal:** rename `Product` type ([d9f34df](https://github.com/rye-com/checkout-intents-python/commit/d9f34dfc35d70140c380269a20e5214fca3bbb83))
17
+
18
+ ## 0.12.0 (2026-01-24)
19
+
20
+ Full Changelog: [v0.11.0...v0.12.0](https://github.com/rye-com/checkout-intents-python/compare/v0.11.0...v0.12.0)
21
+
22
+ ### Features
23
+
24
+ * add support for idempotency for v2 api ([b7a09af](https://github.com/rye-com/checkout-intents-python/commit/b7a09af76927e67befdbe59566bddf7ab43240f0))
25
+ * **api:** introduce offerRetrievalEffort constraint ([5bc7a2c](https://github.com/rye-com/checkout-intents-python/commit/5bc7a2cc58c555dd4dcd5c0e3abf1f157cd61e8f))
26
+
27
+
28
+ ### Chores
29
+
30
+ * **ci:** upgrade `actions/github-script` ([526d94a](https://github.com/rye-com/checkout-intents-python/commit/526d94ae385eb0e5f54124ca429651d55ce0ec53))
31
+ * **internal:** update `actions/checkout` version ([9eadb2e](https://github.com/rye-com/checkout-intents-python/commit/9eadb2e9a5a8abaad98be7567dd3dc195458cd53))
32
+
3
33
  ## 0.11.0 (2026-01-15)
4
34
 
5
35
  Full Changelog: [v0.10.0...v0.11.0](https://github.com/rye-com/checkout-intents-python/compare/v0.10.0...v0.11.0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: checkout-intents
3
- Version: 0.11.0
3
+ Version: 0.13.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
@@ -48,3 +48,15 @@ from checkout_intents.types import BrandRetrieveResponse
48
48
  Methods:
49
49
 
50
50
  - <code title="get /api/v1/brands/domain/{domain}">client.brands.<a href="./src/checkout_intents/resources/brands.py">retrieve</a>(domain) -> <a href="./src/checkout_intents/types/brand_retrieve_response.py">BrandRetrieveResponse</a></code>
51
+
52
+ # Products
53
+
54
+ Types:
55
+
56
+ ```python
57
+ from checkout_intents.types import Product, ProductAvailability, ProductImage
58
+ ```
59
+
60
+ Methods:
61
+
62
+ - <code title="get /api/v1/products/lookup">client.products.<a href="./src/checkout_intents/resources/products.py">lookup</a>(\*\*<a href="src/checkout_intents/types/product_lookup_params.py">params</a>) -> <a href="./src/checkout_intents/types/product.py">Product</a></code>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "checkout-intents"
3
- version = "0.11.0"
3
+ version = "0.13.0"
4
4
  description = "The official Python library for the Checkout Intents API"
5
5
  dynamic = ["readme"]
6
6
  license = "MIT"
@@ -86,6 +86,7 @@ from ._exceptions import (
86
86
  APIConnectionError,
87
87
  APIResponseValidationError,
88
88
  )
89
+ from ._utils._json import openapi_dumps
89
90
 
90
91
  log: logging.Logger = logging.getLogger(__name__)
91
92
 
@@ -554,8 +555,10 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
554
555
  kwargs["content"] = options.content
555
556
  elif isinstance(json_data, bytes):
556
557
  kwargs["content"] = json_data
557
- else:
558
- kwargs["json"] = json_data if is_given(json_data) else None
558
+ elif not files:
559
+ # Don't set content when JSON is sent as multipart/form-data,
560
+ # since httpx's content param overrides other body arguments
561
+ kwargs["content"] = openapi_dumps(json_data) if is_given(json_data) and json_data is not None else None
559
562
  kwargs["files"] = files
560
563
  else:
561
564
  headers.pop("Content-Type", None)
@@ -31,8 +31,9 @@ from ._base_client import (
31
31
  )
32
32
 
33
33
  if TYPE_CHECKING:
34
- from .resources import betas, brands, checkout_intents
34
+ from .resources import betas, brands, products, checkout_intents
35
35
  from .resources.brands import BrandsResource, AsyncBrandsResource
36
+ from .resources.products import ProductsResource, AsyncProductsResource
36
37
  from .resources.betas.betas import BetasResource, AsyncBetasResource
37
38
  from .resources.checkout_intents import CheckoutIntentsResource, AsyncCheckoutIntentsResource
38
39
 
@@ -167,6 +168,8 @@ class CheckoutIntents(SyncAPIClient):
167
168
  _strict_response_validation=_strict_response_validation,
168
169
  )
169
170
 
171
+ self._idempotency_header = "Idempotency-Key"
172
+
170
173
  @cached_property
171
174
  def checkout_intents(self) -> CheckoutIntentsResource:
172
175
  from .resources.checkout_intents import CheckoutIntentsResource
@@ -185,6 +188,12 @@ class CheckoutIntents(SyncAPIClient):
185
188
 
186
189
  return BrandsResource(self)
187
190
 
191
+ @cached_property
192
+ def products(self) -> ProductsResource:
193
+ from .resources.products import ProductsResource
194
+
195
+ return ProductsResource(self)
196
+
188
197
  @cached_property
189
198
  def with_raw_response(self) -> CheckoutIntentsWithRawResponse:
190
199
  return CheckoutIntentsWithRawResponse(self)
@@ -396,6 +405,8 @@ class AsyncCheckoutIntents(AsyncAPIClient):
396
405
  _strict_response_validation=_strict_response_validation,
397
406
  )
398
407
 
408
+ self._idempotency_header = "Idempotency-Key"
409
+
399
410
  @cached_property
400
411
  def checkout_intents(self) -> AsyncCheckoutIntentsResource:
401
412
  from .resources.checkout_intents import AsyncCheckoutIntentsResource
@@ -414,6 +425,12 @@ class AsyncCheckoutIntents(AsyncAPIClient):
414
425
 
415
426
  return AsyncBrandsResource(self)
416
427
 
428
+ @cached_property
429
+ def products(self) -> AsyncProductsResource:
430
+ from .resources.products import AsyncProductsResource
431
+
432
+ return AsyncProductsResource(self)
433
+
417
434
  @cached_property
418
435
  def with_raw_response(self) -> AsyncCheckoutIntentsWithRawResponse:
419
436
  return AsyncCheckoutIntentsWithRawResponse(self)
@@ -553,6 +570,12 @@ class CheckoutIntentsWithRawResponse:
553
570
 
554
571
  return BrandsResourceWithRawResponse(self._client.brands)
555
572
 
573
+ @cached_property
574
+ def products(self) -> products.ProductsResourceWithRawResponse:
575
+ from .resources.products import ProductsResourceWithRawResponse
576
+
577
+ return ProductsResourceWithRawResponse(self._client.products)
578
+
556
579
 
557
580
  class AsyncCheckoutIntentsWithRawResponse:
558
581
  _client: AsyncCheckoutIntents
@@ -578,6 +601,12 @@ class AsyncCheckoutIntentsWithRawResponse:
578
601
 
579
602
  return AsyncBrandsResourceWithRawResponse(self._client.brands)
580
603
 
604
+ @cached_property
605
+ def products(self) -> products.AsyncProductsResourceWithRawResponse:
606
+ from .resources.products import AsyncProductsResourceWithRawResponse
607
+
608
+ return AsyncProductsResourceWithRawResponse(self._client.products)
609
+
581
610
 
582
611
  class CheckoutIntentsWithStreamedResponse:
583
612
  _client: CheckoutIntents
@@ -603,6 +632,12 @@ class CheckoutIntentsWithStreamedResponse:
603
632
 
604
633
  return BrandsResourceWithStreamingResponse(self._client.brands)
605
634
 
635
+ @cached_property
636
+ def products(self) -> products.ProductsResourceWithStreamingResponse:
637
+ from .resources.products import ProductsResourceWithStreamingResponse
638
+
639
+ return ProductsResourceWithStreamingResponse(self._client.products)
640
+
606
641
 
607
642
  class AsyncCheckoutIntentsWithStreamedResponse:
608
643
  _client: AsyncCheckoutIntents
@@ -628,6 +663,12 @@ class AsyncCheckoutIntentsWithStreamedResponse:
628
663
 
629
664
  return AsyncBrandsResourceWithStreamingResponse(self._client.brands)
630
665
 
666
+ @cached_property
667
+ def products(self) -> products.AsyncProductsResourceWithStreamingResponse:
668
+ from .resources.products import AsyncProductsResourceWithStreamingResponse
669
+
670
+ return AsyncProductsResourceWithStreamingResponse(self._client.products)
671
+
631
672
 
632
673
  Client = CheckoutIntents
633
674
 
@@ -139,6 +139,7 @@ def model_dump(
139
139
  exclude_defaults: bool = False,
140
140
  warnings: bool = True,
141
141
  mode: Literal["json", "python"] = "python",
142
+ by_alias: bool | None = None,
142
143
  ) -> dict[str, Any]:
143
144
  if (not PYDANTIC_V1) or hasattr(model, "model_dump"):
144
145
  return model.model_dump(
@@ -148,13 +149,12 @@ def model_dump(
148
149
  exclude_defaults=exclude_defaults,
149
150
  # warnings are not supported in Pydantic v1
150
151
  warnings=True if PYDANTIC_V1 else warnings,
152
+ by_alias=by_alias,
151
153
  )
152
154
  return cast(
153
155
  "dict[str, Any]",
154
156
  model.dict( # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
155
- exclude=exclude,
156
- exclude_unset=exclude_unset,
157
- exclude_defaults=exclude_defaults,
157
+ exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, by_alias=bool(by_alias)
158
158
  ),
159
159
  )
160
160
 
@@ -0,0 +1,35 @@
1
+ import json
2
+ from typing import Any
3
+ from datetime import datetime
4
+ from typing_extensions import override
5
+
6
+ import pydantic
7
+
8
+ from .._compat import model_dump
9
+
10
+
11
+ def openapi_dumps(obj: Any) -> bytes:
12
+ """
13
+ Serialize an object to UTF-8 encoded JSON bytes.
14
+
15
+ Extends the standard json.dumps with support for additional types
16
+ commonly used in the SDK, such as `datetime`, `pydantic.BaseModel`, etc.
17
+ """
18
+ return json.dumps(
19
+ obj,
20
+ cls=_CustomEncoder,
21
+ # Uses the same defaults as httpx's JSON serialization
22
+ ensure_ascii=False,
23
+ separators=(",", ":"),
24
+ allow_nan=False,
25
+ ).encode()
26
+
27
+
28
+ class _CustomEncoder(json.JSONEncoder):
29
+ @override
30
+ def default(self, o: Any) -> Any:
31
+ if isinstance(o, datetime):
32
+ return o.isoformat()
33
+ if isinstance(o, pydantic.BaseModel):
34
+ return model_dump(o, exclude_unset=True, mode="json", by_alias=True)
35
+ return super().default(o)
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "checkout_intents"
4
- __version__ = "0.11.0" # x-release-please-version
4
+ __version__ = "0.13.0" # x-release-please-version
@@ -16,6 +16,14 @@ from .brands import (
16
16
  BrandsResourceWithStreamingResponse,
17
17
  AsyncBrandsResourceWithStreamingResponse,
18
18
  )
19
+ from .products import (
20
+ ProductsResource,
21
+ AsyncProductsResource,
22
+ ProductsResourceWithRawResponse,
23
+ AsyncProductsResourceWithRawResponse,
24
+ ProductsResourceWithStreamingResponse,
25
+ AsyncProductsResourceWithStreamingResponse,
26
+ )
19
27
  from .checkout_intents import (
20
28
  CheckoutIntentsResource,
21
29
  AsyncCheckoutIntentsResource,
@@ -44,4 +52,10 @@ __all__ = [
44
52
  "AsyncBrandsResourceWithRawResponse",
45
53
  "BrandsResourceWithStreamingResponse",
46
54
  "AsyncBrandsResourceWithStreamingResponse",
55
+ "ProductsResource",
56
+ "AsyncProductsResource",
57
+ "ProductsResourceWithRawResponse",
58
+ "AsyncProductsResourceWithRawResponse",
59
+ "ProductsResourceWithStreamingResponse",
60
+ "AsyncProductsResourceWithStreamingResponse",
47
61
  ]
@@ -59,6 +59,7 @@ class CheckoutSessionsResource(SyncAPIResource):
59
59
  extra_query: Query | None = None,
60
60
  extra_body: Body | None = None,
61
61
  timeout: float | httpx.Timeout | None | NotGiven = not_given,
62
+ idempotency_key: str | None = None,
62
63
  ) -> CheckoutSession:
63
64
  """
64
65
  Create a new checkout session.
@@ -77,6 +78,8 @@ class CheckoutSessionsResource(SyncAPIResource):
77
78
  extra_body: Add additional JSON properties to the request
78
79
 
79
80
  timeout: Override the client-level default timeout for this request, in seconds
81
+
82
+ idempotency_key: Specify a custom idempotency key for this request
80
83
  """
81
84
  return self._post(
82
85
  "/api/v1/betas/checkout-sessions",
@@ -92,7 +95,11 @@ class CheckoutSessionsResource(SyncAPIResource):
92
95
  checkout_session_create_params.CheckoutSessionCreateParams,
93
96
  ),
94
97
  options=make_request_options(
95
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
98
+ extra_headers=extra_headers,
99
+ extra_query=extra_query,
100
+ extra_body=extra_body,
101
+ timeout=timeout,
102
+ idempotency_key=idempotency_key,
96
103
  ),
97
104
  cast_to=CheckoutSession,
98
105
  )
@@ -133,6 +140,7 @@ class AsyncCheckoutSessionsResource(AsyncAPIResource):
133
140
  extra_query: Query | None = None,
134
141
  extra_body: Body | None = None,
135
142
  timeout: float | httpx.Timeout | None | NotGiven = not_given,
143
+ idempotency_key: str | None = None,
136
144
  ) -> CheckoutSession:
137
145
  """
138
146
  Create a new checkout session.
@@ -151,6 +159,8 @@ class AsyncCheckoutSessionsResource(AsyncAPIResource):
151
159
  extra_body: Add additional JSON properties to the request
152
160
 
153
161
  timeout: Override the client-level default timeout for this request, in seconds
162
+
163
+ idempotency_key: Specify a custom idempotency key for this request
154
164
  """
155
165
  return await self._post(
156
166
  "/api/v1/betas/checkout-sessions",
@@ -166,7 +176,11 @@ class AsyncCheckoutSessionsResource(AsyncAPIResource):
166
176
  checkout_session_create_params.CheckoutSessionCreateParams,
167
177
  ),
168
178
  options=make_request_options(
169
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
179
+ extra_headers=extra_headers,
180
+ extra_query=extra_query,
181
+ extra_body=extra_body,
182
+ timeout=timeout,
183
+ idempotency_key=idempotency_key,
170
184
  ),
171
185
  cast_to=CheckoutSession,
172
186
  )
@@ -80,6 +80,7 @@ class CheckoutIntentsResource(SyncAPIResource):
80
80
  extra_query: Query | None = None,
81
81
  extra_body: Body | None = None,
82
82
  timeout: float | httpx.Timeout | None | NotGiven = not_given,
83
+ idempotency_key: str | None = None,
83
84
  ) -> CheckoutIntent:
84
85
  """
85
86
  Create a checkout intent with the given request body.
@@ -92,6 +93,8 @@ class CheckoutIntentsResource(SyncAPIResource):
92
93
  extra_body: Add additional JSON properties to the request
93
94
 
94
95
  timeout: Override the client-level default timeout for this request, in seconds
96
+
97
+ idempotency_key: Specify a custom idempotency key for this request
95
98
  """
96
99
  return cast(
97
100
  CheckoutIntent,
@@ -109,7 +112,11 @@ class CheckoutIntentsResource(SyncAPIResource):
109
112
  checkout_intent_create_params.CheckoutIntentCreateParams,
110
113
  ),
111
114
  options=make_request_options(
112
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
115
+ extra_headers=extra_headers,
116
+ extra_query=extra_query,
117
+ extra_body=extra_body,
118
+ timeout=timeout,
119
+ idempotency_key=idempotency_key,
113
120
  ),
114
121
  cast_to=cast(Any, CheckoutIntent), # Union types cannot be passed in as arguments in the type system
115
122
  ),
@@ -217,6 +224,7 @@ class CheckoutIntentsResource(SyncAPIResource):
217
224
  extra_query: Query | None = None,
218
225
  extra_body: Body | None = None,
219
226
  timeout: float | httpx.Timeout | None | NotGiven = not_given,
227
+ idempotency_key: str | None = None,
220
228
  ) -> CheckoutIntent:
221
229
  """
222
230
  Add payment details to a checkout intent
@@ -229,6 +237,8 @@ class CheckoutIntentsResource(SyncAPIResource):
229
237
  extra_body: Add additional JSON properties to the request
230
238
 
231
239
  timeout: Override the client-level default timeout for this request, in seconds
240
+
241
+ idempotency_key: Specify a custom idempotency key for this request
232
242
  """
233
243
  if not id:
234
244
  raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
@@ -241,7 +251,11 @@ class CheckoutIntentsResource(SyncAPIResource):
241
251
  checkout_intent_add_payment_params.CheckoutIntentAddPaymentParams,
242
252
  ),
243
253
  options=make_request_options(
244
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
254
+ extra_headers=extra_headers,
255
+ extra_query=extra_query,
256
+ extra_body=extra_body,
257
+ timeout=timeout,
258
+ idempotency_key=idempotency_key,
245
259
  ),
246
260
  cast_to=cast(Any, CheckoutIntent), # Union types cannot be passed in as arguments in the type system
247
261
  ),
@@ -258,6 +272,7 @@ class CheckoutIntentsResource(SyncAPIResource):
258
272
  extra_query: Query | None = None,
259
273
  extra_body: Body | None = None,
260
274
  timeout: float | httpx.Timeout | None | NotGiven = not_given,
275
+ idempotency_key: str | None = None,
261
276
  ) -> CheckoutIntent:
262
277
  """
263
278
  Confirm a checkout intent with provided payment information
@@ -273,6 +288,8 @@ class CheckoutIntentsResource(SyncAPIResource):
273
288
  extra_body: Add additional JSON properties to the request
274
289
 
275
290
  timeout: Override the client-level default timeout for this request, in seconds
291
+
292
+ idempotency_key: Specify a custom idempotency key for this request
276
293
  """
277
294
  if not id:
278
295
  raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
@@ -284,7 +301,11 @@ class CheckoutIntentsResource(SyncAPIResource):
284
301
  {"payment_method": payment_method}, checkout_intent_confirm_params.CheckoutIntentConfirmParams
285
302
  ),
286
303
  options=make_request_options(
287
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
304
+ extra_headers=extra_headers,
305
+ extra_query=extra_query,
306
+ extra_body=extra_body,
307
+ timeout=timeout,
308
+ idempotency_key=idempotency_key,
288
309
  ),
289
310
  cast_to=cast(Any, CheckoutIntent), # Union types cannot be passed in as arguments in the type system
290
311
  ),
@@ -306,6 +327,7 @@ class CheckoutIntentsResource(SyncAPIResource):
306
327
  extra_query: Query | None = None,
307
328
  extra_body: Body | None = None,
308
329
  timeout: float | httpx.Timeout | None | NotGiven = not_given,
330
+ idempotency_key: str | None = None,
309
331
  ) -> CheckoutIntent:
310
332
  """
311
333
  Create a checkout intent and immediately trigger the purchase workflow.
@@ -322,6 +344,8 @@ class CheckoutIntentsResource(SyncAPIResource):
322
344
  extra_body: Add additional JSON properties to the request
323
345
 
324
346
  timeout: Override the client-level default timeout for this request, in seconds
347
+
348
+ idempotency_key: Specify a custom idempotency key for this request
325
349
  """
326
350
  return cast(
327
351
  CheckoutIntent,
@@ -340,7 +364,11 @@ class CheckoutIntentsResource(SyncAPIResource):
340
364
  checkout_intent_purchase_params.CheckoutIntentPurchaseParams
341
365
  ),
342
366
  options=make_request_options(
343
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
367
+ extra_headers=extra_headers,
368
+ extra_query=extra_query,
369
+ extra_body=extra_body,
370
+ timeout=timeout,
371
+ idempotency_key=idempotency_key,
344
372
  ),
345
373
  cast_to=cast(Any, CheckoutIntent), # Union types cannot be passed in as arguments in the type system
346
374
  ),
@@ -741,6 +769,7 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
741
769
  extra_query: Query | None = None,
742
770
  extra_body: Body | None = None,
743
771
  timeout: float | httpx.Timeout | None | NotGiven = not_given,
772
+ idempotency_key: str | None = None,
744
773
  ) -> CheckoutIntent:
745
774
  """
746
775
  Create a checkout intent with the given request body.
@@ -753,6 +782,8 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
753
782
  extra_body: Add additional JSON properties to the request
754
783
 
755
784
  timeout: Override the client-level default timeout for this request, in seconds
785
+
786
+ idempotency_key: Specify a custom idempotency key for this request
756
787
  """
757
788
  return cast(
758
789
  CheckoutIntent,
@@ -770,7 +801,11 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
770
801
  checkout_intent_create_params.CheckoutIntentCreateParams,
771
802
  ),
772
803
  options=make_request_options(
773
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
804
+ extra_headers=extra_headers,
805
+ extra_query=extra_query,
806
+ extra_body=extra_body,
807
+ timeout=timeout,
808
+ idempotency_key=idempotency_key,
774
809
  ),
775
810
  cast_to=cast(Any, CheckoutIntent), # Union types cannot be passed in as arguments in the type system
776
811
  ),
@@ -878,6 +913,7 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
878
913
  extra_query: Query | None = None,
879
914
  extra_body: Body | None = None,
880
915
  timeout: float | httpx.Timeout | None | NotGiven = not_given,
916
+ idempotency_key: str | None = None,
881
917
  ) -> CheckoutIntent:
882
918
  """
883
919
  Add payment details to a checkout intent
@@ -890,6 +926,8 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
890
926
  extra_body: Add additional JSON properties to the request
891
927
 
892
928
  timeout: Override the client-level default timeout for this request, in seconds
929
+
930
+ idempotency_key: Specify a custom idempotency key for this request
893
931
  """
894
932
  if not id:
895
933
  raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
@@ -902,7 +940,11 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
902
940
  checkout_intent_add_payment_params.CheckoutIntentAddPaymentParams,
903
941
  ),
904
942
  options=make_request_options(
905
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
943
+ extra_headers=extra_headers,
944
+ extra_query=extra_query,
945
+ extra_body=extra_body,
946
+ timeout=timeout,
947
+ idempotency_key=idempotency_key,
906
948
  ),
907
949
  cast_to=cast(Any, CheckoutIntent), # Union types cannot be passed in as arguments in the type system
908
950
  ),
@@ -919,6 +961,7 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
919
961
  extra_query: Query | None = None,
920
962
  extra_body: Body | None = None,
921
963
  timeout: float | httpx.Timeout | None | NotGiven = not_given,
964
+ idempotency_key: str | None = None,
922
965
  ) -> CheckoutIntent:
923
966
  """
924
967
  Confirm a checkout intent with provided payment information
@@ -934,6 +977,8 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
934
977
  extra_body: Add additional JSON properties to the request
935
978
 
936
979
  timeout: Override the client-level default timeout for this request, in seconds
980
+
981
+ idempotency_key: Specify a custom idempotency key for this request
937
982
  """
938
983
  if not id:
939
984
  raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
@@ -945,7 +990,11 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
945
990
  {"payment_method": payment_method}, checkout_intent_confirm_params.CheckoutIntentConfirmParams
946
991
  ),
947
992
  options=make_request_options(
948
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
993
+ extra_headers=extra_headers,
994
+ extra_query=extra_query,
995
+ extra_body=extra_body,
996
+ timeout=timeout,
997
+ idempotency_key=idempotency_key,
949
998
  ),
950
999
  cast_to=cast(Any, CheckoutIntent), # Union types cannot be passed in as arguments in the type system
951
1000
  ),
@@ -967,6 +1016,7 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
967
1016
  extra_query: Query | None = None,
968
1017
  extra_body: Body | None = None,
969
1018
  timeout: float | httpx.Timeout | None | NotGiven = not_given,
1019
+ idempotency_key: str | None = None,
970
1020
  ) -> CheckoutIntent:
971
1021
  """
972
1022
  Create a checkout intent and immediately trigger the purchase workflow.
@@ -983,6 +1033,8 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
983
1033
  extra_body: Add additional JSON properties to the request
984
1034
 
985
1035
  timeout: Override the client-level default timeout for this request, in seconds
1036
+
1037
+ idempotency_key: Specify a custom idempotency key for this request
986
1038
  """
987
1039
  return cast(
988
1040
  CheckoutIntent,
@@ -1001,7 +1053,11 @@ class AsyncCheckoutIntentsResource(AsyncAPIResource):
1001
1053
  checkout_intent_purchase_params.CheckoutIntentPurchaseParams
1002
1054
  ),
1003
1055
  options=make_request_options(
1004
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1056
+ extra_headers=extra_headers,
1057
+ extra_query=extra_query,
1058
+ extra_body=extra_body,
1059
+ timeout=timeout,
1060
+ idempotency_key=idempotency_key,
1005
1061
  ),
1006
1062
  cast_to=cast(Any, CheckoutIntent), # Union types cannot be passed in as arguments in the type system
1007
1063
  ),