checkout-intents 0.0.2
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 +7 -0
- data/.ignore +2 -0
- data/CHANGELOG.md +16 -0
- data/README.md +358 -0
- data/SECURITY.md +27 -0
- data/lib/checkout_intents/client.rb +100 -0
- data/lib/checkout_intents/errors.rb +228 -0
- data/lib/checkout_intents/file_part.rb +58 -0
- data/lib/checkout_intents/internal/cursor_pagination.rb +125 -0
- data/lib/checkout_intents/internal/transport/base_client.rb +577 -0
- data/lib/checkout_intents/internal/transport/pooled_net_requester.rb +210 -0
- data/lib/checkout_intents/internal/type/array_of.rb +168 -0
- data/lib/checkout_intents/internal/type/base_model.rb +536 -0
- data/lib/checkout_intents/internal/type/base_page.rb +55 -0
- data/lib/checkout_intents/internal/type/boolean.rb +77 -0
- data/lib/checkout_intents/internal/type/converter.rb +327 -0
- data/lib/checkout_intents/internal/type/enum.rb +131 -0
- data/lib/checkout_intents/internal/type/file_input.rb +111 -0
- data/lib/checkout_intents/internal/type/hash_of.rb +188 -0
- data/lib/checkout_intents/internal/type/request_parameters.rb +42 -0
- data/lib/checkout_intents/internal/type/union.rb +258 -0
- data/lib/checkout_intents/internal/type/unknown.rb +81 -0
- data/lib/checkout_intents/internal/util.rb +920 -0
- data/lib/checkout_intents/internal.rb +20 -0
- data/lib/checkout_intents/models/base_checkout_intent.rb +76 -0
- data/lib/checkout_intents/models/betas/checkout_session_create_params.rb +148 -0
- data/lib/checkout_intents/models/brand_retrieve_params.rb +14 -0
- data/lib/checkout_intents/models/brand_retrieve_response.rb +52 -0
- data/lib/checkout_intents/models/buyer.rb +69 -0
- data/lib/checkout_intents/models/checkout_intent.rb +230 -0
- data/lib/checkout_intents/models/checkout_intent_add_payment_params.rb +20 -0
- data/lib/checkout_intents/models/checkout_intent_confirm_params.rb +20 -0
- data/lib/checkout_intents/models/checkout_intent_create_params.rb +68 -0
- data/lib/checkout_intents/models/checkout_intent_list_params.rb +58 -0
- data/lib/checkout_intents/models/checkout_intent_purchase_params.rb +74 -0
- data/lib/checkout_intents/models/checkout_intent_retrieve_params.rb +14 -0
- data/lib/checkout_intents/models/checkout_session.rb +23 -0
- data/lib/checkout_intents/models/money.rb +21 -0
- data/lib/checkout_intents/models/offer.rb +113 -0
- data/lib/checkout_intents/models/payment_method.rb +120 -0
- data/lib/checkout_intents/models/variant_selection.rb +33 -0
- data/lib/checkout_intents/models.rb +76 -0
- data/lib/checkout_intents/request_options.rb +78 -0
- data/lib/checkout_intents/resources/betas/checkout_sessions.rb +54 -0
- data/lib/checkout_intents/resources/betas.rb +18 -0
- data/lib/checkout_intents/resources/brands.rb +37 -0
- data/lib/checkout_intents/resources/checkout_intents.rb +173 -0
- data/lib/checkout_intents/version.rb +5 -0
- data/lib/checkout_intents.rb +77 -0
- data/manifest.yaml +17 -0
- data/rbi/checkout_intents/client.rbi +74 -0
- data/rbi/checkout_intents/errors.rbi +205 -0
- data/rbi/checkout_intents/file_part.rbi +37 -0
- data/rbi/checkout_intents/internal/cursor_pagination.rbi +74 -0
- data/rbi/checkout_intents/internal/transport/base_client.rbi +309 -0
- data/rbi/checkout_intents/internal/transport/pooled_net_requester.rbi +84 -0
- data/rbi/checkout_intents/internal/type/array_of.rbi +108 -0
- data/rbi/checkout_intents/internal/type/base_model.rbi +314 -0
- data/rbi/checkout_intents/internal/type/base_page.rbi +43 -0
- data/rbi/checkout_intents/internal/type/boolean.rbi +58 -0
- data/rbi/checkout_intents/internal/type/converter.rbi +225 -0
- data/rbi/checkout_intents/internal/type/enum.rbi +82 -0
- data/rbi/checkout_intents/internal/type/file_input.rbi +59 -0
- data/rbi/checkout_intents/internal/type/hash_of.rbi +108 -0
- data/rbi/checkout_intents/internal/type/request_parameters.rbi +31 -0
- data/rbi/checkout_intents/internal/type/union.rbi +134 -0
- data/rbi/checkout_intents/internal/type/unknown.rbi +58 -0
- data/rbi/checkout_intents/internal/util.rbi +487 -0
- data/rbi/checkout_intents/internal.rbi +18 -0
- data/rbi/checkout_intents/models/base_checkout_intent.rbi +142 -0
- data/rbi/checkout_intents/models/betas/checkout_session_create_params.rbi +281 -0
- data/rbi/checkout_intents/models/brand_retrieve_params.rbi +32 -0
- data/rbi/checkout_intents/models/brand_retrieve_response.rbi +109 -0
- data/rbi/checkout_intents/models/buyer.rbi +92 -0
- data/rbi/checkout_intents/models/checkout_intent.rbi +653 -0
- data/rbi/checkout_intents/models/checkout_intent_add_payment_params.rbi +59 -0
- data/rbi/checkout_intents/models/checkout_intent_confirm_params.rbi +59 -0
- data/rbi/checkout_intents/models/checkout_intent_create_params.rbi +141 -0
- data/rbi/checkout_intents/models/checkout_intent_list_params.rbi +146 -0
- data/rbi/checkout_intents/models/checkout_intent_purchase_params.rbi +165 -0
- data/rbi/checkout_intents/models/checkout_intent_retrieve_params.rbi +32 -0
- data/rbi/checkout_intents/models/checkout_session.rbi +36 -0
- data/rbi/checkout_intents/models/money.rbi +32 -0
- data/rbi/checkout_intents/models/offer.rbi +225 -0
- data/rbi/checkout_intents/models/payment_method.rbi +292 -0
- data/rbi/checkout_intents/models/variant_selection.rbi +55 -0
- data/rbi/checkout_intents/models.rbi +40 -0
- data/rbi/checkout_intents/request_options.rbi +64 -0
- data/rbi/checkout_intents/resources/betas/checkout_sessions.rbi +47 -0
- data/rbi/checkout_intents/resources/betas.rbi +15 -0
- data/rbi/checkout_intents/resources/brands.rbi +29 -0
- data/rbi/checkout_intents/resources/checkout_intents.rbi +165 -0
- data/rbi/checkout_intents/version.rbi +5 -0
- data/sig/checkout_intents/client.rbs +36 -0
- data/sig/checkout_intents/errors.rbs +117 -0
- data/sig/checkout_intents/file_part.rbs +21 -0
- data/sig/checkout_intents/internal/cursor_pagination.rbs +48 -0
- data/sig/checkout_intents/internal/transport/base_client.rbs +133 -0
- data/sig/checkout_intents/internal/transport/pooled_net_requester.rbs +48 -0
- data/sig/checkout_intents/internal/type/array_of.rbs +48 -0
- data/sig/checkout_intents/internal/type/base_model.rbs +104 -0
- data/sig/checkout_intents/internal/type/base_page.rbs +24 -0
- data/sig/checkout_intents/internal/type/boolean.rbs +26 -0
- data/sig/checkout_intents/internal/type/converter.rbs +79 -0
- data/sig/checkout_intents/internal/type/enum.rbs +32 -0
- data/sig/checkout_intents/internal/type/file_input.rbs +25 -0
- data/sig/checkout_intents/internal/type/hash_of.rbs +48 -0
- data/sig/checkout_intents/internal/type/request_parameters.rbs +20 -0
- data/sig/checkout_intents/internal/type/union.rbs +52 -0
- data/sig/checkout_intents/internal/type/unknown.rbs +26 -0
- data/sig/checkout_intents/internal/util.rbs +185 -0
- data/sig/checkout_intents/internal.rbs +10 -0
- data/sig/checkout_intents/models/base_checkout_intent.rbs +88 -0
- data/sig/checkout_intents/models/betas/checkout_session_create_params.rbs +172 -0
- data/sig/checkout_intents/models/brand_retrieve_params.rbs +15 -0
- data/sig/checkout_intents/models/brand_retrieve_response.rbs +43 -0
- data/sig/checkout_intents/models/buyer.rbs +67 -0
- data/sig/checkout_intents/models/checkout_intent.rbs +324 -0
- data/sig/checkout_intents/models/checkout_intent_add_payment_params.rbs +24 -0
- data/sig/checkout_intents/models/checkout_intent_confirm_params.rbs +24 -0
- data/sig/checkout_intents/models/checkout_intent_create_params.rbs +84 -0
- data/sig/checkout_intents/models/checkout_intent_list_params.rbs +77 -0
- data/sig/checkout_intents/models/checkout_intent_purchase_params.rbs +89 -0
- data/sig/checkout_intents/models/checkout_intent_retrieve_params.rbs +15 -0
- data/sig/checkout_intents/models/checkout_session.rbs +13 -0
- data/sig/checkout_intents/models/money.rbs +15 -0
- data/sig/checkout_intents/models/offer.rbs +135 -0
- data/sig/checkout_intents/models/payment_method.rbs +127 -0
- data/sig/checkout_intents/models/variant_selection.rbs +30 -0
- data/sig/checkout_intents/models.rbs +33 -0
- data/sig/checkout_intents/request_options.rbs +36 -0
- data/sig/checkout_intents/resources/betas/checkout_sessions.rbs +19 -0
- data/sig/checkout_intents/resources/betas.rbs +9 -0
- data/sig/checkout_intents/resources/brands.rbs +12 -0
- data/sig/checkout_intents/resources/checkout_intents.rbs +54 -0
- data/sig/checkout_intents/version.rbs +3 -0
- metadata +194 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CheckoutIntents
|
|
4
|
+
module Resources
|
|
5
|
+
class Betas
|
|
6
|
+
class CheckoutSessions
|
|
7
|
+
# Some parameter documentations has been truncated, see
|
|
8
|
+
# {::CheckoutIntents::Models::Betas::CheckoutSessionCreateParams} for more details.
|
|
9
|
+
#
|
|
10
|
+
# Create a new checkout session.
|
|
11
|
+
#
|
|
12
|
+
# Checkout sessions are hosted checkout forms your shoppers can use to complete
|
|
13
|
+
# their purchases.
|
|
14
|
+
#
|
|
15
|
+
# @overload create(product_url:, quantity:, buyer: nil, constraints: nil, promo_codes: nil, variant_selections: nil, request_options: {})
|
|
16
|
+
#
|
|
17
|
+
# @param product_url [String]
|
|
18
|
+
#
|
|
19
|
+
# @param quantity [Float]
|
|
20
|
+
#
|
|
21
|
+
# @param buyer [::CheckoutIntents::Models::Betas::CheckoutSessionCreateParams::Buyer] Optional buyer information, used to pre-fill the checkout form with the buyer's
|
|
22
|
+
#
|
|
23
|
+
# @param constraints [::CheckoutIntents::Models::Betas::CheckoutSessionCreateParams::Constraints]
|
|
24
|
+
#
|
|
25
|
+
# @param promo_codes [Array<String>]
|
|
26
|
+
#
|
|
27
|
+
# @param variant_selections [Array<::CheckoutIntents::Models::VariantSelection>]
|
|
28
|
+
#
|
|
29
|
+
# @param request_options [::CheckoutIntents::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
30
|
+
#
|
|
31
|
+
# @return [::CheckoutIntents::Models::CheckoutSession]
|
|
32
|
+
#
|
|
33
|
+
# @see ::CheckoutIntents::Models::Betas::CheckoutSessionCreateParams
|
|
34
|
+
def create(params)
|
|
35
|
+
parsed, options = ::CheckoutIntents::Betas::CheckoutSessionCreateParams.dump_request(params)
|
|
36
|
+
@client.request(
|
|
37
|
+
method: :post,
|
|
38
|
+
path: "api/v1/betas/checkout-sessions",
|
|
39
|
+
body: parsed,
|
|
40
|
+
model: ::CheckoutIntents::CheckoutSession,
|
|
41
|
+
options: options
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @api private
|
|
46
|
+
#
|
|
47
|
+
# @param client [::CheckoutIntents::Client]
|
|
48
|
+
def initialize(client:)
|
|
49
|
+
@client = client
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CheckoutIntents
|
|
4
|
+
module Resources
|
|
5
|
+
class Betas
|
|
6
|
+
# @return [::CheckoutIntents::Resources::Betas::CheckoutSessions]
|
|
7
|
+
attr_reader :checkout_sessions
|
|
8
|
+
|
|
9
|
+
# @api private
|
|
10
|
+
#
|
|
11
|
+
# @param client [::CheckoutIntents::Client]
|
|
12
|
+
def initialize(client:)
|
|
13
|
+
@client = client
|
|
14
|
+
@checkout_sessions = ::CheckoutIntents::Resources::Betas::CheckoutSessions.new(client: client)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CheckoutIntents
|
|
4
|
+
module Resources
|
|
5
|
+
class Brands
|
|
6
|
+
# Retrieve brand information by domain name
|
|
7
|
+
#
|
|
8
|
+
# Look up a brand by its domain name (e.g. "aloyoga.com" or "www.amazon.com").
|
|
9
|
+
# Returns brand information including the marketplace type if the lookup succeeds.
|
|
10
|
+
#
|
|
11
|
+
# @overload retrieve(domain, request_options: {})
|
|
12
|
+
#
|
|
13
|
+
# @param domain [String] Represents a valid domain name string.
|
|
14
|
+
#
|
|
15
|
+
# @param request_options [::CheckoutIntents::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
16
|
+
#
|
|
17
|
+
# @return [::CheckoutIntents::Models::BrandRetrieveResponse]
|
|
18
|
+
#
|
|
19
|
+
# @see ::CheckoutIntents::Models::BrandRetrieveParams
|
|
20
|
+
def retrieve(domain, params = {})
|
|
21
|
+
@client.request(
|
|
22
|
+
method: :get,
|
|
23
|
+
path: ["api/v1/brands/domain/%1$s", domain],
|
|
24
|
+
model: ::CheckoutIntents::Models::BrandRetrieveResponse,
|
|
25
|
+
options: params[:request_options]
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @api private
|
|
30
|
+
#
|
|
31
|
+
# @param client [::CheckoutIntents::Client]
|
|
32
|
+
def initialize(client:)
|
|
33
|
+
@client = client
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CheckoutIntents
|
|
4
|
+
module Resources
|
|
5
|
+
class CheckoutIntents
|
|
6
|
+
# Create a checkout intent with the given request body.
|
|
7
|
+
#
|
|
8
|
+
# @overload create(buyer:, product_url:, quantity:, constraints: nil, promo_codes: nil, variant_selections: nil, request_options: {})
|
|
9
|
+
#
|
|
10
|
+
# @param buyer [::CheckoutIntents::Models::Buyer]
|
|
11
|
+
# @param product_url [String]
|
|
12
|
+
# @param quantity [Float]
|
|
13
|
+
# @param constraints [::CheckoutIntents::Models::CheckoutIntentCreateParams::Constraints]
|
|
14
|
+
# @param promo_codes [Array<String>]
|
|
15
|
+
# @param variant_selections [Array<::CheckoutIntents::Models::VariantSelection>]
|
|
16
|
+
# @param request_options [::CheckoutIntents::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
17
|
+
#
|
|
18
|
+
# @return [::CheckoutIntents::Models::CheckoutIntent::RetrievingOfferCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::AwaitingConfirmationCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::PlacingOrderCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::CompletedCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::FailedCheckoutIntent]
|
|
19
|
+
#
|
|
20
|
+
# @see ::CheckoutIntents::Models::CheckoutIntentCreateParams
|
|
21
|
+
def create(params)
|
|
22
|
+
parsed, options = ::CheckoutIntents::CheckoutIntentCreateParams.dump_request(params)
|
|
23
|
+
@client.request(
|
|
24
|
+
method: :post,
|
|
25
|
+
path: "api/v1/checkout-intents",
|
|
26
|
+
body: parsed,
|
|
27
|
+
model: ::CheckoutIntents::CheckoutIntent,
|
|
28
|
+
options: options
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Retrieve a checkout intent by id
|
|
33
|
+
#
|
|
34
|
+
# Returns checkout intent information if the lookup succeeds.
|
|
35
|
+
#
|
|
36
|
+
# @overload retrieve(id, request_options: {})
|
|
37
|
+
#
|
|
38
|
+
# @param id [String] The id of the checkout intent to look up
|
|
39
|
+
#
|
|
40
|
+
# @param request_options [::CheckoutIntents::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
41
|
+
#
|
|
42
|
+
# @return [::CheckoutIntents::Models::CheckoutIntent::RetrievingOfferCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::AwaitingConfirmationCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::PlacingOrderCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::CompletedCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::FailedCheckoutIntent]
|
|
43
|
+
#
|
|
44
|
+
# @see ::CheckoutIntents::Models::CheckoutIntentRetrieveParams
|
|
45
|
+
def retrieve(id, params = {})
|
|
46
|
+
@client.request(
|
|
47
|
+
method: :get,
|
|
48
|
+
path: ["api/v1/checkout-intents/%1$s", id],
|
|
49
|
+
model: ::CheckoutIntents::CheckoutIntent,
|
|
50
|
+
options: params[:request_options]
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Retrieve a paginated list of checkout intents
|
|
55
|
+
#
|
|
56
|
+
# Enables developers to query checkout intents associated with their account, with
|
|
57
|
+
# filters and cursor-based pagination.
|
|
58
|
+
#
|
|
59
|
+
# @overload list(id: nil, after: nil, before: nil, limit: nil, state: nil, request_options: {})
|
|
60
|
+
#
|
|
61
|
+
# @param id [Array<String>]
|
|
62
|
+
# @param after [String]
|
|
63
|
+
# @param before [String]
|
|
64
|
+
# @param limit [Float]
|
|
65
|
+
# @param state [Array<Symbol, ::CheckoutIntents::Models::CheckoutIntentListParams::State>]
|
|
66
|
+
# @param request_options [::CheckoutIntents::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
67
|
+
#
|
|
68
|
+
# @return [::CheckoutIntents::Internal::CursorPagination<::CheckoutIntents::Models::CheckoutIntent::RetrievingOfferCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::AwaitingConfirmationCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::PlacingOrderCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::CompletedCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::FailedCheckoutIntent>]
|
|
69
|
+
#
|
|
70
|
+
# @see ::CheckoutIntents::Models::CheckoutIntentListParams
|
|
71
|
+
def list(params = {})
|
|
72
|
+
parsed, options = ::CheckoutIntents::CheckoutIntentListParams.dump_request(params)
|
|
73
|
+
@client.request(
|
|
74
|
+
method: :get,
|
|
75
|
+
path: "api/v1/checkout-intents",
|
|
76
|
+
query: parsed,
|
|
77
|
+
page: ::CheckoutIntents::Internal::CursorPagination,
|
|
78
|
+
model: ::CheckoutIntents::CheckoutIntent,
|
|
79
|
+
options: options
|
|
80
|
+
)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Add payment details to a checkout intent
|
|
84
|
+
#
|
|
85
|
+
# @overload add_payment(id, payment_method:, request_options: {})
|
|
86
|
+
#
|
|
87
|
+
# @param id [String] The id of the checkout intent to add payment details to
|
|
88
|
+
#
|
|
89
|
+
# @param payment_method [::CheckoutIntents::Models::PaymentMethod::StripeTokenPaymentMethod, ::CheckoutIntents::Models::PaymentMethod::BasisTheoryPaymentMethod, ::CheckoutIntents::Models::PaymentMethod::NekudaPaymentMethod]
|
|
90
|
+
#
|
|
91
|
+
# @param request_options [::CheckoutIntents::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
92
|
+
#
|
|
93
|
+
# @return [::CheckoutIntents::Models::CheckoutIntent::RetrievingOfferCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::AwaitingConfirmationCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::PlacingOrderCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::CompletedCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::FailedCheckoutIntent]
|
|
94
|
+
#
|
|
95
|
+
# @see ::CheckoutIntents::Models::CheckoutIntentAddPaymentParams
|
|
96
|
+
def add_payment(id, params)
|
|
97
|
+
parsed, options = ::CheckoutIntents::CheckoutIntentAddPaymentParams.dump_request(params)
|
|
98
|
+
@client.request(
|
|
99
|
+
method: :post,
|
|
100
|
+
path: ["api/v1/checkout-intents/%1$s/payment", id],
|
|
101
|
+
body: parsed,
|
|
102
|
+
model: ::CheckoutIntents::CheckoutIntent,
|
|
103
|
+
options: options
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Confirm a checkout intent with provided payment information
|
|
108
|
+
#
|
|
109
|
+
# Confirm means we have buyer's name, address and payment info, so we can move
|
|
110
|
+
# forward to place the order.
|
|
111
|
+
#
|
|
112
|
+
# @overload confirm(id, payment_method:, request_options: {})
|
|
113
|
+
#
|
|
114
|
+
# @param id [String] The id of the checkout intent to confirm
|
|
115
|
+
#
|
|
116
|
+
# @param payment_method [::CheckoutIntents::Models::PaymentMethod::StripeTokenPaymentMethod, ::CheckoutIntents::Models::PaymentMethod::BasisTheoryPaymentMethod, ::CheckoutIntents::Models::PaymentMethod::NekudaPaymentMethod]
|
|
117
|
+
#
|
|
118
|
+
# @param request_options [::CheckoutIntents::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
119
|
+
#
|
|
120
|
+
# @return [::CheckoutIntents::Models::CheckoutIntent::RetrievingOfferCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::AwaitingConfirmationCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::PlacingOrderCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::CompletedCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::FailedCheckoutIntent]
|
|
121
|
+
#
|
|
122
|
+
# @see ::CheckoutIntents::Models::CheckoutIntentConfirmParams
|
|
123
|
+
def confirm(id, params)
|
|
124
|
+
parsed, options = ::CheckoutIntents::CheckoutIntentConfirmParams.dump_request(params)
|
|
125
|
+
@client.request(
|
|
126
|
+
method: :post,
|
|
127
|
+
path: ["api/v1/checkout-intents/%1$s/confirm", id],
|
|
128
|
+
body: parsed,
|
|
129
|
+
model: ::CheckoutIntents::CheckoutIntent,
|
|
130
|
+
options: options
|
|
131
|
+
)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Create a checkout intent and immediately trigger the purchase workflow.
|
|
135
|
+
#
|
|
136
|
+
# This is a "fire-and-forget" endpoint that combines create + confirm in one step.
|
|
137
|
+
# The workflow handles offer retrieval, payment authorization, and order placement
|
|
138
|
+
# asynchronously. Poll the GET endpoint to check status.
|
|
139
|
+
#
|
|
140
|
+
# @overload purchase(buyer:, payment_method:, product_url:, quantity:, constraints: nil, promo_codes: nil, variant_selections: nil, request_options: {})
|
|
141
|
+
#
|
|
142
|
+
# @param buyer [::CheckoutIntents::Models::Buyer]
|
|
143
|
+
# @param payment_method [::CheckoutIntents::Models::PaymentMethod::StripeTokenPaymentMethod, ::CheckoutIntents::Models::PaymentMethod::BasisTheoryPaymentMethod, ::CheckoutIntents::Models::PaymentMethod::NekudaPaymentMethod]
|
|
144
|
+
# @param product_url [String]
|
|
145
|
+
# @param quantity [Float]
|
|
146
|
+
# @param constraints [::CheckoutIntents::Models::CheckoutIntentPurchaseParams::Constraints]
|
|
147
|
+
# @param promo_codes [Array<String>]
|
|
148
|
+
# @param variant_selections [Array<::CheckoutIntents::Models::VariantSelection>]
|
|
149
|
+
# @param request_options [::CheckoutIntents::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
150
|
+
#
|
|
151
|
+
# @return [::CheckoutIntents::Models::CheckoutIntent::RetrievingOfferCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::AwaitingConfirmationCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::PlacingOrderCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::CompletedCheckoutIntent, ::CheckoutIntents::Models::CheckoutIntent::FailedCheckoutIntent]
|
|
152
|
+
#
|
|
153
|
+
# @see ::CheckoutIntents::Models::CheckoutIntentPurchaseParams
|
|
154
|
+
def purchase(params)
|
|
155
|
+
parsed, options = ::CheckoutIntents::CheckoutIntentPurchaseParams.dump_request(params)
|
|
156
|
+
@client.request(
|
|
157
|
+
method: :post,
|
|
158
|
+
path: "api/v1/checkout-intents/purchase",
|
|
159
|
+
body: parsed,
|
|
160
|
+
model: ::CheckoutIntents::CheckoutIntent,
|
|
161
|
+
options: options
|
|
162
|
+
)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# @api private
|
|
166
|
+
#
|
|
167
|
+
# @param client [::CheckoutIntents::Client]
|
|
168
|
+
def initialize(client:)
|
|
169
|
+
@client = client
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Standard libraries.
|
|
4
|
+
# rubocop:disable Lint/RedundantRequireStatement
|
|
5
|
+
require "English"
|
|
6
|
+
require "base64"
|
|
7
|
+
require "cgi"
|
|
8
|
+
require "date"
|
|
9
|
+
require "erb"
|
|
10
|
+
require "etc"
|
|
11
|
+
require "json"
|
|
12
|
+
require "net/http"
|
|
13
|
+
require "openssl"
|
|
14
|
+
require "pathname"
|
|
15
|
+
require "rbconfig"
|
|
16
|
+
require "securerandom"
|
|
17
|
+
require "set"
|
|
18
|
+
require "stringio"
|
|
19
|
+
require "time"
|
|
20
|
+
require "uri"
|
|
21
|
+
# rubocop:enable Lint/RedundantRequireStatement
|
|
22
|
+
|
|
23
|
+
# We already ship the preferred sorbet manifests in the package itself.
|
|
24
|
+
# `tapioca` currently does not offer us a way to opt out of unnecessary compilation.
|
|
25
|
+
if Object.const_defined?(:Tapioca) &&
|
|
26
|
+
caller.chain([$PROGRAM_NAME]).chain(ARGV).any?(/tapioca/) &&
|
|
27
|
+
ARGV.none?(/dsl/)
|
|
28
|
+
return
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Gems.
|
|
32
|
+
require "connection_pool"
|
|
33
|
+
|
|
34
|
+
# Package files.
|
|
35
|
+
require_relative "checkout_intents/version"
|
|
36
|
+
require_relative "checkout_intents/internal/util"
|
|
37
|
+
require_relative "checkout_intents/internal/type/converter"
|
|
38
|
+
require_relative "checkout_intents/internal/type/unknown"
|
|
39
|
+
require_relative "checkout_intents/internal/type/boolean"
|
|
40
|
+
require_relative "checkout_intents/internal/type/file_input"
|
|
41
|
+
require_relative "checkout_intents/internal/type/enum"
|
|
42
|
+
require_relative "checkout_intents/internal/type/union"
|
|
43
|
+
require_relative "checkout_intents/internal/type/array_of"
|
|
44
|
+
require_relative "checkout_intents/internal/type/hash_of"
|
|
45
|
+
require_relative "checkout_intents/internal/type/base_model"
|
|
46
|
+
require_relative "checkout_intents/internal/type/base_page"
|
|
47
|
+
require_relative "checkout_intents/internal/type/request_parameters"
|
|
48
|
+
require_relative "checkout_intents/internal"
|
|
49
|
+
require_relative "checkout_intents/request_options"
|
|
50
|
+
require_relative "checkout_intents/file_part"
|
|
51
|
+
require_relative "checkout_intents/errors"
|
|
52
|
+
require_relative "checkout_intents/internal/transport/base_client"
|
|
53
|
+
require_relative "checkout_intents/internal/transport/pooled_net_requester"
|
|
54
|
+
require_relative "checkout_intents/client"
|
|
55
|
+
require_relative "checkout_intents/internal/cursor_pagination"
|
|
56
|
+
require_relative "checkout_intents/models/base_checkout_intent"
|
|
57
|
+
require_relative "checkout_intents/models/betas/checkout_session_create_params"
|
|
58
|
+
require_relative "checkout_intents/models/brand_retrieve_params"
|
|
59
|
+
require_relative "checkout_intents/models/brand_retrieve_response"
|
|
60
|
+
require_relative "checkout_intents/models/buyer"
|
|
61
|
+
require_relative "checkout_intents/models/checkout_intent"
|
|
62
|
+
require_relative "checkout_intents/models/checkout_intent_add_payment_params"
|
|
63
|
+
require_relative "checkout_intents/models/checkout_intent_confirm_params"
|
|
64
|
+
require_relative "checkout_intents/models/checkout_intent_create_params"
|
|
65
|
+
require_relative "checkout_intents/models/checkout_intent_list_params"
|
|
66
|
+
require_relative "checkout_intents/models/checkout_intent_purchase_params"
|
|
67
|
+
require_relative "checkout_intents/models/checkout_intent_retrieve_params"
|
|
68
|
+
require_relative "checkout_intents/models/checkout_session"
|
|
69
|
+
require_relative "checkout_intents/models/money"
|
|
70
|
+
require_relative "checkout_intents/models/offer"
|
|
71
|
+
require_relative "checkout_intents/models/payment_method"
|
|
72
|
+
require_relative "checkout_intents/models/variant_selection"
|
|
73
|
+
require_relative "checkout_intents/models"
|
|
74
|
+
require_relative "checkout_intents/resources/betas"
|
|
75
|
+
require_relative "checkout_intents/resources/betas/checkout_sessions"
|
|
76
|
+
require_relative "checkout_intents/resources/brands"
|
|
77
|
+
require_relative "checkout_intents/resources/checkout_intents"
|
data/manifest.yaml
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module CheckoutIntents
|
|
4
|
+
class Client < CheckoutIntents::Internal::Transport::BaseClient
|
|
5
|
+
DEFAULT_MAX_RETRIES = 2
|
|
6
|
+
|
|
7
|
+
DEFAULT_TIMEOUT_IN_SECONDS = T.let(60.0, Float)
|
|
8
|
+
|
|
9
|
+
DEFAULT_INITIAL_RETRY_DELAY = T.let(0.5, Float)
|
|
10
|
+
|
|
11
|
+
DEFAULT_MAX_RETRY_DELAY = T.let(8.0, Float)
|
|
12
|
+
|
|
13
|
+
ENVIRONMENTS =
|
|
14
|
+
T.let(
|
|
15
|
+
{
|
|
16
|
+
staging: "https://staging.api.rye.com/",
|
|
17
|
+
production: "https://api.rye.com/"
|
|
18
|
+
},
|
|
19
|
+
T::Hash[Symbol, String]
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# Rye API key. Format: `RYE/{environment}-abcdef`
|
|
23
|
+
sig { returns(String) }
|
|
24
|
+
attr_reader :api_key
|
|
25
|
+
|
|
26
|
+
sig { returns(CheckoutIntents::Resources::CheckoutIntents) }
|
|
27
|
+
attr_reader :checkout_intents
|
|
28
|
+
|
|
29
|
+
sig { returns(CheckoutIntents::Resources::Betas) }
|
|
30
|
+
attr_reader :betas
|
|
31
|
+
|
|
32
|
+
sig { returns(CheckoutIntents::Resources::Brands) }
|
|
33
|
+
attr_reader :brands
|
|
34
|
+
|
|
35
|
+
# @api private
|
|
36
|
+
sig { override.returns(T::Hash[String, String]) }
|
|
37
|
+
private def auth_headers
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Creates and returns a new client for interacting with the API.
|
|
41
|
+
sig do
|
|
42
|
+
params(
|
|
43
|
+
api_key: T.nilable(String),
|
|
44
|
+
environment: T.nilable(T.any(Symbol, String)),
|
|
45
|
+
base_url: T.nilable(String),
|
|
46
|
+
max_retries: Integer,
|
|
47
|
+
timeout: Float,
|
|
48
|
+
initial_retry_delay: Float,
|
|
49
|
+
max_retry_delay: Float
|
|
50
|
+
).returns(T.attached_class)
|
|
51
|
+
end
|
|
52
|
+
def self.new(
|
|
53
|
+
# Rye API key. Format: `RYE/{environment}-abcdef` Defaults to
|
|
54
|
+
# `ENV["CHECKOUT_INTENTS_API_KEY"]`
|
|
55
|
+
api_key: ENV["CHECKOUT_INTENTS_API_KEY"],
|
|
56
|
+
# Specifies the environment to use for the API.
|
|
57
|
+
#
|
|
58
|
+
# Each environment maps to a different base URL:
|
|
59
|
+
#
|
|
60
|
+
# - `staging` corresponds to `https://staging.api.rye.com/`
|
|
61
|
+
# - `production` corresponds to `https://api.rye.com/`
|
|
62
|
+
environment: nil,
|
|
63
|
+
# Override the default base URL for the API, e.g.,
|
|
64
|
+
# `"https://api.example.com/v2/"`. Defaults to `ENV["CHECKOUT_INTENTS_BASE_URL"]`
|
|
65
|
+
base_url: ENV["CHECKOUT_INTENTS_BASE_URL"],
|
|
66
|
+
# Max number of retries to attempt after a failed retryable request.
|
|
67
|
+
max_retries: CheckoutIntents::Client::DEFAULT_MAX_RETRIES,
|
|
68
|
+
timeout: CheckoutIntents::Client::DEFAULT_TIMEOUT_IN_SECONDS,
|
|
69
|
+
initial_retry_delay: CheckoutIntents::Client::DEFAULT_INITIAL_RETRY_DELAY,
|
|
70
|
+
max_retry_delay: CheckoutIntents::Client::DEFAULT_MAX_RETRY_DELAY
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module CheckoutIntents
|
|
4
|
+
module Errors
|
|
5
|
+
class Error < StandardError
|
|
6
|
+
sig { returns(T.nilable(StandardError)) }
|
|
7
|
+
attr_accessor :cause
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class ConversionError < CheckoutIntents::Errors::Error
|
|
11
|
+
sig { returns(T.nilable(StandardError)) }
|
|
12
|
+
def cause
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @api private
|
|
16
|
+
sig do
|
|
17
|
+
params(
|
|
18
|
+
on: T::Class[StandardError],
|
|
19
|
+
method: Symbol,
|
|
20
|
+
target: T.anything,
|
|
21
|
+
value: T.anything,
|
|
22
|
+
cause: T.nilable(StandardError)
|
|
23
|
+
).returns(T.attached_class)
|
|
24
|
+
end
|
|
25
|
+
def self.new(on:, method:, target:, value:, cause: nil)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class APIError < CheckoutIntents::Errors::Error
|
|
30
|
+
sig { returns(URI::Generic) }
|
|
31
|
+
attr_accessor :url
|
|
32
|
+
|
|
33
|
+
sig { returns(T.nilable(Integer)) }
|
|
34
|
+
attr_accessor :status
|
|
35
|
+
|
|
36
|
+
sig { returns(T.nilable(T::Hash[String, String])) }
|
|
37
|
+
attr_accessor :headers
|
|
38
|
+
|
|
39
|
+
sig { returns(T.nilable(T.anything)) }
|
|
40
|
+
attr_accessor :body
|
|
41
|
+
|
|
42
|
+
# @api private
|
|
43
|
+
sig do
|
|
44
|
+
params(
|
|
45
|
+
url: URI::Generic,
|
|
46
|
+
status: T.nilable(Integer),
|
|
47
|
+
headers: T.nilable(T::Hash[String, String]),
|
|
48
|
+
body: T.nilable(Object),
|
|
49
|
+
request: NilClass,
|
|
50
|
+
response: NilClass,
|
|
51
|
+
message: T.nilable(String)
|
|
52
|
+
).returns(T.attached_class)
|
|
53
|
+
end
|
|
54
|
+
def self.new(
|
|
55
|
+
url:,
|
|
56
|
+
status: nil,
|
|
57
|
+
headers: nil,
|
|
58
|
+
body: nil,
|
|
59
|
+
request: nil,
|
|
60
|
+
response: nil,
|
|
61
|
+
message: nil
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
class APIConnectionError < CheckoutIntents::Errors::APIError
|
|
67
|
+
sig { returns(NilClass) }
|
|
68
|
+
attr_accessor :status
|
|
69
|
+
|
|
70
|
+
sig { returns(NilClass) }
|
|
71
|
+
attr_accessor :body
|
|
72
|
+
|
|
73
|
+
# @api private
|
|
74
|
+
sig do
|
|
75
|
+
params(
|
|
76
|
+
url: URI::Generic,
|
|
77
|
+
status: NilClass,
|
|
78
|
+
headers: T.nilable(T::Hash[String, String]),
|
|
79
|
+
body: NilClass,
|
|
80
|
+
request: NilClass,
|
|
81
|
+
response: NilClass,
|
|
82
|
+
message: T.nilable(String)
|
|
83
|
+
).returns(T.attached_class)
|
|
84
|
+
end
|
|
85
|
+
def self.new(
|
|
86
|
+
url:,
|
|
87
|
+
status: nil,
|
|
88
|
+
headers: nil,
|
|
89
|
+
body: nil,
|
|
90
|
+
request: nil,
|
|
91
|
+
response: nil,
|
|
92
|
+
message: "Connection error."
|
|
93
|
+
)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
class APITimeoutError < CheckoutIntents::Errors::APIConnectionError
|
|
98
|
+
# @api private
|
|
99
|
+
sig do
|
|
100
|
+
params(
|
|
101
|
+
url: URI::Generic,
|
|
102
|
+
status: NilClass,
|
|
103
|
+
headers: T.nilable(T::Hash[String, String]),
|
|
104
|
+
body: NilClass,
|
|
105
|
+
request: NilClass,
|
|
106
|
+
response: NilClass,
|
|
107
|
+
message: T.nilable(String)
|
|
108
|
+
).returns(T.attached_class)
|
|
109
|
+
end
|
|
110
|
+
def self.new(
|
|
111
|
+
url:,
|
|
112
|
+
status: nil,
|
|
113
|
+
headers: nil,
|
|
114
|
+
body: nil,
|
|
115
|
+
request: nil,
|
|
116
|
+
response: nil,
|
|
117
|
+
message: "Request timed out."
|
|
118
|
+
)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
class APIStatusError < CheckoutIntents::Errors::APIError
|
|
123
|
+
# @api private
|
|
124
|
+
sig do
|
|
125
|
+
params(
|
|
126
|
+
url: URI::Generic,
|
|
127
|
+
status: Integer,
|
|
128
|
+
headers: T.nilable(T::Hash[String, String]),
|
|
129
|
+
body: T.nilable(Object),
|
|
130
|
+
request: NilClass,
|
|
131
|
+
response: NilClass,
|
|
132
|
+
message: T.nilable(String)
|
|
133
|
+
).returns(T.attached_class)
|
|
134
|
+
end
|
|
135
|
+
def self.for(
|
|
136
|
+
url:,
|
|
137
|
+
status:,
|
|
138
|
+
headers:,
|
|
139
|
+
body:,
|
|
140
|
+
request:,
|
|
141
|
+
response:,
|
|
142
|
+
message: nil
|
|
143
|
+
)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
sig { returns(Integer) }
|
|
147
|
+
attr_accessor :status
|
|
148
|
+
|
|
149
|
+
# @api private
|
|
150
|
+
sig do
|
|
151
|
+
params(
|
|
152
|
+
url: URI::Generic,
|
|
153
|
+
status: Integer,
|
|
154
|
+
headers: T.nilable(T::Hash[String, String]),
|
|
155
|
+
body: T.nilable(Object),
|
|
156
|
+
request: NilClass,
|
|
157
|
+
response: NilClass,
|
|
158
|
+
message: T.nilable(String)
|
|
159
|
+
).returns(T.attached_class)
|
|
160
|
+
end
|
|
161
|
+
def self.new(
|
|
162
|
+
url:,
|
|
163
|
+
status:,
|
|
164
|
+
headers:,
|
|
165
|
+
body:,
|
|
166
|
+
request:,
|
|
167
|
+
response:,
|
|
168
|
+
message: nil
|
|
169
|
+
)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
class BadRequestError < CheckoutIntents::Errors::APIStatusError
|
|
174
|
+
HTTP_STATUS = 400
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
class AuthenticationError < CheckoutIntents::Errors::APIStatusError
|
|
178
|
+
HTTP_STATUS = 401
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
class PermissionDeniedError < CheckoutIntents::Errors::APIStatusError
|
|
182
|
+
HTTP_STATUS = 403
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
class NotFoundError < CheckoutIntents::Errors::APIStatusError
|
|
186
|
+
HTTP_STATUS = 404
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
class ConflictError < CheckoutIntents::Errors::APIStatusError
|
|
190
|
+
HTTP_STATUS = 409
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
class UnprocessableEntityError < CheckoutIntents::Errors::APIStatusError
|
|
194
|
+
HTTP_STATUS = 422
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
class RateLimitError < CheckoutIntents::Errors::APIStatusError
|
|
198
|
+
HTTP_STATUS = 429
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
class InternalServerError < CheckoutIntents::Errors::APIStatusError
|
|
202
|
+
HTTP_STATUS = T.let((500..), T::Range[Integer])
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|