checkout-intents 0.3.1 → 0.4.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +56 -0
- data/README.md +11 -9
- data/lib/checkout_intents/client.rb +11 -11
- data/lib/checkout_intents/errors.rb +23 -23
- data/lib/checkout_intents/helpers/polling.rb +91 -0
- data/lib/checkout_intents/internal/cursor_pagination.rb +11 -11
- data/lib/checkout_intents/internal/transport/base_client.rb +57 -57
- data/lib/checkout_intents/internal/transport/pooled_net_requester.rb +11 -11
- data/lib/checkout_intents/internal/type/array_of.rb +11 -11
- data/lib/checkout_intents/internal/type/base_model.rb +37 -37
- data/lib/checkout_intents/internal/type/base_page.rb +2 -2
- data/lib/checkout_intents/internal/type/boolean.rb +3 -3
- data/lib/checkout_intents/internal/type/converter.rb +19 -19
- data/lib/checkout_intents/internal/type/enum.rb +11 -9
- data/lib/checkout_intents/internal/type/file_input.rb +8 -8
- data/lib/checkout_intents/internal/type/hash_of.rb +11 -11
- data/lib/checkout_intents/internal/type/request_parameters.rb +4 -4
- data/lib/checkout_intents/internal/type/union.rb +23 -23
- data/lib/checkout_intents/internal/type/unknown.rb +3 -3
- data/lib/checkout_intents/internal/util.rb +14 -14
- data/lib/checkout_intents/internal.rb +3 -3
- data/lib/checkout_intents/models/base_checkout_intent.rb +28 -20
- data/lib/checkout_intents/models/betas/checkout_session_create_params.rb +55 -25
- data/lib/checkout_intents/models/brand_retrieve_params.rb +5 -5
- data/lib/checkout_intents/models/brand_retrieve_response.rb +9 -9
- data/lib/checkout_intents/models/buyer.rb +1 -1
- data/lib/checkout_intents/models/checkout_intent.rb +78 -69
- data/lib/checkout_intents/models/checkout_intent_add_payment_params.rb +8 -8
- data/lib/checkout_intents/models/checkout_intent_confirm_params.rb +8 -8
- data/lib/checkout_intents/models/checkout_intent_create_params.rb +33 -23
- data/lib/checkout_intents/models/checkout_intent_list_params.rb +12 -12
- data/lib/checkout_intents/models/checkout_intent_purchase_params.rb +34 -26
- data/lib/checkout_intents/models/checkout_intent_retrieve_params.rb +5 -5
- data/lib/checkout_intents/models/checkout_session.rb +1 -1
- data/lib/checkout_intents/models/money.rb +1 -1
- data/lib/checkout_intents/models/offer.rb +40 -40
- data/lib/checkout_intents/models/payment_method.rb +75 -25
- data/lib/checkout_intents/models/product.rb +20 -13
- data/lib/checkout_intents/models/product_availability.rb +1 -1
- data/lib/checkout_intents/models/product_image.rb +2 -2
- data/lib/checkout_intents/models/product_lookup_params.rb +5 -5
- data/lib/checkout_intents/models/variant_selection.rb +4 -4
- data/lib/checkout_intents/models.rb +29 -29
- data/lib/checkout_intents/request_options.rb +7 -7
- data/lib/checkout_intents/resources/betas/checkout_sessions.rb +5 -1
- data/lib/checkout_intents/resources/checkout_intents.rb +21 -87
- data/lib/checkout_intents/version.rb +1 -1
- data/lib/checkout_intents.rb +1 -0
- data/rbi/checkout_intents/client.rbi +9 -9
- data/rbi/checkout_intents/errors.rbi +14 -14
- data/rbi/checkout_intents/helpers/polling.rbi +54 -0
- data/rbi/checkout_intents/internal/cursor_pagination.rbi +3 -3
- data/rbi/checkout_intents/internal/transport/base_client.rbi +22 -21
- data/rbi/checkout_intents/internal/transport/pooled_net_requester.rbi +4 -4
- data/rbi/checkout_intents/internal/type/array_of.rbi +12 -12
- data/rbi/checkout_intents/internal/type/base_model.rbi +34 -32
- data/rbi/checkout_intents/internal/type/base_page.rbi +2 -2
- data/rbi/checkout_intents/internal/type/boolean.rbi +4 -4
- data/rbi/checkout_intents/internal/type/converter.rbi +23 -23
- data/rbi/checkout_intents/internal/type/enum.rbi +4 -4
- data/rbi/checkout_intents/internal/type/file_input.rbi +4 -4
- data/rbi/checkout_intents/internal/type/hash_of.rbi +14 -14
- data/rbi/checkout_intents/internal/type/request_parameters.rbi +5 -3
- data/rbi/checkout_intents/internal/type/union.rbi +9 -9
- data/rbi/checkout_intents/internal/type/unknown.rbi +4 -4
- data/rbi/checkout_intents/internal/util.rbi +9 -9
- data/rbi/checkout_intents/internal.rbi +2 -2
- data/rbi/checkout_intents/models/base_checkout_intent.rbi +38 -27
- data/rbi/checkout_intents/models/betas/checkout_session_create_params.rbi +108 -34
- data/rbi/checkout_intents/models/brand_retrieve_params.rbi +7 -7
- data/rbi/checkout_intents/models/brand_retrieve_response.rbi +13 -13
- data/rbi/checkout_intents/models/buyer.rbi +2 -2
- data/rbi/checkout_intents/models/checkout_intent.rbi +162 -134
- data/rbi/checkout_intents/models/checkout_intent_add_payment_params.rbi +22 -16
- data/rbi/checkout_intents/models/checkout_intent_confirm_params.rbi +22 -16
- data/rbi/checkout_intents/models/checkout_intent_create_params.rbi +40 -31
- data/rbi/checkout_intents/models/checkout_intent_list_params.rbi +31 -27
- data/rbi/checkout_intents/models/checkout_intent_purchase_params.rbi +57 -40
- data/rbi/checkout_intents/models/checkout_intent_retrieve_params.rbi +7 -7
- data/rbi/checkout_intents/models/checkout_session.rbi +3 -3
- data/rbi/checkout_intents/models/money.rbi +2 -2
- data/rbi/checkout_intents/models/offer.rbi +54 -54
- data/rbi/checkout_intents/models/payment_method.rbi +180 -41
- data/rbi/checkout_intents/models/product.rbi +21 -12
- data/rbi/checkout_intents/models/product_availability.rbi +11 -8
- data/rbi/checkout_intents/models/product_image.rbi +3 -3
- data/rbi/checkout_intents/models/product_lookup_params.rbi +7 -7
- data/rbi/checkout_intents/models/variant_selection.rbi +8 -8
- data/rbi/checkout_intents/models.rbi +20 -20
- data/rbi/checkout_intents/request_options.rbi +5 -5
- data/rbi/checkout_intents/resources/betas/checkout_sessions.rbi +7 -0
- data/rbi/checkout_intents/resources/checkout_intents.rbi +21 -17
- data/sig/checkout_intents/client.rbs +5 -5
- data/sig/checkout_intents/errors.rbs +13 -13
- data/sig/checkout_intents/helpers/polling.rbs +24 -0
- data/sig/checkout_intents/internal/cursor_pagination.rbs +2 -2
- data/sig/checkout_intents/internal/transport/base_client.rbs +14 -14
- data/sig/checkout_intents/internal/transport/pooled_net_requester.rbs +3 -3
- data/sig/checkout_intents/internal/type/array_of.rbs +8 -8
- data/sig/checkout_intents/internal/type/base_model.rbs +20 -18
- data/sig/checkout_intents/internal/type/base_page.rbs +2 -2
- data/sig/checkout_intents/internal/type/boolean.rbs +4 -4
- data/sig/checkout_intents/internal/type/converter.rbs +21 -21
- data/sig/checkout_intents/internal/type/enum.rbs +4 -4
- data/sig/checkout_intents/internal/type/file_input.rbs +3 -3
- data/sig/checkout_intents/internal/type/hash_of.rbs +8 -8
- data/sig/checkout_intents/internal/type/request_parameters.rbs +4 -4
- data/sig/checkout_intents/internal/type/union.rbs +10 -10
- data/sig/checkout_intents/internal/type/unknown.rbs +4 -4
- data/sig/checkout_intents/internal/util.rbs +7 -7
- data/sig/checkout_intents/internal.rbs +2 -2
- data/sig/checkout_intents/models/base_checkout_intent.rbs +33 -26
- data/sig/checkout_intents/models/betas/checkout_session_create_params.rbs +61 -34
- data/sig/checkout_intents/models/brand_retrieve_params.rbs +8 -6
- data/sig/checkout_intents/models/brand_retrieve_response.rbs +7 -7
- data/sig/checkout_intents/models/buyer.rbs +1 -1
- data/sig/checkout_intents/models/checkout_intent.rbs +118 -109
- data/sig/checkout_intents/models/checkout_intent_add_payment_params.rbs +10 -10
- data/sig/checkout_intents/models/checkout_intent_confirm_params.rbs +10 -10
- data/sig/checkout_intents/models/checkout_intent_create_params.rbs +38 -31
- data/sig/checkout_intents/models/checkout_intent_list_params.rbs +19 -19
- data/sig/checkout_intents/models/checkout_intent_purchase_params.rbs +42 -35
- data/sig/checkout_intents/models/checkout_intent_retrieve_params.rbs +8 -6
- data/sig/checkout_intents/models/checkout_session.rbs +1 -1
- data/sig/checkout_intents/models/money.rbs +1 -1
- data/sig/checkout_intents/models/offer.rbs +53 -53
- data/sig/checkout_intents/models/payment_method.rbs +95 -34
- data/sig/checkout_intents/models/product.rbs +18 -13
- data/sig/checkout_intents/models/product_availability.rbs +2 -2
- data/sig/checkout_intents/models/product_image.rbs +1 -1
- data/sig/checkout_intents/models/product_lookup_params.rbs +6 -6
- data/sig/checkout_intents/models/variant_selection.rbs +10 -7
- data/sig/checkout_intents/models.rbs +20 -20
- data/sig/checkout_intents/request_options.rbs +5 -5
- data/sig/checkout_intents/resources/betas/checkout_sessions.rbs +8 -6
- data/sig/checkout_intents/resources/betas.rbs +2 -2
- data/sig/checkout_intents/resources/brands.rbs +3 -3
- data/sig/checkout_intents/resources/checkout_intents.rbs +41 -39
- data/sig/checkout_intents/resources/products.rbs +3 -3
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e95cb2b0e6816c9a4a08dfbcb3397b51587fbb1f14f3a5335e2fc91377853d9a
|
|
4
|
+
data.tar.gz: df0ea3bfe74c7958477438ccb52ce9f61943a9f94d031dade04f430cf2b80e3a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe526dbcf0a927db2819a5b8a87bbc685d7548e2212266297e0a0807aad840cae94d94dd455101bc2e2d83396e19160f86cfe44a3f6a613ec22aac9f2947c9f4
|
|
7
|
+
data.tar.gz: f4982fc701c36a7cb01119bcea079c1d2d1199eb268fb736b28e327f6a1f85a5dbb616b6f194aad725ec565bfa1833ee1e79e64776e6230647bd42dc1f3f33c5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0 (2026-02-25)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.3.1...v0.4.0](https://github.com/rye-com/checkout-intents-ruby/compare/v0.3.1...v0.4.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* add merchants API endpoint ([fe328c8](https://github.com/rye-com/checkout-intents-ruby/commit/fe328c8624e6918c8fc12116e94ac234c55809c7))
|
|
10
|
+
* Add PaymentMethod support for Prava ([14403ec](https://github.com/rye-com/checkout-intents-ruby/commit/14403ec2d12b9cc0b158b1f13f57a4f2562425a5))
|
|
11
|
+
* Add stainless updates ([fb15ca9](https://github.com/rye-com/checkout-intents-ruby/commit/fb15ca96cfa2cce055f4b5298337d153a27d01d7))
|
|
12
|
+
* Billing: Add BillingReconciliationService for expired drawdown orders ([bfdf7c7](https://github.com/rye-com/checkout-intents-ruby/commit/bfdf7c7623d2f67ded81d7d4b42586c7761b9587))
|
|
13
|
+
* Billing: Add BillingReconciliationService for expired drawdown orders ([4c5cc0c](https://github.com/rye-com/checkout-intents-ruby/commit/4c5cc0c21cf3fff1dd814f0980f391769f991903))
|
|
14
|
+
* Billing: Envelope payment processing fields ([4883dbc](https://github.com/rye-com/checkout-intents-ruby/commit/4883dbce3f4f94f6f479b7e9c7590acc3f4f98fe))
|
|
15
|
+
* Billing: Integrate drawdown payments in order flow ([fc96bce](https://github.com/rye-com/checkout-intents-ruby/commit/fc96bce1e2161b0e860d966a4c0dcd95088ae650))
|
|
16
|
+
* Centralize Shopify domain resolution into ShopifyDomainResolver service ([667747d](https://github.com/rye-com/checkout-intents-ruby/commit/667747d078a9f4cb4f21610de3f8845792a107e9))
|
|
17
|
+
* Enable searching checkoutIntent by order Id on dev console ([e4e1d60](https://github.com/rye-com/checkout-intents-ruby/commit/e4e1d60fcd31fe16a114657e0d88c5198ca31470))
|
|
18
|
+
* integrate promo codes discovery to checkout intent flow ([0a853b4](https://github.com/rye-com/checkout-intents-ruby/commit/0a853b42afa15f3ebd965056fe939581d7d8d5b5))
|
|
19
|
+
* Phase 3: Strategy Interface + Normalizer ([f7a8093](https://github.com/rye-com/checkout-intents-ruby/commit/f7a809350d9d2b47d3e33fa15c934423b3890769))
|
|
20
|
+
* Remove `shipments` from our stainless config ([647f966](https://github.com/rye-com/checkout-intents-ruby/commit/647f966aa6283367a86bb6b1bb1016d0b7baa1b6))
|
|
21
|
+
* Remove duplicate method from controller ([bdbda16](https://github.com/rye-com/checkout-intents-ruby/commit/bdbda16d7cd63db41d9253625d6a6a1ed8715acf))
|
|
22
|
+
* Store estimated delivery date on completed checkout intent ([1114b43](https://github.com/rye-com/checkout-intents-ruby/commit/1114b4326c1a372f33d6cc17171db0192ed4d40c))
|
|
23
|
+
* Store estimated delivery date on completed checkout intent ([cce80b5](https://github.com/rye-com/checkout-intents-ruby/commit/cce80b5171fba2b7573b5ce27bd328c4cbc9d194))
|
|
24
|
+
* Unwrap `rd.bizrate.com` affiliate URLs ([9b31371](https://github.com/rye-com/checkout-intents-ruby/commit/9b3137194da902b632001a16756a6bd3df4a1770))
|
|
25
|
+
* Unwrap `rd.bizrate.com` affiliate URLs ([5620d06](https://github.com/rye-com/checkout-intents-ruby/commit/5620d06a52adba2842dc67e9acb8c38574fcff24))
|
|
26
|
+
* Update return states to better reflect return lifecycle ([7b2053f](https://github.com/rye-com/checkout-intents-ruby/commit/7b2053f24007e8f3d401b7a73b0c4ad1c7856191))
|
|
27
|
+
* wire up wizard layout and pass layout type through JWT ([3b5be9b](https://github.com/rye-com/checkout-intents-ruby/commit/3b5be9bdba3d7e1c5f13530aae7348028928974b))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* **client:** always add content-length to post body, even when empty ([cf0a01b](https://github.com/rye-com/checkout-intents-ruby/commit/cf0a01b9aea9660921b37245e054d7d3c4bc6589))
|
|
33
|
+
* **client:** loosen json header parsing ([370e9f1](https://github.com/rye-com/checkout-intents-ruby/commit/370e9f183a4a01425a6ed55f1f587cec1ce0051b))
|
|
34
|
+
* **internal:** auto-correct style issues on format ([0996321](https://github.com/rye-com/checkout-intents-ruby/commit/0996321f2b40af55bfa1f5f7c1440b536465e3ec))
|
|
35
|
+
* **internal:** expand `fix-absolute-references` script ([bb4c3db](https://github.com/rye-com/checkout-intents-ruby/commit/bb4c3db1a0919f5196c6de982bc31568f1f95c02))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Chores
|
|
39
|
+
|
|
40
|
+
* **docs:** remove www prefix ([94872c2](https://github.com/rye-com/checkout-intents-ruby/commit/94872c23c918df8535960a872609a82355b0a8f1))
|
|
41
|
+
* **internal:** format and fix absolute references ([b804e1a](https://github.com/rye-com/checkout-intents-ruby/commit/b804e1a10bb5e0cde953dc9b459805dce71b4e30))
|
|
42
|
+
* **internal:** format and fix absolute references ([398a39c](https://github.com/rye-com/checkout-intents-ruby/commit/398a39ccebcc0aa1e3d9dda3e596c3ba6cffe7db))
|
|
43
|
+
* **internal:** format and fix absolute references ([cc55350](https://github.com/rye-com/checkout-intents-ruby/commit/cc55350f01e1e361ea686cf361078082b3fab927))
|
|
44
|
+
* **internal:** format and fix absolute references ([a4ef09b](https://github.com/rye-com/checkout-intents-ruby/commit/a4ef09b368112fda02705a6203d5c5e7e4e2eaeb))
|
|
45
|
+
* **internal:** format and fix absolute references ([a52c0ba](https://github.com/rye-com/checkout-intents-ruby/commit/a52c0ba29741ebcba333a77c353157ce57388fae))
|
|
46
|
+
* **internal:** format and fix absolute references ([044f29e](https://github.com/rye-com/checkout-intents-ruby/commit/044f29e1e7c25ccfa25d1a43e0b730fe6964fc0b))
|
|
47
|
+
* **internal:** format and fix absolute references ([9cca341](https://github.com/rye-com/checkout-intents-ruby/commit/9cca34174d75aee7798f4bbea375e5f6f4955c15))
|
|
48
|
+
* **internal:** format and fix absolute references ([c7e748d](https://github.com/rye-com/checkout-intents-ruby/commit/c7e748d8a4114448c505310c30add13357800b12))
|
|
49
|
+
* **internal:** format and fix absolute references ([37f8e6f](https://github.com/rye-com/checkout-intents-ruby/commit/37f8e6f6ce31b7e44b6a71aecb45682e061d888c))
|
|
50
|
+
* **internal:** format and fix absolute references ([1d010c4](https://github.com/rye-com/checkout-intents-ruby/commit/1d010c4d9e2c3387efdde6d5a4019d94e7757607))
|
|
51
|
+
* **internal:** format and fix absolute references ([2890fe0](https://github.com/rye-com/checkout-intents-ruby/commit/2890fe035123d6af0bb4f7de2252af919cdc285d))
|
|
52
|
+
* **internal:** improvements ([9d65299](https://github.com/rye-com/checkout-intents-ruby/commit/9d652994c7618deb3479d73f5fc56c4ef0fa1878))
|
|
53
|
+
* **internal:** improvements ([826f76c](https://github.com/rye-com/checkout-intents-ruby/commit/826f76c459e35ee6327f7c8910a7c399cef9e9f5))
|
|
54
|
+
* **internal:** improvements ([b8d678f](https://github.com/rye-com/checkout-intents-ruby/commit/b8d678ffd041f631487709fea369fc2ac0184d6f))
|
|
55
|
+
* **internal:** move polling helpers ([4e74c7f](https://github.com/rye-com/checkout-intents-ruby/commit/4e74c7fe0b32260c63980e9e9bbe2185966a0df2))
|
|
56
|
+
* **internal:** remove mock server code ([43ad79f](https://github.com/rye-com/checkout-intents-ruby/commit/43ad79f58124c6f40fc9ae6a95a59f5404ea6a0f))
|
|
57
|
+
* update mock server docs ([47ac5a6](https://github.com/rye-com/checkout-intents-ruby/commit/47ac5a65f13964ea4c0e764023fe2a802612657b))
|
|
58
|
+
|
|
3
59
|
## 0.3.1 (2026-01-30)
|
|
4
60
|
|
|
5
61
|
Full Changelog: [v0.3.0...v0.3.1](https://github.com/rye-com/checkout-intents-ruby/compare/v0.3.0...v0.3.1)
|
data/README.md
CHANGED
|
@@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
|
|
|
17
17
|
<!-- x-release-please-start-version -->
|
|
18
18
|
|
|
19
19
|
```ruby
|
|
20
|
-
gem "checkout-intents", "~> 0.
|
|
20
|
+
gem "checkout-intents", "~> 0.4.0"
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
<!-- x-release-please-end -->
|
|
@@ -427,23 +427,25 @@ checkout_intents.checkout_intents.purchase(**params)
|
|
|
427
427
|
Since this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:
|
|
428
428
|
|
|
429
429
|
```ruby
|
|
430
|
-
# :
|
|
431
|
-
puts(CheckoutIntents::
|
|
430
|
+
# :default
|
|
431
|
+
puts(CheckoutIntents::Betas::CheckoutSessionCreateParams::Layout::DEFAULT)
|
|
432
432
|
|
|
433
|
-
# Revealed type: `T.all(CheckoutIntents::
|
|
434
|
-
T.reveal_type(CheckoutIntents::
|
|
433
|
+
# Revealed type: `T.all(CheckoutIntents::Betas::CheckoutSessionCreateParams::Layout, Symbol)`
|
|
434
|
+
T.reveal_type(CheckoutIntents::Betas::CheckoutSessionCreateParams::Layout::DEFAULT)
|
|
435
435
|
```
|
|
436
436
|
|
|
437
437
|
Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:
|
|
438
438
|
|
|
439
439
|
```ruby
|
|
440
|
-
|
|
441
|
-
|
|
440
|
+
# Using the enum constants preserves the tagged type information:
|
|
441
|
+
checkout_intents.betas.checkout_sessions.create(
|
|
442
|
+
layout: CheckoutIntents::Betas::CheckoutSessionCreateParams::Layout::DEFAULT,
|
|
442
443
|
# …
|
|
443
444
|
)
|
|
444
445
|
|
|
445
|
-
|
|
446
|
-
|
|
446
|
+
# Literal values are also permissible:
|
|
447
|
+
checkout_intents.betas.checkout_sessions.create(
|
|
448
|
+
layout: :default,
|
|
447
449
|
# …
|
|
448
450
|
)
|
|
449
451
|
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module CheckoutIntents
|
|
4
|
-
class Client < CheckoutIntents::Internal::Transport::BaseClient
|
|
4
|
+
class Client < ::CheckoutIntents::Internal::Transport::BaseClient
|
|
5
5
|
# Default max number of retries to attempt after a failed retryable request.
|
|
6
6
|
DEFAULT_MAX_RETRIES = 2
|
|
7
7
|
|
|
@@ -24,16 +24,16 @@ module CheckoutIntents
|
|
|
24
24
|
# @return [String]
|
|
25
25
|
attr_reader :api_key
|
|
26
26
|
|
|
27
|
-
# @return [CheckoutIntents::Resources::CheckoutIntents]
|
|
27
|
+
# @return [::CheckoutIntents::Resources::CheckoutIntents]
|
|
28
28
|
attr_reader :checkout_intents
|
|
29
29
|
|
|
30
|
-
# @return [CheckoutIntents::Resources::Betas]
|
|
30
|
+
# @return [::CheckoutIntents::Resources::Betas]
|
|
31
31
|
attr_reader :betas
|
|
32
32
|
|
|
33
|
-
# @return [CheckoutIntents::Resources::Brands]
|
|
33
|
+
# @return [::CheckoutIntents::Resources::Brands]
|
|
34
34
|
attr_reader :brands
|
|
35
35
|
|
|
36
|
-
# @return [CheckoutIntents::Resources::Products]
|
|
36
|
+
# @return [::CheckoutIntents::Resources::Products]
|
|
37
37
|
attr_reader :products
|
|
38
38
|
|
|
39
39
|
# @api private
|
|
@@ -114,8 +114,8 @@ module CheckoutIntents
|
|
|
114
114
|
# Resolve environment: explicit > inferred > default (staging)
|
|
115
115
|
resolved_environment = environment&.to_sym || inferred_environment || :staging
|
|
116
116
|
|
|
117
|
-
base_url ||= CheckoutIntents::Client::ENVIRONMENTS.fetch(resolved_environment) do
|
|
118
|
-
message = "environment must be one of #{CheckoutIntents::Client::ENVIRONMENTS.keys}, got #{resolved_environment}"
|
|
117
|
+
base_url ||= ::CheckoutIntents::Client::ENVIRONMENTS.fetch(resolved_environment) do
|
|
118
|
+
message = "environment must be one of #{::CheckoutIntents::Client::ENVIRONMENTS.keys}, got #{resolved_environment}"
|
|
119
119
|
raise ArgumentError.new(message)
|
|
120
120
|
end
|
|
121
121
|
|
|
@@ -128,10 +128,10 @@ module CheckoutIntents
|
|
|
128
128
|
idempotency_header: idempotency_header
|
|
129
129
|
)
|
|
130
130
|
|
|
131
|
-
@checkout_intents = CheckoutIntents::Resources::CheckoutIntents.new(client: self)
|
|
132
|
-
@betas = CheckoutIntents::Resources::Betas.new(client: self)
|
|
133
|
-
@brands = CheckoutIntents::Resources::Brands.new(client: self)
|
|
134
|
-
@products = CheckoutIntents::Resources::Products.new(client: self)
|
|
131
|
+
@checkout_intents = ::CheckoutIntents::Resources::CheckoutIntents.new(client: self)
|
|
132
|
+
@betas = ::CheckoutIntents::Resources::Betas.new(client: self)
|
|
133
|
+
@brands = ::CheckoutIntents::Resources::Brands.new(client: self)
|
|
134
|
+
@products = ::CheckoutIntents::Resources::Products.new(client: self)
|
|
135
135
|
end
|
|
136
136
|
end
|
|
137
137
|
end
|
|
@@ -8,7 +8,7 @@ module CheckoutIntents
|
|
|
8
8
|
# @return [StandardError, nil]
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
class ConversionError < CheckoutIntents::Errors::Error
|
|
11
|
+
class ConversionError < ::CheckoutIntents::Errors::Error
|
|
12
12
|
# @return [StandardError, nil]
|
|
13
13
|
def cause = @cause.nil? ? super : @cause
|
|
14
14
|
|
|
@@ -33,7 +33,7 @@ module CheckoutIntents
|
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
class APIError < CheckoutIntents::Errors::Error
|
|
36
|
+
class APIError < ::CheckoutIntents::Errors::Error
|
|
37
37
|
# @return [URI::Generic]
|
|
38
38
|
attr_accessor :url
|
|
39
39
|
|
|
@@ -66,7 +66,7 @@ module CheckoutIntents
|
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
class APIConnectionError < CheckoutIntents::Errors::APIError
|
|
69
|
+
class APIConnectionError < ::CheckoutIntents::Errors::APIError
|
|
70
70
|
# @!attribute status
|
|
71
71
|
#
|
|
72
72
|
# @return [nil]
|
|
@@ -97,7 +97,7 @@ module CheckoutIntents
|
|
|
97
97
|
end
|
|
98
98
|
end
|
|
99
99
|
|
|
100
|
-
class APITimeoutError < CheckoutIntents::Errors::APIConnectionError
|
|
100
|
+
class APITimeoutError < ::CheckoutIntents::Errors::APIConnectionError
|
|
101
101
|
# @api private
|
|
102
102
|
#
|
|
103
103
|
# @param url [URI::Generic]
|
|
@@ -120,7 +120,7 @@ module CheckoutIntents
|
|
|
120
120
|
end
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
-
class APIStatusError < CheckoutIntents::Errors::APIError
|
|
123
|
+
class APIStatusError < ::CheckoutIntents::Errors::APIError
|
|
124
124
|
# @api private
|
|
125
125
|
#
|
|
126
126
|
# @param url [URI::Generic]
|
|
@@ -146,23 +146,23 @@ module CheckoutIntents
|
|
|
146
146
|
|
|
147
147
|
case status
|
|
148
148
|
in 400
|
|
149
|
-
CheckoutIntents::Errors::BadRequestError.new(**kwargs)
|
|
149
|
+
::CheckoutIntents::Errors::BadRequestError.new(**kwargs)
|
|
150
150
|
in 401
|
|
151
|
-
CheckoutIntents::Errors::AuthenticationError.new(**kwargs)
|
|
151
|
+
::CheckoutIntents::Errors::AuthenticationError.new(**kwargs)
|
|
152
152
|
in 403
|
|
153
|
-
CheckoutIntents::Errors::PermissionDeniedError.new(**kwargs)
|
|
153
|
+
::CheckoutIntents::Errors::PermissionDeniedError.new(**kwargs)
|
|
154
154
|
in 404
|
|
155
|
-
CheckoutIntents::Errors::NotFoundError.new(**kwargs)
|
|
155
|
+
::CheckoutIntents::Errors::NotFoundError.new(**kwargs)
|
|
156
156
|
in 409
|
|
157
|
-
CheckoutIntents::Errors::ConflictError.new(**kwargs)
|
|
157
|
+
::CheckoutIntents::Errors::ConflictError.new(**kwargs)
|
|
158
158
|
in 422
|
|
159
|
-
CheckoutIntents::Errors::UnprocessableEntityError.new(**kwargs)
|
|
159
|
+
::CheckoutIntents::Errors::UnprocessableEntityError.new(**kwargs)
|
|
160
160
|
in 429
|
|
161
|
-
CheckoutIntents::Errors::RateLimitError.new(**kwargs)
|
|
161
|
+
::CheckoutIntents::Errors::RateLimitError.new(**kwargs)
|
|
162
162
|
in (500..)
|
|
163
|
-
CheckoutIntents::Errors::InternalServerError.new(**kwargs)
|
|
163
|
+
::CheckoutIntents::Errors::InternalServerError.new(**kwargs)
|
|
164
164
|
else
|
|
165
|
-
CheckoutIntents::Errors::APIStatusError.new(**kwargs)
|
|
165
|
+
::CheckoutIntents::Errors::APIStatusError.new(**kwargs)
|
|
166
166
|
end
|
|
167
167
|
end
|
|
168
168
|
|
|
@@ -193,39 +193,39 @@ module CheckoutIntents
|
|
|
193
193
|
end
|
|
194
194
|
end
|
|
195
195
|
|
|
196
|
-
class BadRequestError < CheckoutIntents::Errors::APIStatusError
|
|
196
|
+
class BadRequestError < ::CheckoutIntents::Errors::APIStatusError
|
|
197
197
|
HTTP_STATUS = 400
|
|
198
198
|
end
|
|
199
199
|
|
|
200
|
-
class AuthenticationError < CheckoutIntents::Errors::APIStatusError
|
|
200
|
+
class AuthenticationError < ::CheckoutIntents::Errors::APIStatusError
|
|
201
201
|
HTTP_STATUS = 401
|
|
202
202
|
end
|
|
203
203
|
|
|
204
|
-
class PermissionDeniedError < CheckoutIntents::Errors::APIStatusError
|
|
204
|
+
class PermissionDeniedError < ::CheckoutIntents::Errors::APIStatusError
|
|
205
205
|
HTTP_STATUS = 403
|
|
206
206
|
end
|
|
207
207
|
|
|
208
|
-
class NotFoundError < CheckoutIntents::Errors::APIStatusError
|
|
208
|
+
class NotFoundError < ::CheckoutIntents::Errors::APIStatusError
|
|
209
209
|
HTTP_STATUS = 404
|
|
210
210
|
end
|
|
211
211
|
|
|
212
|
-
class ConflictError < CheckoutIntents::Errors::APIStatusError
|
|
212
|
+
class ConflictError < ::CheckoutIntents::Errors::APIStatusError
|
|
213
213
|
HTTP_STATUS = 409
|
|
214
214
|
end
|
|
215
215
|
|
|
216
|
-
class UnprocessableEntityError < CheckoutIntents::Errors::APIStatusError
|
|
216
|
+
class UnprocessableEntityError < ::CheckoutIntents::Errors::APIStatusError
|
|
217
217
|
HTTP_STATUS = 422
|
|
218
218
|
end
|
|
219
219
|
|
|
220
|
-
class RateLimitError < CheckoutIntents::Errors::APIStatusError
|
|
220
|
+
class RateLimitError < ::CheckoutIntents::Errors::APIStatusError
|
|
221
221
|
HTTP_STATUS = 429
|
|
222
222
|
end
|
|
223
223
|
|
|
224
|
-
class InternalServerError < CheckoutIntents::Errors::APIStatusError
|
|
224
|
+
class InternalServerError < ::CheckoutIntents::Errors::APIStatusError
|
|
225
225
|
HTTP_STATUS = (500..)
|
|
226
226
|
end
|
|
227
227
|
|
|
228
|
-
class PollTimeoutError < CheckoutIntents::Errors::Error
|
|
228
|
+
class PollTimeoutError < ::CheckoutIntents::Errors::Error
|
|
229
229
|
# @return [String]
|
|
230
230
|
attr_reader :intent_id
|
|
231
231
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CheckoutIntents
|
|
4
|
+
module Helpers
|
|
5
|
+
# @api private
|
|
6
|
+
#
|
|
7
|
+
# Core polling logic for checkout intents. Extracted from the resource class
|
|
8
|
+
# to keep the Stainless-generated file free of custom implementation details.
|
|
9
|
+
module Polling
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
# @return [Float]
|
|
13
|
+
DEFAULT_POLL_INTERVAL = 5.0
|
|
14
|
+
|
|
15
|
+
# @return [Integer]
|
|
16
|
+
DEFAULT_MAX_ATTEMPTS = 120
|
|
17
|
+
|
|
18
|
+
# @return [Proc]
|
|
19
|
+
COMPLETED = ->(intent) { [:completed, :failed].include?(intent.state) }
|
|
20
|
+
|
|
21
|
+
# @return [Proc]
|
|
22
|
+
AWAITING_CONFIRMATION = ->(intent) { [:awaiting_confirmation, :failed].include?(intent.state) }
|
|
23
|
+
|
|
24
|
+
# Poll a checkout intent until the given condition is met.
|
|
25
|
+
#
|
|
26
|
+
# @param client [::CheckoutIntents::Client] The API client instance
|
|
27
|
+
# @param id [String] The checkout intent ID to poll
|
|
28
|
+
# @param condition [Proc] A callable that receives the intent and returns true when polling should stop
|
|
29
|
+
# @param poll_interval [Float] Seconds between polling attempts
|
|
30
|
+
# @param max_attempts [Integer] Maximum number of polling attempts
|
|
31
|
+
# @param request_options [Hash{Symbol=>Object}, nil] Additional request options
|
|
32
|
+
#
|
|
33
|
+
# @return [::CheckoutIntents::Models::CheckoutIntent]
|
|
34
|
+
#
|
|
35
|
+
# @raise [::CheckoutIntents::Errors::PollTimeoutError] If max attempts reached without the condition being met
|
|
36
|
+
def poll_until(client, id, condition, poll_interval:, max_attempts:, request_options:)
|
|
37
|
+
if max_attempts < 1
|
|
38
|
+
warn(
|
|
39
|
+
"[Checkout Intents SDK] Invalid max_attempts value: #{max_attempts}. " \
|
|
40
|
+
"max_attempts must be >= 1. Defaulting to 1."
|
|
41
|
+
)
|
|
42
|
+
max_attempts = 1
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
attempts = 0
|
|
46
|
+
poll_headers = {
|
|
47
|
+
"x-stainless-poll-helper" => "true",
|
|
48
|
+
"x-stainless-custom-poll-interval" => (poll_interval * 1000).to_i.to_s
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
merged_options = (request_options || {}).merge(
|
|
52
|
+
extra_headers: ((request_options || {})[:extra_headers] || {}).merge(poll_headers)
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
while attempts < max_attempts
|
|
56
|
+
result = client.request_with_headers(
|
|
57
|
+
method: :get,
|
|
58
|
+
path: ["api/v1/checkout-intents/%1$s", id],
|
|
59
|
+
model: ::CheckoutIntents::CheckoutIntent,
|
|
60
|
+
options: merged_options
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
intent = result[:data]
|
|
64
|
+
headers = result[:headers]
|
|
65
|
+
|
|
66
|
+
return intent if condition.call(intent)
|
|
67
|
+
|
|
68
|
+
attempts += 1
|
|
69
|
+
|
|
70
|
+
if attempts >= max_attempts
|
|
71
|
+
raise ::CheckoutIntents::Errors::PollTimeoutError.new(
|
|
72
|
+
intent_id: id,
|
|
73
|
+
attempts: attempts,
|
|
74
|
+
poll_interval: poll_interval,
|
|
75
|
+
max_attempts: max_attempts
|
|
76
|
+
)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Check for server-suggested polling interval
|
|
80
|
+
sleep_interval = poll_interval
|
|
81
|
+
if (header_interval = headers["retry-after-ms"])
|
|
82
|
+
header_interval_ms = Integer(header_interval, exception: false)
|
|
83
|
+
sleep_interval = header_interval_ms / 1000.0 if header_interval_ms
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
sleep(sleep_interval)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -14,7 +14,7 @@ module CheckoutIntents
|
|
|
14
14
|
# puts(checkout_intent)
|
|
15
15
|
# end
|
|
16
16
|
class CursorPagination
|
|
17
|
-
include CheckoutIntents::Internal::Type::BasePage
|
|
17
|
+
include ::CheckoutIntents::Internal::Type::BasePage
|
|
18
18
|
|
|
19
19
|
# @return [Array<generic<Elem>>, nil]
|
|
20
20
|
attr_accessor :data
|
|
@@ -27,7 +27,7 @@ module CheckoutIntents
|
|
|
27
27
|
!data.to_a.empty? && (!page_info&.start_cursor.to_s.empty? || !page_info&.end_cursor.to_s.empty?)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
# @raise [CheckoutIntents::HTTP::Error]
|
|
30
|
+
# @raise [::CheckoutIntents::HTTP::Error]
|
|
31
31
|
# @return [self]
|
|
32
32
|
def next_page
|
|
33
33
|
unless next_page?
|
|
@@ -35,7 +35,7 @@ module CheckoutIntents
|
|
|
35
35
|
raise RuntimeError.new(message)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
req = CheckoutIntents::Internal::Util.deep_merge(
|
|
38
|
+
req = ::CheckoutIntents::Internal::Util.deep_merge(
|
|
39
39
|
@req,
|
|
40
40
|
{query: page_info&.start_cursor.nil? ? {after: page_info&.end_cursor} : {before: page_info&.start_cursor}}
|
|
41
41
|
)
|
|
@@ -61,7 +61,7 @@ module CheckoutIntents
|
|
|
61
61
|
|
|
62
62
|
# @api private
|
|
63
63
|
#
|
|
64
|
-
# @param client [CheckoutIntents::Internal::Transport::BaseClient]
|
|
64
|
+
# @param client [::CheckoutIntents::Internal::Transport::BaseClient]
|
|
65
65
|
# @param req [Hash{Symbol=>Object}]
|
|
66
66
|
# @param headers [Hash{String=>String}]
|
|
67
67
|
# @param page_data [Hash{Symbol=>Object}]
|
|
@@ -70,14 +70,14 @@ module CheckoutIntents
|
|
|
70
70
|
|
|
71
71
|
case page_data
|
|
72
72
|
in {data: Array => data}
|
|
73
|
-
@data = data.map { CheckoutIntents::Internal::Type::Converter.coerce(@model, _1) }
|
|
73
|
+
@data = data.map { ::CheckoutIntents::Internal::Type::Converter.coerce(@model, _1) }
|
|
74
74
|
else
|
|
75
75
|
end
|
|
76
76
|
case page_data
|
|
77
77
|
in {pageInfo: Hash | nil => page_info}
|
|
78
78
|
@page_info =
|
|
79
|
-
CheckoutIntents::Internal::Type::Converter.coerce(
|
|
80
|
-
CheckoutIntents::Internal::CursorPagination::PageInfo,
|
|
79
|
+
::CheckoutIntents::Internal::Type::Converter.coerce(
|
|
80
|
+
::CheckoutIntents::Internal::CursorPagination::PageInfo,
|
|
81
81
|
page_info
|
|
82
82
|
)
|
|
83
83
|
else
|
|
@@ -88,12 +88,12 @@ module CheckoutIntents
|
|
|
88
88
|
#
|
|
89
89
|
# @return [String]
|
|
90
90
|
def inspect
|
|
91
|
-
model = CheckoutIntents::Internal::Type::Converter.inspect(@model, depth: 1)
|
|
91
|
+
model = ::CheckoutIntents::Internal::Type::Converter.inspect(@model, depth: 1)
|
|
92
92
|
|
|
93
93
|
"#<#{self.class}[#{model}]:0x#{object_id.to_s(16)}>"
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
-
class PageInfo < CheckoutIntents::Internal::Type::BaseModel
|
|
96
|
+
class PageInfo < ::CheckoutIntents::Internal::Type::BaseModel
|
|
97
97
|
# @!attribute end_cursor
|
|
98
98
|
#
|
|
99
99
|
# @return [String, nil]
|
|
@@ -102,12 +102,12 @@ module CheckoutIntents
|
|
|
102
102
|
# @!attribute has_next_page
|
|
103
103
|
#
|
|
104
104
|
# @return [Boolean, nil]
|
|
105
|
-
optional :has_next_page, CheckoutIntents::Internal::Type::Boolean, api_name: :hasNextPage
|
|
105
|
+
optional :has_next_page, ::CheckoutIntents::Internal::Type::Boolean, api_name: :hasNextPage
|
|
106
106
|
|
|
107
107
|
# @!attribute has_previous_page
|
|
108
108
|
#
|
|
109
109
|
# @return [Boolean, nil]
|
|
110
|
-
optional :has_previous_page, CheckoutIntents::Internal::Type::Boolean, api_name: :hasPreviousPage
|
|
110
|
+
optional :has_previous_page, ::CheckoutIntents::Internal::Type::Boolean, api_name: :hasPreviousPage
|
|
111
111
|
|
|
112
112
|
# @!attribute start_cursor
|
|
113
113
|
#
|