checkout-intents 0.2.1 → 0.3.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 +33 -0
- data/README.md +27 -1
- data/lib/checkout_intents/client.rb +10 -2
- data/lib/checkout_intents/internal/type/enum.rb +25 -0
- data/lib/checkout_intents/models/base_checkout_intent.rb +40 -1
- data/lib/checkout_intents/models/betas/checkout_session_create_params.rb +43 -1
- data/lib/checkout_intents/models/checkout_intent_create_params.rb +41 -1
- data/lib/checkout_intents/models/checkout_intent_purchase_params.rb +43 -1
- data/lib/checkout_intents/models/money.rb +3 -3
- data/lib/checkout_intents/models/product.rb +82 -0
- data/lib/checkout_intents/models/product_availability.rb +25 -0
- data/lib/checkout_intents/models/product_image.rb +21 -0
- data/lib/checkout_intents/models/product_lookup_params.rb +20 -0
- data/lib/checkout_intents/models.rb +8 -0
- data/lib/checkout_intents/resources/products.rb +35 -0
- data/lib/checkout_intents/version.rb +1 -1
- data/lib/checkout_intents.rb +5 -0
- data/rbi/checkout_intents/client.rbi +7 -2
- data/rbi/checkout_intents/internal/transport/base_client.rbi +2 -1
- data/rbi/checkout_intents/models/base_checkout_intent.rbi +89 -5
- data/rbi/checkout_intents/models/betas/checkout_session_create_params.rbi +87 -4
- data/rbi/checkout_intents/models/checkout_intent_create_params.rbi +89 -5
- data/rbi/checkout_intents/models/checkout_intent_purchase_params.rbi +89 -5
- data/rbi/checkout_intents/models/money.rbi +3 -3
- data/rbi/checkout_intents/models/product.rbi +100 -0
- data/rbi/checkout_intents/models/product_availability.rbi +39 -0
- data/rbi/checkout_intents/models/product_image.rbi +31 -0
- data/rbi/checkout_intents/models/product_lookup_params.rbi +38 -0
- data/rbi/checkout_intents/models.rbi +8 -0
- data/rbi/checkout_intents/resources/betas.rbi +3 -1
- data/rbi/checkout_intents/resources/brands.rbi +3 -1
- data/rbi/checkout_intents/resources/checkout_intents.rbi +3 -1
- data/rbi/checkout_intents/resources/products.rbi +24 -0
- data/sig/checkout_intents/client.rbs +4 -1
- data/sig/checkout_intents/models/base_checkout_intent.rbs +26 -3
- data/sig/checkout_intents/models/betas/checkout_session_create_params.rbs +26 -3
- data/sig/checkout_intents/models/checkout_intent_create_params.rbs +26 -3
- data/sig/checkout_intents/models/checkout_intent_purchase_params.rbs +26 -3
- data/sig/checkout_intents/models/money.rbs +4 -4
- data/sig/checkout_intents/models/product.rbs +60 -0
- data/sig/checkout_intents/models/product_availability.rbs +18 -0
- data/sig/checkout_intents/models/product_image.rbs +15 -0
- data/sig/checkout_intents/models/product_lookup_params.rbs +23 -0
- data/sig/checkout_intents/models.rbs +8 -0
- data/sig/checkout_intents/resources/checkout_intents.rbs +8 -4
- data/sig/checkout_intents/resources/products.rbs +12 -0
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bda63c599b8cd83771abe42c287a04c4ad82c5d4f0786fd3709de9c5170845b6
|
|
4
|
+
data.tar.gz: 7b984e686cc00fb3ab287cc07ae8dec14c3f9ff6a56210d7638e0952691b2c4c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac453b93ad2940abf04156c8f80111558b0dc4fa9caeb64a52e97a721c057519b3c5bb6a61fca0ef5d58dd3f65c1fb00e25e0f03447d83c5245fca24e54886d9
|
|
7
|
+
data.tar.gz: 3f70463b0132c2c69e35b20ff4a8488d51afafc9c439dd01c91238f24f9cd904b032e4f834e81b38cce83c6dfaf85aa36846cd2586ec3ca74735e2c93356570e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 (2026-01-30)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.2.2...v0.3.0](https://github.com/rye-com/checkout-intents-ruby/compare/v0.2.2...v0.3.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* add support for idempotency for v2 api ([b94de41](https://github.com/rye-com/checkout-intents-ruby/commit/b94de413ad3cfd4a5a552d2719203f060414d228))
|
|
10
|
+
* **api:** introduce lookup product data endpoint ([f4edc38](https://github.com/rye-com/checkout-intents-ruby/commit/f4edc38289d432cbc3f87497274c0798bd88b7ee))
|
|
11
|
+
* **api:** introduce offerRetrievalEffort constraint ([0d38c14](https://github.com/rye-com/checkout-intents-ruby/commit/0d38c1491c570ae1c8164ed001eb803d600d8bf1))
|
|
12
|
+
* Implement shipping profile -> shipping option calculation ([eb0fa3a](https://github.com/rye-com/checkout-intents-ruby/commit/eb0fa3a0c180fbbc616032f02bb303a154d41cb0))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **internal:** transformer script to fix references ([8481675](https://github.com/rye-com/checkout-intents-ruby/commit/8481675e295bbfa698b9edb93af9d2c99cd840db))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Chores
|
|
21
|
+
|
|
22
|
+
* **internal:** add format step in ci ([ad0d359](https://github.com/rye-com/checkout-intents-ruby/commit/ad0d3594d6b4f92df889e645434dbc5310802216))
|
|
23
|
+
* **internal:** format and fix absolute references ([2509f6a](https://github.com/rye-com/checkout-intents-ruby/commit/2509f6af145d3b586fbbde14e94697975d15653c))
|
|
24
|
+
* **internal:** format and fix absolute references ([09920e1](https://github.com/rye-com/checkout-intents-ruby/commit/09920e1eef0dc90eb8a0999d9fbcce0b0e12de72))
|
|
25
|
+
* **internal:** rename `Product` type ([fdadda4](https://github.com/rye-com/checkout-intents-ruby/commit/fdadda4eefc867d5492376e23b25138c263c0811))
|
|
26
|
+
* **internal:** update `actions/checkout` version ([00c3bfa](https://github.com/rye-com/checkout-intents-ruby/commit/00c3bfa75b4fd0d01e040070e37a4e72396ea230))
|
|
27
|
+
|
|
28
|
+
## 0.2.2 (2026-01-15)
|
|
29
|
+
|
|
30
|
+
Full Changelog: [v0.2.1...v0.2.2](https://github.com/rye-com/checkout-intents-ruby/compare/v0.2.1...v0.2.2)
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* **api:** correctly type quantity as integer ([a85ecbf](https://github.com/rye-com/checkout-intents-ruby/commit/a85ecbf160c0cc4b24dc62357aa5bf47e7f7932a))
|
|
35
|
+
|
|
3
36
|
## 0.2.1 (2026-01-13)
|
|
4
37
|
|
|
5
38
|
Full Changelog: [v0.2.0...v0.2.1](https://github.com/rye-com/checkout-intents-ruby/compare/v0.2.0...v0.2.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.3.0"
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
<!-- x-release-please-end -->
|
|
@@ -422,6 +422,32 @@ params = CheckoutIntents::CheckoutIntentPurchaseParams.new(
|
|
|
422
422
|
checkout_intents.checkout_intents.purchase(**params)
|
|
423
423
|
```
|
|
424
424
|
|
|
425
|
+
### Enums
|
|
426
|
+
|
|
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
|
+
|
|
429
|
+
```ruby
|
|
430
|
+
# :in_stock
|
|
431
|
+
puts(CheckoutIntents::ProductAvailability::IN_STOCK)
|
|
432
|
+
|
|
433
|
+
# Revealed type: `T.all(CheckoutIntents::ProductAvailability, Symbol)`
|
|
434
|
+
T.reveal_type(CheckoutIntents::ProductAvailability::IN_STOCK)
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:
|
|
438
|
+
|
|
439
|
+
```ruby
|
|
440
|
+
CheckoutIntents::Product.new(
|
|
441
|
+
availability: CheckoutIntents::ProductAvailability::IN_STOCK,
|
|
442
|
+
# …
|
|
443
|
+
)
|
|
444
|
+
|
|
445
|
+
CheckoutIntents::Product.new(
|
|
446
|
+
availability: :in_stock,
|
|
447
|
+
# …
|
|
448
|
+
)
|
|
449
|
+
```
|
|
450
|
+
|
|
425
451
|
## Versioning
|
|
426
452
|
|
|
427
453
|
This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.
|
|
@@ -33,6 +33,9 @@ module CheckoutIntents
|
|
|
33
33
|
# @return [CheckoutIntents::Resources::Brands]
|
|
34
34
|
attr_reader :brands
|
|
35
35
|
|
|
36
|
+
# @return [CheckoutIntents::Resources::Products]
|
|
37
|
+
attr_reader :products
|
|
38
|
+
|
|
36
39
|
# @api private
|
|
37
40
|
#
|
|
38
41
|
# @return [Hash{String=>String}]
|
|
@@ -77,6 +80,8 @@ module CheckoutIntents
|
|
|
77
80
|
# @param initial_retry_delay [Float]
|
|
78
81
|
#
|
|
79
82
|
# @param max_retry_delay [Float]
|
|
83
|
+
#
|
|
84
|
+
# @param idempotency_header [String]
|
|
80
85
|
def initialize(
|
|
81
86
|
api_key: ENV["CHECKOUT_INTENTS_API_KEY"],
|
|
82
87
|
environment: nil,
|
|
@@ -84,7 +89,8 @@ module CheckoutIntents
|
|
|
84
89
|
max_retries: self.class::DEFAULT_MAX_RETRIES,
|
|
85
90
|
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
|
|
86
91
|
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
|
|
87
|
-
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
|
|
92
|
+
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY,
|
|
93
|
+
idempotency_header: "Idempotency-Key"
|
|
88
94
|
)
|
|
89
95
|
if api_key.nil?
|
|
90
96
|
raise ArgumentError.new("api_key is required, and can be set via environ: \"CHECKOUT_INTENTS_API_KEY\"")
|
|
@@ -118,12 +124,14 @@ module CheckoutIntents
|
|
|
118
124
|
timeout: timeout,
|
|
119
125
|
max_retries: max_retries,
|
|
120
126
|
initial_retry_delay: initial_retry_delay,
|
|
121
|
-
max_retry_delay: max_retry_delay
|
|
127
|
+
max_retry_delay: max_retry_delay,
|
|
128
|
+
idempotency_header: idempotency_header
|
|
122
129
|
)
|
|
123
130
|
|
|
124
131
|
@checkout_intents = CheckoutIntents::Resources::CheckoutIntents.new(client: self)
|
|
125
132
|
@betas = CheckoutIntents::Resources::Betas.new(client: self)
|
|
126
133
|
@brands = CheckoutIntents::Resources::Brands.new(client: self)
|
|
134
|
+
@products = CheckoutIntents::Resources::Products.new(client: self)
|
|
127
135
|
end
|
|
128
136
|
end
|
|
129
137
|
end
|
|
@@ -15,6 +15,31 @@ module CheckoutIntents
|
|
|
15
15
|
#
|
|
16
16
|
# We can therefore convert string values to Symbols, but can't convert other
|
|
17
17
|
# values safely.
|
|
18
|
+
#
|
|
19
|
+
# @example
|
|
20
|
+
# # `product_availability` is a `CheckoutIntents::ProductAvailability`
|
|
21
|
+
# case product_availability
|
|
22
|
+
# when CheckoutIntents::ProductAvailability::IN_STOCK
|
|
23
|
+
# # ...
|
|
24
|
+
# when CheckoutIntents::ProductAvailability::OUT_OF_STOCK
|
|
25
|
+
# # ...
|
|
26
|
+
# when CheckoutIntents::ProductAvailability::PREORDER
|
|
27
|
+
# # ...
|
|
28
|
+
# else
|
|
29
|
+
# puts(product_availability)
|
|
30
|
+
# end
|
|
31
|
+
#
|
|
32
|
+
# @example
|
|
33
|
+
# case product_availability
|
|
34
|
+
# in :in_stock
|
|
35
|
+
# # ...
|
|
36
|
+
# in :out_of_stock
|
|
37
|
+
# # ...
|
|
38
|
+
# in :preorder
|
|
39
|
+
# # ...
|
|
40
|
+
# else
|
|
41
|
+
# puts(product_availability)
|
|
42
|
+
# end
|
|
18
43
|
module Enum
|
|
19
44
|
include CheckoutIntents::Internal::Type::Converter
|
|
20
45
|
include CheckoutIntents::Internal::Util::SorbetRuntimeSupport
|
|
@@ -67,9 +67,48 @@ module CheckoutIntents
|
|
|
67
67
|
# @return [Integer, nil]
|
|
68
68
|
optional :max_total_price, Integer, api_name: :maxTotalPrice
|
|
69
69
|
|
|
70
|
-
# @!
|
|
70
|
+
# @!attribute offer_retrieval_effort
|
|
71
|
+
# Controls how much effort the system should spend retrieving an offer.
|
|
72
|
+
#
|
|
73
|
+
# - 'max': Full effort including AI agent fallback (slower, higher success rate)
|
|
74
|
+
# - 'low': Fast API-only retrieval, fails if API unavailable (faster, lower
|
|
75
|
+
# success rate)
|
|
76
|
+
#
|
|
77
|
+
# Default: 'max'
|
|
78
|
+
#
|
|
79
|
+
# @return [Symbol, CheckoutIntents::Models::BaseCheckoutIntent::Constraints::OfferRetrievalEffort, nil]
|
|
80
|
+
optional :offer_retrieval_effort,
|
|
81
|
+
enum: -> { CheckoutIntents::BaseCheckoutIntent::Constraints::OfferRetrievalEffort },
|
|
82
|
+
api_name: :offerRetrievalEffort
|
|
83
|
+
|
|
84
|
+
# @!method initialize(max_shipping_price: nil, max_total_price: nil, offer_retrieval_effort: nil)
|
|
85
|
+
# Some parameter documentations has been truncated, see
|
|
86
|
+
# {CheckoutIntents::Models::BaseCheckoutIntent::Constraints} for more details.
|
|
87
|
+
#
|
|
71
88
|
# @param max_shipping_price [Integer]
|
|
89
|
+
#
|
|
72
90
|
# @param max_total_price [Integer]
|
|
91
|
+
#
|
|
92
|
+
# @param offer_retrieval_effort [Symbol, CheckoutIntents::Models::BaseCheckoutIntent::Constraints::OfferRetrievalEffort] Controls how much effort the system should spend retrieving an offer.
|
|
93
|
+
|
|
94
|
+
# Controls how much effort the system should spend retrieving an offer.
|
|
95
|
+
#
|
|
96
|
+
# - 'max': Full effort including AI agent fallback (slower, higher success rate)
|
|
97
|
+
# - 'low': Fast API-only retrieval, fails if API unavailable (faster, lower
|
|
98
|
+
# success rate)
|
|
99
|
+
#
|
|
100
|
+
# Default: 'max'
|
|
101
|
+
#
|
|
102
|
+
# @see CheckoutIntents::Models::BaseCheckoutIntent::Constraints#offer_retrieval_effort
|
|
103
|
+
module OfferRetrievalEffort
|
|
104
|
+
extend CheckoutIntents::Internal::Type::Enum
|
|
105
|
+
|
|
106
|
+
MAX = :max
|
|
107
|
+
LOW = :low
|
|
108
|
+
|
|
109
|
+
# @!method self.values
|
|
110
|
+
# @return [Array<Symbol>]
|
|
111
|
+
end
|
|
73
112
|
end
|
|
74
113
|
end
|
|
75
114
|
end
|
|
@@ -138,9 +138,51 @@ module CheckoutIntents
|
|
|
138
138
|
# @return [Integer, nil]
|
|
139
139
|
optional :max_total_price, Integer, api_name: :maxTotalPrice
|
|
140
140
|
|
|
141
|
-
# @!
|
|
141
|
+
# @!attribute offer_retrieval_effort
|
|
142
|
+
# Controls how much effort the system should spend retrieving an offer.
|
|
143
|
+
#
|
|
144
|
+
# - 'max': Full effort including AI agent fallback (slower, higher success rate)
|
|
145
|
+
# - 'low': Fast API-only retrieval, fails if API unavailable (faster, lower
|
|
146
|
+
# success rate)
|
|
147
|
+
#
|
|
148
|
+
# Default: 'max'
|
|
149
|
+
#
|
|
150
|
+
# @return [Symbol, CheckoutIntents::Models::Betas::CheckoutSessionCreateParams::Constraints::OfferRetrievalEffort, nil]
|
|
151
|
+
optional :offer_retrieval_effort,
|
|
152
|
+
enum: -> {
|
|
153
|
+
CheckoutIntents::Betas::CheckoutSessionCreateParams::Constraints::OfferRetrievalEffort
|
|
154
|
+
},
|
|
155
|
+
api_name: :offerRetrievalEffort
|
|
156
|
+
|
|
157
|
+
# @!method initialize(max_shipping_price: nil, max_total_price: nil, offer_retrieval_effort: nil)
|
|
158
|
+
# Some parameter documentations has been truncated, see
|
|
159
|
+
# {CheckoutIntents::Models::Betas::CheckoutSessionCreateParams::Constraints} for
|
|
160
|
+
# more details.
|
|
161
|
+
#
|
|
142
162
|
# @param max_shipping_price [Integer]
|
|
163
|
+
#
|
|
143
164
|
# @param max_total_price [Integer]
|
|
165
|
+
#
|
|
166
|
+
# @param offer_retrieval_effort [Symbol, CheckoutIntents::Models::Betas::CheckoutSessionCreateParams::Constraints::OfferRetrievalEffort] Controls how much effort the system should spend retrieving an offer.
|
|
167
|
+
|
|
168
|
+
# Controls how much effort the system should spend retrieving an offer.
|
|
169
|
+
#
|
|
170
|
+
# - 'max': Full effort including AI agent fallback (slower, higher success rate)
|
|
171
|
+
# - 'low': Fast API-only retrieval, fails if API unavailable (faster, lower
|
|
172
|
+
# success rate)
|
|
173
|
+
#
|
|
174
|
+
# Default: 'max'
|
|
175
|
+
#
|
|
176
|
+
# @see CheckoutIntents::Models::Betas::CheckoutSessionCreateParams::Constraints#offer_retrieval_effort
|
|
177
|
+
module OfferRetrievalEffort
|
|
178
|
+
extend CheckoutIntents::Internal::Type::Enum
|
|
179
|
+
|
|
180
|
+
MAX = :max
|
|
181
|
+
LOW = :low
|
|
182
|
+
|
|
183
|
+
# @!method self.values
|
|
184
|
+
# @return [Array<Symbol>]
|
|
185
|
+
end
|
|
144
186
|
end
|
|
145
187
|
end
|
|
146
188
|
end
|
|
@@ -59,9 +59,49 @@ module CheckoutIntents
|
|
|
59
59
|
# @return [Integer, nil]
|
|
60
60
|
optional :max_total_price, Integer, api_name: :maxTotalPrice
|
|
61
61
|
|
|
62
|
-
# @!
|
|
62
|
+
# @!attribute offer_retrieval_effort
|
|
63
|
+
# Controls how much effort the system should spend retrieving an offer.
|
|
64
|
+
#
|
|
65
|
+
# - 'max': Full effort including AI agent fallback (slower, higher success rate)
|
|
66
|
+
# - 'low': Fast API-only retrieval, fails if API unavailable (faster, lower
|
|
67
|
+
# success rate)
|
|
68
|
+
#
|
|
69
|
+
# Default: 'max'
|
|
70
|
+
#
|
|
71
|
+
# @return [Symbol, CheckoutIntents::Models::CheckoutIntentCreateParams::Constraints::OfferRetrievalEffort, nil]
|
|
72
|
+
optional :offer_retrieval_effort,
|
|
73
|
+
enum: -> { CheckoutIntents::CheckoutIntentCreateParams::Constraints::OfferRetrievalEffort },
|
|
74
|
+
api_name: :offerRetrievalEffort
|
|
75
|
+
|
|
76
|
+
# @!method initialize(max_shipping_price: nil, max_total_price: nil, offer_retrieval_effort: nil)
|
|
77
|
+
# Some parameter documentations has been truncated, see
|
|
78
|
+
# {CheckoutIntents::Models::CheckoutIntentCreateParams::Constraints} for more
|
|
79
|
+
# details.
|
|
80
|
+
#
|
|
63
81
|
# @param max_shipping_price [Integer]
|
|
82
|
+
#
|
|
64
83
|
# @param max_total_price [Integer]
|
|
84
|
+
#
|
|
85
|
+
# @param offer_retrieval_effort [Symbol, CheckoutIntents::Models::CheckoutIntentCreateParams::Constraints::OfferRetrievalEffort] Controls how much effort the system should spend retrieving an offer.
|
|
86
|
+
|
|
87
|
+
# Controls how much effort the system should spend retrieving an offer.
|
|
88
|
+
#
|
|
89
|
+
# - 'max': Full effort including AI agent fallback (slower, higher success rate)
|
|
90
|
+
# - 'low': Fast API-only retrieval, fails if API unavailable (faster, lower
|
|
91
|
+
# success rate)
|
|
92
|
+
#
|
|
93
|
+
# Default: 'max'
|
|
94
|
+
#
|
|
95
|
+
# @see CheckoutIntents::Models::CheckoutIntentCreateParams::Constraints#offer_retrieval_effort
|
|
96
|
+
module OfferRetrievalEffort
|
|
97
|
+
extend CheckoutIntents::Internal::Type::Enum
|
|
98
|
+
|
|
99
|
+
MAX = :max
|
|
100
|
+
LOW = :low
|
|
101
|
+
|
|
102
|
+
# @!method self.values
|
|
103
|
+
# @return [Array<Symbol>]
|
|
104
|
+
end
|
|
65
105
|
end
|
|
66
106
|
end
|
|
67
107
|
end
|
|
@@ -65,9 +65,51 @@ module CheckoutIntents
|
|
|
65
65
|
# @return [Integer, nil]
|
|
66
66
|
optional :max_total_price, Integer, api_name: :maxTotalPrice
|
|
67
67
|
|
|
68
|
-
# @!
|
|
68
|
+
# @!attribute offer_retrieval_effort
|
|
69
|
+
# Controls how much effort the system should spend retrieving an offer.
|
|
70
|
+
#
|
|
71
|
+
# - 'max': Full effort including AI agent fallback (slower, higher success rate)
|
|
72
|
+
# - 'low': Fast API-only retrieval, fails if API unavailable (faster, lower
|
|
73
|
+
# success rate)
|
|
74
|
+
#
|
|
75
|
+
# Default: 'max'
|
|
76
|
+
#
|
|
77
|
+
# @return [Symbol, CheckoutIntents::Models::CheckoutIntentPurchaseParams::Constraints::OfferRetrievalEffort, nil]
|
|
78
|
+
optional :offer_retrieval_effort,
|
|
79
|
+
enum: -> {
|
|
80
|
+
CheckoutIntents::CheckoutIntentPurchaseParams::Constraints::OfferRetrievalEffort
|
|
81
|
+
},
|
|
82
|
+
api_name: :offerRetrievalEffort
|
|
83
|
+
|
|
84
|
+
# @!method initialize(max_shipping_price: nil, max_total_price: nil, offer_retrieval_effort: nil)
|
|
85
|
+
# Some parameter documentations has been truncated, see
|
|
86
|
+
# {CheckoutIntents::Models::CheckoutIntentPurchaseParams::Constraints} for more
|
|
87
|
+
# details.
|
|
88
|
+
#
|
|
69
89
|
# @param max_shipping_price [Integer]
|
|
90
|
+
#
|
|
70
91
|
# @param max_total_price [Integer]
|
|
92
|
+
#
|
|
93
|
+
# @param offer_retrieval_effort [Symbol, CheckoutIntents::Models::CheckoutIntentPurchaseParams::Constraints::OfferRetrievalEffort] Controls how much effort the system should spend retrieving an offer.
|
|
94
|
+
|
|
95
|
+
# Controls how much effort the system should spend retrieving an offer.
|
|
96
|
+
#
|
|
97
|
+
# - 'max': Full effort including AI agent fallback (slower, higher success rate)
|
|
98
|
+
# - 'low': Fast API-only retrieval, fails if API unavailable (faster, lower
|
|
99
|
+
# success rate)
|
|
100
|
+
#
|
|
101
|
+
# Default: 'max'
|
|
102
|
+
#
|
|
103
|
+
# @see CheckoutIntents::Models::CheckoutIntentPurchaseParams::Constraints#offer_retrieval_effort
|
|
104
|
+
module OfferRetrievalEffort
|
|
105
|
+
extend CheckoutIntents::Internal::Type::Enum
|
|
106
|
+
|
|
107
|
+
MAX = :max
|
|
108
|
+
LOW = :low
|
|
109
|
+
|
|
110
|
+
# @!method self.values
|
|
111
|
+
# @return [Array<Symbol>]
|
|
112
|
+
end
|
|
71
113
|
end
|
|
72
114
|
end
|
|
73
115
|
end
|
|
@@ -5,8 +5,8 @@ module CheckoutIntents
|
|
|
5
5
|
class Money < CheckoutIntents::Internal::Type::BaseModel
|
|
6
6
|
# @!attribute amount_subunits
|
|
7
7
|
#
|
|
8
|
-
# @return [
|
|
9
|
-
required :amount_subunits,
|
|
8
|
+
# @return [Integer]
|
|
9
|
+
required :amount_subunits, Integer, api_name: :amountSubunits
|
|
10
10
|
|
|
11
11
|
# @!attribute currency_code
|
|
12
12
|
#
|
|
@@ -14,7 +14,7 @@ module CheckoutIntents
|
|
|
14
14
|
required :currency_code, String, api_name: :currencyCode
|
|
15
15
|
|
|
16
16
|
# @!method initialize(amount_subunits:, currency_code:)
|
|
17
|
-
# @param amount_subunits [
|
|
17
|
+
# @param amount_subunits [Integer]
|
|
18
18
|
# @param currency_code [String]
|
|
19
19
|
end
|
|
20
20
|
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CheckoutIntents
|
|
4
|
+
module Models
|
|
5
|
+
# @see CheckoutIntents::Resources::Products#lookup
|
|
6
|
+
class Product < CheckoutIntents::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute id
|
|
8
|
+
#
|
|
9
|
+
# @return [String]
|
|
10
|
+
required :id, String
|
|
11
|
+
|
|
12
|
+
# @!attribute availability
|
|
13
|
+
# The availability status of a product.
|
|
14
|
+
#
|
|
15
|
+
# - `in_stock`: Product is available for immediate purchase
|
|
16
|
+
# - `out_of_stock`: Product is currently unavailable
|
|
17
|
+
# - `preorder`: Product is available for pre-order before release
|
|
18
|
+
# - `backorder`: Product is temporarily out of stock but can be ordered
|
|
19
|
+
# - `unknown`: Availability could not be determined
|
|
20
|
+
#
|
|
21
|
+
# @return [Symbol, CheckoutIntents::Models::ProductAvailability]
|
|
22
|
+
required :availability, enum: -> { CheckoutIntents::ProductAvailability }
|
|
23
|
+
|
|
24
|
+
# @!attribute brand
|
|
25
|
+
#
|
|
26
|
+
# @return [String, nil]
|
|
27
|
+
required :brand, String, nil?: true
|
|
28
|
+
|
|
29
|
+
# @!attribute description
|
|
30
|
+
#
|
|
31
|
+
# @return [String, nil]
|
|
32
|
+
required :description, String, nil?: true
|
|
33
|
+
|
|
34
|
+
# @!attribute images
|
|
35
|
+
#
|
|
36
|
+
# @return [Array<CheckoutIntents::Models::ProductImage>]
|
|
37
|
+
required :images, -> { CheckoutIntents::Internal::Type::ArrayOf[CheckoutIntents::ProductImage] }
|
|
38
|
+
|
|
39
|
+
# @!attribute name
|
|
40
|
+
#
|
|
41
|
+
# @return [String]
|
|
42
|
+
required :name, String
|
|
43
|
+
|
|
44
|
+
# @!attribute price
|
|
45
|
+
#
|
|
46
|
+
# @return [CheckoutIntents::Models::Money]
|
|
47
|
+
required :price, -> { CheckoutIntents::Money }
|
|
48
|
+
|
|
49
|
+
# @!attribute sku
|
|
50
|
+
#
|
|
51
|
+
# @return [String, nil]
|
|
52
|
+
required :sku, String, nil?: true
|
|
53
|
+
|
|
54
|
+
# @!attribute url
|
|
55
|
+
#
|
|
56
|
+
# @return [String]
|
|
57
|
+
required :url, String
|
|
58
|
+
|
|
59
|
+
# @!method initialize(id:, availability:, brand:, description:, images:, name:, price:, sku:, url:)
|
|
60
|
+
# Some parameter documentations has been truncated, see
|
|
61
|
+
# {CheckoutIntents::Models::Product} for more details.
|
|
62
|
+
#
|
|
63
|
+
# @param id [String]
|
|
64
|
+
#
|
|
65
|
+
# @param availability [Symbol, CheckoutIntents::Models::ProductAvailability] The availability status of a product.
|
|
66
|
+
#
|
|
67
|
+
# @param brand [String, nil]
|
|
68
|
+
#
|
|
69
|
+
# @param description [String, nil]
|
|
70
|
+
#
|
|
71
|
+
# @param images [Array<CheckoutIntents::Models::ProductImage>]
|
|
72
|
+
#
|
|
73
|
+
# @param name [String]
|
|
74
|
+
#
|
|
75
|
+
# @param price [CheckoutIntents::Models::Money]
|
|
76
|
+
#
|
|
77
|
+
# @param sku [String, nil]
|
|
78
|
+
#
|
|
79
|
+
# @param url [String]
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CheckoutIntents
|
|
4
|
+
module Models
|
|
5
|
+
# The availability status of a product.
|
|
6
|
+
#
|
|
7
|
+
# - `in_stock`: Product is available for immediate purchase
|
|
8
|
+
# - `out_of_stock`: Product is currently unavailable
|
|
9
|
+
# - `preorder`: Product is available for pre-order before release
|
|
10
|
+
# - `backorder`: Product is temporarily out of stock but can be ordered
|
|
11
|
+
# - `unknown`: Availability could not be determined
|
|
12
|
+
module ProductAvailability
|
|
13
|
+
extend CheckoutIntents::Internal::Type::Enum
|
|
14
|
+
|
|
15
|
+
IN_STOCK = :in_stock
|
|
16
|
+
OUT_OF_STOCK = :out_of_stock
|
|
17
|
+
PREORDER = :preorder
|
|
18
|
+
BACKORDER = :backorder
|
|
19
|
+
UNKNOWN = :unknown
|
|
20
|
+
|
|
21
|
+
# @!method self.values
|
|
22
|
+
# @return [Array<Symbol>]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CheckoutIntents
|
|
4
|
+
module Models
|
|
5
|
+
class ProductImage < CheckoutIntents::Internal::Type::BaseModel
|
|
6
|
+
# @!attribute is_featured
|
|
7
|
+
#
|
|
8
|
+
# @return [Boolean]
|
|
9
|
+
required :is_featured, CheckoutIntents::Internal::Type::Boolean, api_name: :isFeatured
|
|
10
|
+
|
|
11
|
+
# @!attribute url
|
|
12
|
+
#
|
|
13
|
+
# @return [String]
|
|
14
|
+
required :url, String
|
|
15
|
+
|
|
16
|
+
# @!method initialize(is_featured:, url:)
|
|
17
|
+
# @param is_featured [Boolean]
|
|
18
|
+
# @param url [String]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CheckoutIntents
|
|
4
|
+
module Models
|
|
5
|
+
# @see CheckoutIntents::Resources::Products#lookup
|
|
6
|
+
class ProductLookupParams < CheckoutIntents::Internal::Type::BaseModel
|
|
7
|
+
extend CheckoutIntents::Internal::Type::RequestParameters::Converter
|
|
8
|
+
include CheckoutIntents::Internal::Type::RequestParameters
|
|
9
|
+
|
|
10
|
+
# @!attribute url
|
|
11
|
+
#
|
|
12
|
+
# @return [String]
|
|
13
|
+
required :url, String
|
|
14
|
+
|
|
15
|
+
# @!method initialize(url:, request_options: {})
|
|
16
|
+
# @param url [String]
|
|
17
|
+
# @param request_options [CheckoutIntents::RequestOptions, Hash{Symbol=>Object}]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -72,5 +72,13 @@ module CheckoutIntents
|
|
|
72
72
|
|
|
73
73
|
PaymentMethod = CheckoutIntents::Models::PaymentMethod
|
|
74
74
|
|
|
75
|
+
Product = CheckoutIntents::Models::Product
|
|
76
|
+
|
|
77
|
+
ProductAvailability = CheckoutIntents::Models::ProductAvailability
|
|
78
|
+
|
|
79
|
+
ProductImage = CheckoutIntents::Models::ProductImage
|
|
80
|
+
|
|
81
|
+
ProductLookupParams = CheckoutIntents::Models::ProductLookupParams
|
|
82
|
+
|
|
75
83
|
VariantSelection = CheckoutIntents::Models::VariantSelection
|
|
76
84
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CheckoutIntents
|
|
4
|
+
module Resources
|
|
5
|
+
class Products
|
|
6
|
+
# Retrieve a product's information by URL.
|
|
7
|
+
#
|
|
8
|
+
# @overload lookup(url:, request_options: {})
|
|
9
|
+
#
|
|
10
|
+
# @param url [String]
|
|
11
|
+
# @param request_options [::CheckoutIntents::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
12
|
+
#
|
|
13
|
+
# @return [::CheckoutIntents::Models::Product]
|
|
14
|
+
#
|
|
15
|
+
# @see ::CheckoutIntents::Models::ProductLookupParams
|
|
16
|
+
def lookup(params)
|
|
17
|
+
parsed, options = ::CheckoutIntents::ProductLookupParams.dump_request(params)
|
|
18
|
+
@client.request(
|
|
19
|
+
method: :get,
|
|
20
|
+
path: "api/v1/products/lookup",
|
|
21
|
+
query: parsed,
|
|
22
|
+
model: ::CheckoutIntents::Product,
|
|
23
|
+
options: options
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @api private
|
|
28
|
+
#
|
|
29
|
+
# @param client [::CheckoutIntents::Client]
|
|
30
|
+
def initialize(client:)
|
|
31
|
+
@client = client
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/checkout_intents.rb
CHANGED
|
@@ -69,9 +69,14 @@ require_relative "checkout_intents/models/checkout_session"
|
|
|
69
69
|
require_relative "checkout_intents/models/money"
|
|
70
70
|
require_relative "checkout_intents/models/offer"
|
|
71
71
|
require_relative "checkout_intents/models/payment_method"
|
|
72
|
+
require_relative "checkout_intents/models/product"
|
|
73
|
+
require_relative "checkout_intents/models/product_availability"
|
|
74
|
+
require_relative "checkout_intents/models/product_image"
|
|
75
|
+
require_relative "checkout_intents/models/product_lookup_params"
|
|
72
76
|
require_relative "checkout_intents/models/variant_selection"
|
|
73
77
|
require_relative "checkout_intents/models"
|
|
74
78
|
require_relative "checkout_intents/resources/betas"
|
|
75
79
|
require_relative "checkout_intents/resources/betas/checkout_sessions"
|
|
76
80
|
require_relative "checkout_intents/resources/brands"
|
|
77
81
|
require_relative "checkout_intents/resources/checkout_intents"
|
|
82
|
+
require_relative "checkout_intents/resources/products"
|
|
@@ -32,6 +32,9 @@ module CheckoutIntents
|
|
|
32
32
|
sig { returns(CheckoutIntents::Resources::Brands) }
|
|
33
33
|
attr_reader :brands
|
|
34
34
|
|
|
35
|
+
sig { returns(CheckoutIntents::Resources::Products) }
|
|
36
|
+
attr_reader :products
|
|
37
|
+
|
|
35
38
|
# @api private
|
|
36
39
|
sig { override.returns(T::Hash[String, String]) }
|
|
37
40
|
private def auth_headers
|
|
@@ -46,7 +49,8 @@ module CheckoutIntents
|
|
|
46
49
|
max_retries: Integer,
|
|
47
50
|
timeout: Float,
|
|
48
51
|
initial_retry_delay: Float,
|
|
49
|
-
max_retry_delay: Float
|
|
52
|
+
max_retry_delay: Float,
|
|
53
|
+
idempotency_header: String
|
|
50
54
|
).returns(T.attached_class)
|
|
51
55
|
end
|
|
52
56
|
def self.new(
|
|
@@ -67,7 +71,8 @@ module CheckoutIntents
|
|
|
67
71
|
max_retries: CheckoutIntents::Client::DEFAULT_MAX_RETRIES,
|
|
68
72
|
timeout: CheckoutIntents::Client::DEFAULT_TIMEOUT_IN_SECONDS,
|
|
69
73
|
initial_retry_delay: CheckoutIntents::Client::DEFAULT_INITIAL_RETRY_DELAY,
|
|
70
|
-
max_retry_delay: CheckoutIntents::Client::DEFAULT_MAX_RETRY_DELAY
|
|
74
|
+
max_retry_delay: CheckoutIntents::Client::DEFAULT_MAX_RETRY_DELAY,
|
|
75
|
+
idempotency_header: "Idempotency-Key"
|
|
71
76
|
)
|
|
72
77
|
end
|
|
73
78
|
end
|
|
@@ -305,7 +305,8 @@ module CheckoutIntents
|
|
|
305
305
|
# Used internally for polling helpers that need to inspect headers.
|
|
306
306
|
sig do
|
|
307
307
|
params(
|
|
308
|
-
req:
|
|
308
|
+
req:
|
|
309
|
+
CheckoutIntents::Internal::Transport::BaseClient::RequestComponents
|
|
309
310
|
).returns({ data: T.anything, headers: T::Hash[String, String] })
|
|
310
311
|
end
|
|
311
312
|
def request_with_headers(req)
|