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.
Files changed (137) hide show
  1. checksums.yaml +7 -0
  2. data/.ignore +2 -0
  3. data/CHANGELOG.md +16 -0
  4. data/README.md +358 -0
  5. data/SECURITY.md +27 -0
  6. data/lib/checkout_intents/client.rb +100 -0
  7. data/lib/checkout_intents/errors.rb +228 -0
  8. data/lib/checkout_intents/file_part.rb +58 -0
  9. data/lib/checkout_intents/internal/cursor_pagination.rb +125 -0
  10. data/lib/checkout_intents/internal/transport/base_client.rb +577 -0
  11. data/lib/checkout_intents/internal/transport/pooled_net_requester.rb +210 -0
  12. data/lib/checkout_intents/internal/type/array_of.rb +168 -0
  13. data/lib/checkout_intents/internal/type/base_model.rb +536 -0
  14. data/lib/checkout_intents/internal/type/base_page.rb +55 -0
  15. data/lib/checkout_intents/internal/type/boolean.rb +77 -0
  16. data/lib/checkout_intents/internal/type/converter.rb +327 -0
  17. data/lib/checkout_intents/internal/type/enum.rb +131 -0
  18. data/lib/checkout_intents/internal/type/file_input.rb +111 -0
  19. data/lib/checkout_intents/internal/type/hash_of.rb +188 -0
  20. data/lib/checkout_intents/internal/type/request_parameters.rb +42 -0
  21. data/lib/checkout_intents/internal/type/union.rb +258 -0
  22. data/lib/checkout_intents/internal/type/unknown.rb +81 -0
  23. data/lib/checkout_intents/internal/util.rb +920 -0
  24. data/lib/checkout_intents/internal.rb +20 -0
  25. data/lib/checkout_intents/models/base_checkout_intent.rb +76 -0
  26. data/lib/checkout_intents/models/betas/checkout_session_create_params.rb +148 -0
  27. data/lib/checkout_intents/models/brand_retrieve_params.rb +14 -0
  28. data/lib/checkout_intents/models/brand_retrieve_response.rb +52 -0
  29. data/lib/checkout_intents/models/buyer.rb +69 -0
  30. data/lib/checkout_intents/models/checkout_intent.rb +230 -0
  31. data/lib/checkout_intents/models/checkout_intent_add_payment_params.rb +20 -0
  32. data/lib/checkout_intents/models/checkout_intent_confirm_params.rb +20 -0
  33. data/lib/checkout_intents/models/checkout_intent_create_params.rb +68 -0
  34. data/lib/checkout_intents/models/checkout_intent_list_params.rb +58 -0
  35. data/lib/checkout_intents/models/checkout_intent_purchase_params.rb +74 -0
  36. data/lib/checkout_intents/models/checkout_intent_retrieve_params.rb +14 -0
  37. data/lib/checkout_intents/models/checkout_session.rb +23 -0
  38. data/lib/checkout_intents/models/money.rb +21 -0
  39. data/lib/checkout_intents/models/offer.rb +113 -0
  40. data/lib/checkout_intents/models/payment_method.rb +120 -0
  41. data/lib/checkout_intents/models/variant_selection.rb +33 -0
  42. data/lib/checkout_intents/models.rb +76 -0
  43. data/lib/checkout_intents/request_options.rb +78 -0
  44. data/lib/checkout_intents/resources/betas/checkout_sessions.rb +54 -0
  45. data/lib/checkout_intents/resources/betas.rb +18 -0
  46. data/lib/checkout_intents/resources/brands.rb +37 -0
  47. data/lib/checkout_intents/resources/checkout_intents.rb +173 -0
  48. data/lib/checkout_intents/version.rb +5 -0
  49. data/lib/checkout_intents.rb +77 -0
  50. data/manifest.yaml +17 -0
  51. data/rbi/checkout_intents/client.rbi +74 -0
  52. data/rbi/checkout_intents/errors.rbi +205 -0
  53. data/rbi/checkout_intents/file_part.rbi +37 -0
  54. data/rbi/checkout_intents/internal/cursor_pagination.rbi +74 -0
  55. data/rbi/checkout_intents/internal/transport/base_client.rbi +309 -0
  56. data/rbi/checkout_intents/internal/transport/pooled_net_requester.rbi +84 -0
  57. data/rbi/checkout_intents/internal/type/array_of.rbi +108 -0
  58. data/rbi/checkout_intents/internal/type/base_model.rbi +314 -0
  59. data/rbi/checkout_intents/internal/type/base_page.rbi +43 -0
  60. data/rbi/checkout_intents/internal/type/boolean.rbi +58 -0
  61. data/rbi/checkout_intents/internal/type/converter.rbi +225 -0
  62. data/rbi/checkout_intents/internal/type/enum.rbi +82 -0
  63. data/rbi/checkout_intents/internal/type/file_input.rbi +59 -0
  64. data/rbi/checkout_intents/internal/type/hash_of.rbi +108 -0
  65. data/rbi/checkout_intents/internal/type/request_parameters.rbi +31 -0
  66. data/rbi/checkout_intents/internal/type/union.rbi +134 -0
  67. data/rbi/checkout_intents/internal/type/unknown.rbi +58 -0
  68. data/rbi/checkout_intents/internal/util.rbi +487 -0
  69. data/rbi/checkout_intents/internal.rbi +18 -0
  70. data/rbi/checkout_intents/models/base_checkout_intent.rbi +142 -0
  71. data/rbi/checkout_intents/models/betas/checkout_session_create_params.rbi +281 -0
  72. data/rbi/checkout_intents/models/brand_retrieve_params.rbi +32 -0
  73. data/rbi/checkout_intents/models/brand_retrieve_response.rbi +109 -0
  74. data/rbi/checkout_intents/models/buyer.rbi +92 -0
  75. data/rbi/checkout_intents/models/checkout_intent.rbi +653 -0
  76. data/rbi/checkout_intents/models/checkout_intent_add_payment_params.rbi +59 -0
  77. data/rbi/checkout_intents/models/checkout_intent_confirm_params.rbi +59 -0
  78. data/rbi/checkout_intents/models/checkout_intent_create_params.rbi +141 -0
  79. data/rbi/checkout_intents/models/checkout_intent_list_params.rbi +146 -0
  80. data/rbi/checkout_intents/models/checkout_intent_purchase_params.rbi +165 -0
  81. data/rbi/checkout_intents/models/checkout_intent_retrieve_params.rbi +32 -0
  82. data/rbi/checkout_intents/models/checkout_session.rbi +36 -0
  83. data/rbi/checkout_intents/models/money.rbi +32 -0
  84. data/rbi/checkout_intents/models/offer.rbi +225 -0
  85. data/rbi/checkout_intents/models/payment_method.rbi +292 -0
  86. data/rbi/checkout_intents/models/variant_selection.rbi +55 -0
  87. data/rbi/checkout_intents/models.rbi +40 -0
  88. data/rbi/checkout_intents/request_options.rbi +64 -0
  89. data/rbi/checkout_intents/resources/betas/checkout_sessions.rbi +47 -0
  90. data/rbi/checkout_intents/resources/betas.rbi +15 -0
  91. data/rbi/checkout_intents/resources/brands.rbi +29 -0
  92. data/rbi/checkout_intents/resources/checkout_intents.rbi +165 -0
  93. data/rbi/checkout_intents/version.rbi +5 -0
  94. data/sig/checkout_intents/client.rbs +36 -0
  95. data/sig/checkout_intents/errors.rbs +117 -0
  96. data/sig/checkout_intents/file_part.rbs +21 -0
  97. data/sig/checkout_intents/internal/cursor_pagination.rbs +48 -0
  98. data/sig/checkout_intents/internal/transport/base_client.rbs +133 -0
  99. data/sig/checkout_intents/internal/transport/pooled_net_requester.rbs +48 -0
  100. data/sig/checkout_intents/internal/type/array_of.rbs +48 -0
  101. data/sig/checkout_intents/internal/type/base_model.rbs +104 -0
  102. data/sig/checkout_intents/internal/type/base_page.rbs +24 -0
  103. data/sig/checkout_intents/internal/type/boolean.rbs +26 -0
  104. data/sig/checkout_intents/internal/type/converter.rbs +79 -0
  105. data/sig/checkout_intents/internal/type/enum.rbs +32 -0
  106. data/sig/checkout_intents/internal/type/file_input.rbs +25 -0
  107. data/sig/checkout_intents/internal/type/hash_of.rbs +48 -0
  108. data/sig/checkout_intents/internal/type/request_parameters.rbs +20 -0
  109. data/sig/checkout_intents/internal/type/union.rbs +52 -0
  110. data/sig/checkout_intents/internal/type/unknown.rbs +26 -0
  111. data/sig/checkout_intents/internal/util.rbs +185 -0
  112. data/sig/checkout_intents/internal.rbs +10 -0
  113. data/sig/checkout_intents/models/base_checkout_intent.rbs +88 -0
  114. data/sig/checkout_intents/models/betas/checkout_session_create_params.rbs +172 -0
  115. data/sig/checkout_intents/models/brand_retrieve_params.rbs +15 -0
  116. data/sig/checkout_intents/models/brand_retrieve_response.rbs +43 -0
  117. data/sig/checkout_intents/models/buyer.rbs +67 -0
  118. data/sig/checkout_intents/models/checkout_intent.rbs +324 -0
  119. data/sig/checkout_intents/models/checkout_intent_add_payment_params.rbs +24 -0
  120. data/sig/checkout_intents/models/checkout_intent_confirm_params.rbs +24 -0
  121. data/sig/checkout_intents/models/checkout_intent_create_params.rbs +84 -0
  122. data/sig/checkout_intents/models/checkout_intent_list_params.rbs +77 -0
  123. data/sig/checkout_intents/models/checkout_intent_purchase_params.rbs +89 -0
  124. data/sig/checkout_intents/models/checkout_intent_retrieve_params.rbs +15 -0
  125. data/sig/checkout_intents/models/checkout_session.rbs +13 -0
  126. data/sig/checkout_intents/models/money.rbs +15 -0
  127. data/sig/checkout_intents/models/offer.rbs +135 -0
  128. data/sig/checkout_intents/models/payment_method.rbs +127 -0
  129. data/sig/checkout_intents/models/variant_selection.rbs +30 -0
  130. data/sig/checkout_intents/models.rbs +33 -0
  131. data/sig/checkout_intents/request_options.rbs +36 -0
  132. data/sig/checkout_intents/resources/betas/checkout_sessions.rbs +19 -0
  133. data/sig/checkout_intents/resources/betas.rbs +9 -0
  134. data/sig/checkout_intents/resources/brands.rbs +12 -0
  135. data/sig/checkout_intents/resources/checkout_intents.rbs +54 -0
  136. data/sig/checkout_intents/version.rbs +3 -0
  137. metadata +194 -0
@@ -0,0 +1,47 @@
1
+ # typed: strong
2
+
3
+ module CheckoutIntents
4
+ module Resources
5
+ class Betas
6
+ class CheckoutSessions
7
+ # Create a new checkout session.
8
+ #
9
+ # Checkout sessions are hosted checkout forms your shoppers can use to complete
10
+ # their purchases.
11
+ sig do
12
+ params(
13
+ product_url: String,
14
+ quantity: Float,
15
+ buyer:
16
+ ::CheckoutIntents::Betas::CheckoutSessionCreateParams::Buyer::OrHash,
17
+ constraints:
18
+ ::CheckoutIntents::Betas::CheckoutSessionCreateParams::Constraints::OrHash,
19
+ promo_codes: T::Array[String],
20
+ variant_selections:
21
+ T::Array[::CheckoutIntents::VariantSelection::OrHash],
22
+ request_options: ::CheckoutIntents::RequestOptions::OrHash
23
+ ).returns(::CheckoutIntents::CheckoutSession)
24
+ end
25
+ def create(
26
+ product_url:,
27
+ quantity:,
28
+ # Optional buyer information, used to pre-fill the checkout form with the buyer's
29
+ # information.
30
+ buyer: nil,
31
+ constraints: nil,
32
+ promo_codes: nil,
33
+ variant_selections: nil,
34
+ request_options: {}
35
+ )
36
+ end
37
+
38
+ # @api private
39
+ sig do
40
+ params(client: ::CheckoutIntents::Client).returns(T.attached_class)
41
+ end
42
+ def self.new(client:)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,15 @@
1
+ # typed: strong
2
+
3
+ module CheckoutIntents
4
+ module Resources
5
+ class Betas
6
+ sig { returns(::CheckoutIntents::Resources::Betas::CheckoutSessions) }
7
+ attr_reader :checkout_sessions
8
+
9
+ # @api private
10
+ sig { params(client: ::CheckoutIntents::Client).returns(T.attached_class) }
11
+ def self.new(client:)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ # typed: strong
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
+ sig do
11
+ params(
12
+ domain: String,
13
+ request_options: ::CheckoutIntents::RequestOptions::OrHash
14
+ ).returns(::CheckoutIntents::Models::BrandRetrieveResponse)
15
+ end
16
+ def retrieve(
17
+ # Represents a valid domain name string.
18
+ domain,
19
+ request_options: {}
20
+ )
21
+ end
22
+
23
+ # @api private
24
+ sig { params(client: ::CheckoutIntents::Client).returns(T.attached_class) }
25
+ def self.new(client:)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,165 @@
1
+ # typed: strong
2
+
3
+ module CheckoutIntents
4
+ module Resources
5
+ class CheckoutIntents
6
+ # Create a checkout intent with the given request body.
7
+ sig do
8
+ params(
9
+ buyer: ::CheckoutIntents::Buyer::OrHash,
10
+ product_url: String,
11
+ quantity: Float,
12
+ constraints:
13
+ ::CheckoutIntents::CheckoutIntentCreateParams::Constraints::OrHash,
14
+ promo_codes: T::Array[String],
15
+ variant_selections:
16
+ T::Array[::CheckoutIntents::VariantSelection::OrHash],
17
+ request_options: ::CheckoutIntents::RequestOptions::OrHash
18
+ ).returns(::CheckoutIntents::CheckoutIntent::Variants)
19
+ end
20
+ def create(
21
+ buyer:,
22
+ product_url:,
23
+ quantity:,
24
+ constraints: nil,
25
+ promo_codes: nil,
26
+ variant_selections: nil,
27
+ request_options: {}
28
+ )
29
+ end
30
+
31
+ # Retrieve a checkout intent by id
32
+ #
33
+ # Returns checkout intent information if the lookup succeeds.
34
+ sig do
35
+ params(
36
+ id: String,
37
+ request_options: ::CheckoutIntents::RequestOptions::OrHash
38
+ ).returns(::CheckoutIntents::CheckoutIntent::Variants)
39
+ end
40
+ def retrieve(
41
+ # The id of the checkout intent to look up
42
+ id,
43
+ request_options: {}
44
+ )
45
+ end
46
+
47
+ # Retrieve a paginated list of checkout intents
48
+ #
49
+ # Enables developers to query checkout intents associated with their account, with
50
+ # filters and cursor-based pagination.
51
+ sig do
52
+ params(
53
+ id: T::Array[String],
54
+ after: String,
55
+ before: String,
56
+ limit: Float,
57
+ state:
58
+ T::Array[
59
+ ::CheckoutIntents::CheckoutIntentListParams::State::OrSymbol
60
+ ],
61
+ request_options: ::CheckoutIntents::RequestOptions::OrHash
62
+ ).returns(
63
+ ::CheckoutIntents::Internal::CursorPagination[
64
+ ::CheckoutIntents::CheckoutIntent::Variants
65
+ ]
66
+ )
67
+ end
68
+ def list(
69
+ id: nil,
70
+ after: nil,
71
+ before: nil,
72
+ limit: nil,
73
+ state: nil,
74
+ request_options: {}
75
+ )
76
+ end
77
+
78
+ # Add payment details to a checkout intent
79
+ sig do
80
+ params(
81
+ id: String,
82
+ payment_method:
83
+ T.any(
84
+ ::CheckoutIntents::PaymentMethod::StripeTokenPaymentMethod::OrHash,
85
+ ::CheckoutIntents::PaymentMethod::BasisTheoryPaymentMethod::OrHash,
86
+ ::CheckoutIntents::PaymentMethod::NekudaPaymentMethod::OrHash
87
+ ),
88
+ request_options: ::CheckoutIntents::RequestOptions::OrHash
89
+ ).returns(::CheckoutIntents::CheckoutIntent::Variants)
90
+ end
91
+ def add_payment(
92
+ # The id of the checkout intent to add payment details to
93
+ id,
94
+ payment_method:,
95
+ request_options: {}
96
+ )
97
+ end
98
+
99
+ # Confirm a checkout intent with provided payment information
100
+ #
101
+ # Confirm means we have buyer's name, address and payment info, so we can move
102
+ # forward to place the order.
103
+ sig do
104
+ params(
105
+ id: String,
106
+ payment_method:
107
+ T.any(
108
+ ::CheckoutIntents::PaymentMethod::StripeTokenPaymentMethod::OrHash,
109
+ ::CheckoutIntents::PaymentMethod::BasisTheoryPaymentMethod::OrHash,
110
+ ::CheckoutIntents::PaymentMethod::NekudaPaymentMethod::OrHash
111
+ ),
112
+ request_options: ::CheckoutIntents::RequestOptions::OrHash
113
+ ).returns(::CheckoutIntents::CheckoutIntent::Variants)
114
+ end
115
+ def confirm(
116
+ # The id of the checkout intent to confirm
117
+ id,
118
+ payment_method:,
119
+ request_options: {}
120
+ )
121
+ end
122
+
123
+ # Create a checkout intent and immediately trigger the purchase workflow.
124
+ #
125
+ # This is a "fire-and-forget" endpoint that combines create + confirm in one step.
126
+ # The workflow handles offer retrieval, payment authorization, and order placement
127
+ # asynchronously. Poll the GET endpoint to check status.
128
+ sig do
129
+ params(
130
+ buyer: ::CheckoutIntents::Buyer::OrHash,
131
+ payment_method:
132
+ T.any(
133
+ ::CheckoutIntents::PaymentMethod::StripeTokenPaymentMethod::OrHash,
134
+ ::CheckoutIntents::PaymentMethod::BasisTheoryPaymentMethod::OrHash,
135
+ ::CheckoutIntents::PaymentMethod::NekudaPaymentMethod::OrHash
136
+ ),
137
+ product_url: String,
138
+ quantity: Float,
139
+ constraints:
140
+ ::CheckoutIntents::CheckoutIntentPurchaseParams::Constraints::OrHash,
141
+ promo_codes: T::Array[String],
142
+ variant_selections:
143
+ T::Array[::CheckoutIntents::VariantSelection::OrHash],
144
+ request_options: ::CheckoutIntents::RequestOptions::OrHash
145
+ ).returns(::CheckoutIntents::CheckoutIntent::Variants)
146
+ end
147
+ def purchase(
148
+ buyer:,
149
+ payment_method:,
150
+ product_url:,
151
+ quantity:,
152
+ constraints: nil,
153
+ promo_codes: nil,
154
+ variant_selections: nil,
155
+ request_options: {}
156
+ )
157
+ end
158
+
159
+ # @api private
160
+ sig { params(client: ::CheckoutIntents::Client).returns(T.attached_class) }
161
+ def self.new(client:)
162
+ end
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,5 @@
1
+ # typed: strong
2
+
3
+ module CheckoutIntents
4
+ VERSION = T.let(T.unsafe(nil), String)
5
+ end
@@ -0,0 +1,36 @@
1
+ module CheckoutIntents
2
+ class Client < CheckoutIntents::Internal::Transport::BaseClient
3
+ DEFAULT_MAX_RETRIES: 2
4
+
5
+ DEFAULT_TIMEOUT_IN_SECONDS: Float
6
+
7
+ DEFAULT_INITIAL_RETRY_DELAY: Float
8
+
9
+ DEFAULT_MAX_RETRY_DELAY: Float
10
+
11
+ ENVIRONMENTS: {
12
+ staging: "https://staging.api.rye.com/",
13
+ production: "https://api.rye.com/"
14
+ }
15
+
16
+ attr_reader api_key: String
17
+
18
+ attr_reader checkout_intents: CheckoutIntents::Resources::CheckoutIntents
19
+
20
+ attr_reader betas: CheckoutIntents::Resources::Betas
21
+
22
+ attr_reader brands: CheckoutIntents::Resources::Brands
23
+
24
+ private def auth_headers: -> ::Hash[String, String]
25
+
26
+ def initialize: (
27
+ ?api_key: String?,
28
+ ?environment: :staging | :production | nil,
29
+ ?base_url: String?,
30
+ ?max_retries: Integer,
31
+ ?timeout: Float,
32
+ ?initial_retry_delay: Float,
33
+ ?max_retry_delay: Float
34
+ ) -> void
35
+ end
36
+ end
@@ -0,0 +1,117 @@
1
+ module CheckoutIntents
2
+ module Errors
3
+ class Error < StandardError
4
+ attr_accessor cause: StandardError?
5
+ end
6
+
7
+ class ConversionError < CheckoutIntents::Errors::Error
8
+ def cause: -> StandardError?
9
+
10
+ def initialize: (
11
+ on: Class,
12
+ method: Symbol,
13
+ target: top,
14
+ value: top,
15
+ ?cause: StandardError?
16
+ ) -> void
17
+ end
18
+
19
+ class APIError < CheckoutIntents::Errors::Error
20
+ attr_accessor url: URI::Generic
21
+
22
+ attr_accessor status: Integer?
23
+
24
+ attr_accessor headers: ::Hash[String, String]?
25
+
26
+ attr_accessor body: top?
27
+
28
+ def initialize: (
29
+ url: URI::Generic,
30
+ ?status: Integer?,
31
+ ?headers: ::Hash[String, String]?,
32
+ ?body: Object?,
33
+ ?request: nil,
34
+ ?response: nil,
35
+ ?message: String?
36
+ ) -> void
37
+ end
38
+
39
+ class APIConnectionError < CheckoutIntents::Errors::APIError
40
+ def initialize: (
41
+ url: URI::Generic,
42
+ ?status: nil,
43
+ ?headers: ::Hash[String, String]?,
44
+ ?body: nil,
45
+ ?request: nil,
46
+ ?response: nil,
47
+ ?message: String?
48
+ ) -> void
49
+ end
50
+
51
+ class APITimeoutError < CheckoutIntents::Errors::APIConnectionError
52
+ def initialize: (
53
+ url: URI::Generic,
54
+ ?status: nil,
55
+ ?headers: ::Hash[String, String]?,
56
+ ?body: nil,
57
+ ?request: nil,
58
+ ?response: nil,
59
+ ?message: String?
60
+ ) -> void
61
+ end
62
+
63
+ class APIStatusError < CheckoutIntents::Errors::APIError
64
+ def self.for: (
65
+ url: URI::Generic,
66
+ status: Integer,
67
+ headers: ::Hash[String, String]?,
68
+ body: Object?,
69
+ request: nil,
70
+ response: nil,
71
+ ?message: String?
72
+ ) -> instance
73
+
74
+ def initialize: (
75
+ url: URI::Generic,
76
+ status: Integer,
77
+ headers: ::Hash[String, String]?,
78
+ body: Object?,
79
+ request: nil,
80
+ response: nil,
81
+ ?message: String?
82
+ ) -> void
83
+ end
84
+
85
+ class BadRequestError < CheckoutIntents::Errors::APIStatusError
86
+ HTTP_STATUS: 400
87
+ end
88
+
89
+ class AuthenticationError < CheckoutIntents::Errors::APIStatusError
90
+ HTTP_STATUS: 401
91
+ end
92
+
93
+ class PermissionDeniedError < CheckoutIntents::Errors::APIStatusError
94
+ HTTP_STATUS: 403
95
+ end
96
+
97
+ class NotFoundError < CheckoutIntents::Errors::APIStatusError
98
+ HTTP_STATUS: 404
99
+ end
100
+
101
+ class ConflictError < CheckoutIntents::Errors::APIStatusError
102
+ HTTP_STATUS: 409
103
+ end
104
+
105
+ class UnprocessableEntityError < CheckoutIntents::Errors::APIStatusError
106
+ HTTP_STATUS: 422
107
+ end
108
+
109
+ class RateLimitError < CheckoutIntents::Errors::APIStatusError
110
+ HTTP_STATUS: 429
111
+ end
112
+
113
+ class InternalServerError < CheckoutIntents::Errors::APIStatusError
114
+ HTTP_STATUS: Range[Integer]
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,21 @@
1
+ module CheckoutIntents
2
+ class FilePart
3
+ attr_reader content: Pathname | StringIO | IO | String
4
+
5
+ attr_reader content_type: String?
6
+
7
+ attr_reader filename: String?
8
+
9
+ private def read: -> String
10
+
11
+ def to_json: (*top a) -> String
12
+
13
+ def to_yaml: (*top a) -> String
14
+
15
+ def initialize: (
16
+ Pathname | StringIO | IO | String content,
17
+ ?filename: (Pathname | String)?,
18
+ ?content_type: String?
19
+ ) -> void
20
+ end
21
+ end
@@ -0,0 +1,48 @@
1
+ module CheckoutIntents
2
+ module Internal
3
+ class CursorPagination[Elem]
4
+ include CheckoutIntents::Internal::Type::BasePage[Elem]
5
+
6
+ attr_accessor data: ::Array[Elem]?
7
+
8
+ attr_accessor page_info: PageInfo
9
+
10
+ def inspect: -> String
11
+
12
+ type page_info =
13
+ {
14
+ end_cursor: String?,
15
+ has_next_page: bool,
16
+ has_previous_page: bool,
17
+ start_cursor: String?
18
+ }
19
+ class PageInfo < CheckoutIntents::Internal::Type::BaseModel
20
+ attr_accessor end_cursor: String?
21
+
22
+ attr_reader has_next_page: bool?
23
+
24
+ def has_next_page=: (bool) -> bool
25
+
26
+ attr_reader has_previous_page: bool?
27
+
28
+ def has_previous_page=: (bool) -> bool
29
+
30
+ attr_accessor start_cursor: String?
31
+
32
+ def initialize: (
33
+ ?end_cursor: String?,
34
+ ?has_next_page: bool,
35
+ ?has_previous_page: bool,
36
+ ?start_cursor: String?
37
+ ) -> void
38
+
39
+ def to_hash: -> {
40
+ end_cursor: String?,
41
+ has_next_page: bool,
42
+ has_previous_page: bool,
43
+ start_cursor: String?
44
+ }
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,133 @@
1
+ module CheckoutIntents
2
+ module Internal
3
+ module Transport
4
+ class BaseClient
5
+ extend CheckoutIntents::Internal::Util::SorbetRuntimeSupport
6
+
7
+ type request_components =
8
+ {
9
+ method: Symbol,
10
+ path: String | ::Array[String],
11
+ query: ::Hash[String, (::Array[String] | String)?]?,
12
+ headers: ::Hash[String, (String
13
+ | Integer
14
+ | ::Array[(String | Integer)?])?]?,
15
+ body: top?,
16
+ unwrap: (Symbol
17
+ | Integer
18
+ | ::Array[(Symbol | Integer)]
19
+ | (^(top arg0) -> top))?,
20
+ page: Class?,
21
+ stream: Class?,
22
+ model: CheckoutIntents::Internal::Type::Converter::input?,
23
+ options: CheckoutIntents::request_opts?
24
+ }
25
+ type request_input =
26
+ {
27
+ method: Symbol,
28
+ url: URI::Generic,
29
+ headers: ::Hash[String, String],
30
+ body: top,
31
+ max_retries: Integer,
32
+ timeout: Float
33
+ }
34
+
35
+ MAX_REDIRECTS: 20
36
+
37
+ PLATFORM_HEADERS: ::Hash[String, String]
38
+
39
+ def self.validate!: (
40
+ CheckoutIntents::Internal::Transport::BaseClient::request_components req
41
+ ) -> void
42
+
43
+ def self.should_retry?: (
44
+ Integer status,
45
+ headers: ::Hash[String, String]
46
+ ) -> bool
47
+
48
+ def self.follow_redirect: (
49
+ CheckoutIntents::Internal::Transport::BaseClient::request_input request,
50
+ status: Integer,
51
+ response_headers: ::Hash[String, String]
52
+ ) -> CheckoutIntents::Internal::Transport::BaseClient::request_input
53
+
54
+ def self.reap_connection!: (
55
+ Integer | CheckoutIntents::Errors::APIConnectionError status,
56
+ stream: Enumerable[String]?
57
+ ) -> void
58
+
59
+ attr_reader base_url: URI::Generic
60
+
61
+ attr_reader timeout: Float
62
+
63
+ attr_reader max_retries: Integer
64
+
65
+ attr_reader initial_retry_delay: Float
66
+
67
+ attr_reader max_retry_delay: Float
68
+
69
+ attr_reader headers: ::Hash[String, String]
70
+
71
+ attr_reader idempotency_header: String?
72
+
73
+ # @api private
74
+ attr_reader requester: CheckoutIntents::Internal::Transport::PooledNetRequester
75
+
76
+ def initialize: (
77
+ base_url: String,
78
+ ?timeout: Float,
79
+ ?max_retries: Integer,
80
+ ?initial_retry_delay: Float,
81
+ ?max_retry_delay: Float,
82
+ ?headers: ::Hash[String, (String
83
+ | Integer
84
+ | ::Array[(String | Integer)?])?],
85
+ ?idempotency_header: String?
86
+ ) -> void
87
+
88
+ private def auth_headers: -> ::Hash[String, String]
89
+
90
+ private def user_agent: -> String
91
+
92
+ private def generate_idempotency_key: -> String
93
+
94
+ private def build_request: (
95
+ CheckoutIntents::Internal::Transport::BaseClient::request_components req,
96
+ CheckoutIntents::request_options opts
97
+ ) -> CheckoutIntents::Internal::Transport::BaseClient::request_input
98
+
99
+ private def retry_delay: (
100
+ ::Hash[String, String] headers,
101
+ retry_count: Integer
102
+ ) -> Float
103
+
104
+ def send_request: (
105
+ CheckoutIntents::Internal::Transport::BaseClient::request_input request,
106
+ redirect_count: Integer,
107
+ retry_count: Integer,
108
+ send_retry_header: bool
109
+ ) -> [Integer, top, Enumerable[String]]
110
+
111
+ def request: (
112
+ Symbol method,
113
+ String | ::Array[String] path,
114
+ ?query: ::Hash[String, (::Array[String] | String)?]?,
115
+ ?headers: ::Hash[String, (String
116
+ | Integer
117
+ | ::Array[(String | Integer)?])?]?,
118
+ ?body: top?,
119
+ ?unwrap: (Symbol
120
+ | Integer
121
+ | ::Array[(Symbol | Integer)]
122
+ | (^(top arg0) -> top))?,
123
+ ?page: Class?,
124
+ ?stream: Class?,
125
+ ?model: CheckoutIntents::Internal::Type::Converter::input?,
126
+ ?options: CheckoutIntents::request_opts?
127
+ ) -> top
128
+
129
+ def inspect: -> String
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,48 @@
1
+ module CheckoutIntents
2
+ module Internal
3
+ module Transport
4
+ class PooledNetRequester
5
+ extend CheckoutIntents::Internal::Util::SorbetRuntimeSupport
6
+
7
+ type request =
8
+ {
9
+ method: Symbol,
10
+ url: URI::Generic,
11
+ headers: ::Hash[String, String],
12
+ body: top,
13
+ deadline: Float
14
+ }
15
+
16
+ KEEP_ALIVE_TIMEOUT: 30
17
+
18
+ DEFAULT_MAX_CONNECTIONS: Integer
19
+
20
+ def self.connect: (
21
+ cert_store: OpenSSL::X509::Store,
22
+ url: URI::Generic
23
+ ) -> top
24
+
25
+ def self.calibrate_socket_timeout: (top conn, Float deadline) -> void
26
+
27
+ def self.build_request: (
28
+ CheckoutIntents::Internal::Transport::PooledNetRequester::request request
29
+ ) {
30
+ (String arg0) -> void
31
+ } -> [top, (^-> void)]
32
+
33
+ private def with_pool: (
34
+ URI::Generic url,
35
+ deadline: Float
36
+ ) {
37
+ (top arg0) -> void
38
+ } -> void
39
+
40
+ def execute: (
41
+ CheckoutIntents::Internal::Transport::PooledNetRequester::request request
42
+ ) -> [Integer, top, Enumerable[String]]
43
+
44
+ def initialize: (?size: Integer) -> void
45
+ end
46
+ end
47
+ end
48
+ end