terminal-shop 1.6.0 → 1.8.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/README.md +3 -1
- data/lib/terminal-shop/base_client.rb +36 -46
- data/lib/terminal-shop/base_model.rb +88 -128
- data/lib/terminal-shop/base_page.rb +18 -18
- data/lib/terminal-shop/client.rb +1 -3
- data/lib/terminal-shop/errors.rb +12 -17
- data/lib/terminal-shop/extern.rb +1 -4
- data/lib/terminal-shop/models/region.rb +15 -0
- data/lib/terminal-shop/models/subscription.rb +6 -0
- data/lib/terminal-shop/models/view_init_response.rb +3 -13
- data/lib/terminal-shop/pooled_net_requester.rb +19 -21
- data/lib/terminal-shop/request_options.rb +4 -11
- data/lib/terminal-shop/resources/address.rb +0 -5
- data/lib/terminal-shop/resources/app.rb +0 -5
- data/lib/terminal-shop/resources/card.rb +0 -6
- data/lib/terminal-shop/resources/cart.rb +0 -7
- data/lib/terminal-shop/resources/email.rb +0 -2
- data/lib/terminal-shop/resources/order.rb +0 -4
- data/lib/terminal-shop/resources/product.rb +0 -3
- data/lib/terminal-shop/resources/profile.rb +0 -3
- data/lib/terminal-shop/resources/subscription.rb +0 -5
- data/lib/terminal-shop/resources/token.rb +0 -5
- data/lib/terminal-shop/resources/view.rb +0 -2
- data/lib/terminal-shop/util.rb +44 -71
- data/lib/terminal-shop/version.rb +1 -1
- data/lib/terminal-shop.rb +2 -0
- data/manifest.yaml +1 -0
- data/rbi/lib/terminal-shop/base_client.rbi +23 -0
- data/rbi/lib/terminal-shop/base_model.rbi +178 -52
- data/rbi/lib/terminal-shop/base_page.rbi +1 -2
- data/rbi/lib/terminal-shop/client.rbi +11 -0
- data/rbi/lib/terminal-shop/errors.rbi +33 -0
- data/rbi/lib/terminal-shop/extern.rbi +1 -1
- data/rbi/lib/terminal-shop/models/address.rbi +10 -0
- data/rbi/lib/terminal-shop/models/address_create_params.rbi +8 -0
- data/rbi/lib/terminal-shop/models/address_create_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/address_get_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/address_list_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/app.rbi +5 -0
- data/rbi/lib/terminal-shop/models/app_create_response.rbi +2 -0
- data/rbi/lib/terminal-shop/models/app_get_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/app_list_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/card.rbi +8 -0
- data/rbi/lib/terminal-shop/models/card_collect_response.rbi +4 -0
- data/rbi/lib/terminal-shop/models/card_create_params.rbi +2 -0
- data/rbi/lib/terminal-shop/models/card_create_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/card_get_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/card_list_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/cart.rbi +19 -0
- data/rbi/lib/terminal-shop/models/cart_convert_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/cart_get_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/cart_set_address_params.rbi +1 -0
- data/rbi/lib/terminal-shop/models/cart_set_card_params.rbi +1 -0
- data/rbi/lib/terminal-shop/models/cart_set_item_params.rbi +2 -0
- data/rbi/lib/terminal-shop/models/cart_set_item_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/email_create_params.rbi +1 -0
- data/rbi/lib/terminal-shop/models/order.rbi +28 -0
- data/rbi/lib/terminal-shop/models/order_create_params.rbi +3 -0
- data/rbi/lib/terminal-shop/models/order_create_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/order_get_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/order_list_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/product.rbi +12 -6
- data/rbi/lib/terminal-shop/models/product_get_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/product_list_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/product_variant.rbi +4 -0
- data/rbi/lib/terminal-shop/models/profile.rbi +8 -0
- data/rbi/lib/terminal-shop/models/profile_me_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/profile_update_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/region.rbi +15 -0
- data/rbi/lib/terminal-shop/models/subscription.rbi +18 -11
- data/rbi/lib/terminal-shop/models/subscription_get_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/subscription_list_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/token.rbi +5 -0
- data/rbi/lib/terminal-shop/models/token_create_response.rbi +3 -0
- data/rbi/lib/terminal-shop/models/token_get_response.rbi +2 -0
- data/rbi/lib/terminal-shop/models/token_list_response.rbi +1 -0
- data/rbi/lib/terminal-shop/models/view_init_response.rbi +5 -13
- data/rbi/lib/terminal-shop/pooled_net_requester.rbi +10 -3
- data/rbi/lib/terminal-shop/request_options.rbi +21 -2
- data/rbi/lib/terminal-shop/resources/address.rbi +22 -2
- data/rbi/lib/terminal-shop/resources/app.rbi +14 -2
- data/rbi/lib/terminal-shop/resources/card.rbi +22 -3
- data/rbi/lib/terminal-shop/resources/cart.rbi +23 -3
- data/rbi/lib/terminal-shop/resources/email.rbi +6 -1
- data/rbi/lib/terminal-shop/resources/order.rbi +17 -2
- data/rbi/lib/terminal-shop/resources/product.rbi +7 -1
- data/rbi/lib/terminal-shop/resources/profile.rbi +2 -0
- data/rbi/lib/terminal-shop/resources/subscription.rbi +21 -2
- data/rbi/lib/terminal-shop/resources/token.rbi +14 -2
- data/rbi/lib/terminal-shop/resources/view.rbi +2 -0
- data/rbi/lib/terminal-shop/util.rbi +55 -8
- data/rbi/lib/terminal-shop/version.rbi +1 -1
- data/sig/terminal-shop/base_client.rbs +6 -1
- data/sig/terminal-shop/base_model.rbs +8 -6
- data/sig/terminal-shop/errors.rbs +4 -4
- data/sig/terminal-shop/models/region.rbs +12 -0
- data/sig/terminal-shop/models/subscription.rbs +1 -1
- data/sig/terminal-shop/models/view_init_response.rbs +3 -12
- data/sig/terminal-shop/pooled_net_requester.rbs +7 -2
- data/sig/terminal-shop/util.rbs +4 -4
- data/sig/terminal-shop/version.rbs +1 -1
- metadata +7 -4
@@ -1,6 +1,7 @@
|
|
1
1
|
# typed: strong
|
2
2
|
|
3
3
|
module TerminalShop
|
4
|
+
# @api private
|
4
5
|
class BaseClient
|
5
6
|
abstract!
|
6
7
|
|
@@ -44,16 +45,19 @@ module TerminalShop
|
|
44
45
|
PLATFORM_HEADERS = T::Hash[String, String]
|
45
46
|
|
46
47
|
class << self
|
48
|
+
# @api private
|
47
49
|
sig { params(req: TerminalShop::BaseClient::RequestComponentsShape).void }
|
48
50
|
def validate!(req)
|
49
51
|
end
|
50
52
|
|
53
|
+
# @api private
|
51
54
|
sig do
|
52
55
|
params(status: Integer, headers: T.any(T::Hash[String, String], Net::HTTPHeader)).returns(T::Boolean)
|
53
56
|
end
|
54
57
|
def should_retry?(status, headers:)
|
55
58
|
end
|
56
59
|
|
60
|
+
# @api private
|
57
61
|
sig do
|
58
62
|
params(
|
59
63
|
request: TerminalShop::BaseClient::RequestInputShape,
|
@@ -64,6 +68,17 @@ module TerminalShop
|
|
64
68
|
end
|
65
69
|
def follow_redirect(request, status:, response_headers:)
|
66
70
|
end
|
71
|
+
|
72
|
+
# @api private
|
73
|
+
sig do
|
74
|
+
params(
|
75
|
+
status: T.any(Integer, TerminalShop::APIConnectionError),
|
76
|
+
stream: T.nilable(T::Enumerable[String])
|
77
|
+
)
|
78
|
+
.void
|
79
|
+
end
|
80
|
+
def reap_connection!(status, stream:)
|
81
|
+
end
|
67
82
|
end
|
68
83
|
|
69
84
|
sig { returns(T.anything) }
|
@@ -74,6 +89,7 @@ module TerminalShop
|
|
74
89
|
def requester=(_)
|
75
90
|
end
|
76
91
|
|
92
|
+
# @api private
|
77
93
|
sig do
|
78
94
|
params(
|
79
95
|
base_url: String,
|
@@ -98,14 +114,17 @@ module TerminalShop
|
|
98
114
|
)
|
99
115
|
end
|
100
116
|
|
117
|
+
# @api private
|
101
118
|
sig { overridable.returns(T::Hash[String, String]) }
|
102
119
|
private def auth_headers
|
103
120
|
end
|
104
121
|
|
122
|
+
# @api private
|
105
123
|
sig { returns(String) }
|
106
124
|
private def generate_idempotency_key
|
107
125
|
end
|
108
126
|
|
127
|
+
# @api private
|
109
128
|
sig do
|
110
129
|
overridable
|
111
130
|
.params(req: TerminalShop::BaseClient::RequestComponentsShape, opts: T::Hash[Symbol, T.anything])
|
@@ -114,10 +133,12 @@ module TerminalShop
|
|
114
133
|
private def build_request(req, opts)
|
115
134
|
end
|
116
135
|
|
136
|
+
# @api private
|
117
137
|
sig { params(headers: T::Hash[String, String], retry_count: Integer).returns(Float) }
|
118
138
|
private def retry_delay(headers, retry_count:)
|
119
139
|
end
|
120
140
|
|
141
|
+
# @api private
|
121
142
|
sig do
|
122
143
|
params(
|
123
144
|
request: TerminalShop::BaseClient::RequestInputShape,
|
@@ -130,6 +151,8 @@ module TerminalShop
|
|
130
151
|
private def send_request(request, redirect_count:, retry_count:, send_retry_header:)
|
131
152
|
end
|
132
153
|
|
154
|
+
# Execute the request specified by `req`. This is the method that all resource
|
155
|
+
# methods call into.
|
133
156
|
sig do
|
134
157
|
params(
|
135
158
|
method: Symbol,
|
@@ -1,19 +1,21 @@
|
|
1
1
|
# typed: strong
|
2
2
|
|
3
3
|
module TerminalShop
|
4
|
+
# @api private
|
4
5
|
module Converter
|
5
|
-
abstract!
|
6
|
-
|
7
6
|
Input = T.type_alias { T.any(TerminalShop::Converter, T::Class[T.anything]) }
|
8
7
|
|
8
|
+
# @api private
|
9
9
|
sig { overridable.params(value: T.anything).returns(T.anything) }
|
10
10
|
def coerce(value)
|
11
11
|
end
|
12
12
|
|
13
|
+
# @api private
|
13
14
|
sig { overridable.params(value: T.anything).returns(T.anything) }
|
14
15
|
def dump(value)
|
15
16
|
end
|
16
17
|
|
18
|
+
# @api private
|
17
19
|
sig do
|
18
20
|
overridable
|
19
21
|
.params(value: T.anything)
|
@@ -23,6 +25,7 @@ module TerminalShop
|
|
23
25
|
end
|
24
26
|
|
25
27
|
class << self
|
28
|
+
# @api private
|
26
29
|
sig do
|
27
30
|
params(
|
28
31
|
spec: T.any(
|
@@ -40,43 +43,69 @@ module TerminalShop
|
|
40
43
|
def self.type_info(spec)
|
41
44
|
end
|
42
45
|
|
46
|
+
# @api private
|
47
|
+
#
|
48
|
+
# Based on `target`, transform `value` into `target`, to the extent possible:
|
49
|
+
#
|
50
|
+
# 1. if the given `value` conforms to `target` already, return the given `value`
|
51
|
+
# 2. if it's possible and safe to convert the given `value` to `target`, then the
|
52
|
+
# converted value
|
53
|
+
# 3. otherwise, the given `value` unaltered
|
43
54
|
sig { params(target: TerminalShop::Converter::Input, value: T.anything).returns(T.anything) }
|
44
55
|
def self.coerce(target, value)
|
45
56
|
end
|
46
57
|
|
58
|
+
# @api private
|
47
59
|
sig { params(target: TerminalShop::Converter::Input, value: T.anything).returns(T.anything) }
|
48
60
|
def self.dump(target, value)
|
49
61
|
end
|
50
62
|
|
63
|
+
# @api private
|
64
|
+
#
|
65
|
+
# The underlying algorithm for computing maximal compatibility is subject to
|
66
|
+
# future improvements.
|
67
|
+
#
|
68
|
+
# Similar to `#.coerce`, used to determine the best union variant to decode into.
|
69
|
+
#
|
70
|
+
# 1. determine if strict-ish coercion is possible
|
71
|
+
# 2. return either result of successful coercion or if loose coercion is possible
|
72
|
+
# 3. return a score for recursively tallied count for fields that can be coerced
|
51
73
|
sig { params(target: TerminalShop::Converter::Input, value: T.anything).returns(T.anything) }
|
52
74
|
def self.try_strict_coerce(target, value)
|
53
75
|
end
|
54
76
|
end
|
55
77
|
end
|
56
78
|
|
79
|
+
# @api private
|
80
|
+
#
|
81
|
+
# When we don't know what to expect for the value.
|
57
82
|
class Unknown
|
58
|
-
abstract!
|
59
|
-
|
60
83
|
extend TerminalShop::Converter
|
61
84
|
|
62
|
-
|
85
|
+
abstract!
|
86
|
+
final!
|
87
|
+
|
88
|
+
sig(:final) { params(other: T.anything).returns(T::Boolean) }
|
63
89
|
def self.===(other)
|
64
90
|
end
|
65
91
|
|
66
|
-
sig { params(other: T.anything).returns(T::Boolean) }
|
92
|
+
sig(:final) { params(other: T.anything).returns(T::Boolean) }
|
67
93
|
def self.==(other)
|
68
94
|
end
|
69
95
|
|
70
96
|
class << self
|
71
|
-
|
97
|
+
# @api private
|
98
|
+
sig(:final) { override.params(value: T.anything).returns(T.anything) }
|
72
99
|
def coerce(value)
|
73
100
|
end
|
74
101
|
|
75
|
-
|
102
|
+
# @api private
|
103
|
+
sig(:final) { override.params(value: T.anything).returns(T.anything) }
|
76
104
|
def dump(value)
|
77
105
|
end
|
78
106
|
|
79
|
-
|
107
|
+
# @api private
|
108
|
+
sig(:final) do
|
80
109
|
override
|
81
110
|
.params(value: T.anything)
|
82
111
|
.returns(T.any([T::Boolean, T.anything, NilClass], [T::Boolean, T::Boolean, Integer]))
|
@@ -86,29 +115,40 @@ module TerminalShop
|
|
86
115
|
end
|
87
116
|
end
|
88
117
|
|
118
|
+
# @api private
|
119
|
+
#
|
120
|
+
# Ruby has no Boolean class; this is something for models to refer to.
|
89
121
|
class BooleanModel
|
90
|
-
abstract!
|
91
|
-
|
92
122
|
extend TerminalShop::Converter
|
93
123
|
|
94
|
-
|
124
|
+
abstract!
|
125
|
+
final!
|
126
|
+
|
127
|
+
sig(:final) { params(other: T.anything).returns(T::Boolean) }
|
95
128
|
def self.===(other)
|
96
129
|
end
|
97
130
|
|
98
|
-
sig { params(other: T.anything).returns(T::Boolean) }
|
131
|
+
sig(:final) { params(other: T.anything).returns(T::Boolean) }
|
99
132
|
def self.==(other)
|
100
133
|
end
|
101
134
|
|
102
135
|
class << self
|
103
|
-
|
136
|
+
# @api private
|
137
|
+
sig(:final) do
|
138
|
+
override.params(value: T.any(T::Boolean, T.anything)).returns(T.any(T::Boolean, T.anything))
|
139
|
+
end
|
104
140
|
def coerce(value)
|
105
141
|
end
|
106
142
|
|
107
|
-
|
143
|
+
# @api private
|
144
|
+
sig(:final) do
|
145
|
+
override.params(value: T.any(T::Boolean, T.anything)).returns(T.any(T::Boolean, T.anything))
|
146
|
+
end
|
108
147
|
def dump(value)
|
109
148
|
end
|
110
149
|
|
111
|
-
|
150
|
+
# @api private
|
151
|
+
sig(:final) do
|
112
152
|
override
|
113
153
|
.params(value: T.anything)
|
114
154
|
.returns(T.any([T::Boolean, T.anything, NilClass], [T::Boolean, T::Boolean, Integer]))
|
@@ -118,16 +158,34 @@ module TerminalShop
|
|
118
158
|
end
|
119
159
|
end
|
120
160
|
|
161
|
+
# @api private
|
162
|
+
#
|
163
|
+
# A value from among a specified list of options. OpenAPI enum values map to Ruby
|
164
|
+
# values in the SDK as follows:
|
165
|
+
#
|
166
|
+
# 1. boolean => true | false
|
167
|
+
# 2. integer => Integer
|
168
|
+
# 3. float => Float
|
169
|
+
# 4. string => Symbol
|
170
|
+
#
|
171
|
+
# We can therefore convert string values to Symbols, but can't convert other
|
172
|
+
# values safely.
|
121
173
|
class Enum
|
174
|
+
extend TerminalShop::Converter
|
175
|
+
|
122
176
|
abstract!
|
123
177
|
|
124
|
-
|
178
|
+
Value = type_template(:out)
|
125
179
|
|
126
180
|
class << self
|
127
|
-
|
181
|
+
# All of the valid Symbol values for this enum.
|
182
|
+
sig { overridable.returns(T::Array[Value]) }
|
128
183
|
def values
|
129
184
|
end
|
130
185
|
|
186
|
+
# @api private
|
187
|
+
#
|
188
|
+
# Guard against thread safety issues by instantiating `@values`.
|
131
189
|
sig { void }
|
132
190
|
private def finalize!
|
133
191
|
end
|
@@ -142,14 +200,17 @@ module TerminalShop
|
|
142
200
|
end
|
143
201
|
|
144
202
|
class << self
|
203
|
+
# @api private
|
145
204
|
sig { override.params(value: T.any(String, Symbol, T.anything)).returns(T.any(Symbol, T.anything)) }
|
146
205
|
def coerce(value)
|
147
206
|
end
|
148
207
|
|
208
|
+
# @api private
|
149
209
|
sig { override.params(value: T.any(Symbol, T.anything)).returns(T.any(Symbol, T.anything)) }
|
150
210
|
def dump(value)
|
151
211
|
end
|
152
212
|
|
213
|
+
# @api private
|
153
214
|
sig do
|
154
215
|
override
|
155
216
|
.params(value: T.anything)
|
@@ -160,44 +221,50 @@ module TerminalShop
|
|
160
221
|
end
|
161
222
|
end
|
162
223
|
|
224
|
+
# @api private
|
163
225
|
class Union
|
226
|
+
extend TerminalShop::Converter
|
227
|
+
|
164
228
|
abstract!
|
165
229
|
|
166
|
-
|
230
|
+
Variants = type_template(:out)
|
167
231
|
|
168
232
|
class << self
|
169
|
-
|
233
|
+
# @api private
|
234
|
+
#
|
235
|
+
# All of the specified variant info for this union.
|
236
|
+
sig { returns(T::Array[[T.nilable(Symbol), T.proc.returns(Variants)]]) }
|
170
237
|
private def known_variants
|
171
238
|
end
|
172
239
|
|
173
|
-
|
174
|
-
|
240
|
+
# @api private
|
241
|
+
sig { returns(T::Array[[T.nilable(Symbol), Variants]]) }
|
242
|
+
protected def derefed_variants
|
175
243
|
end
|
176
244
|
|
245
|
+
# All of the specified variants for this union.
|
246
|
+
sig { overridable.returns(T::Array[Variants]) }
|
247
|
+
def variants
|
248
|
+
end
|
249
|
+
|
250
|
+
# @api private
|
177
251
|
sig { params(property: Symbol).void }
|
178
252
|
private def discriminator(property)
|
179
253
|
end
|
180
254
|
|
255
|
+
# @api private
|
181
256
|
sig do
|
182
257
|
params(
|
183
|
-
key: T.any(
|
184
|
-
|
185
|
-
T::Hash[Symbol, T.anything],
|
186
|
-
T.proc.returns(TerminalShop::Converter::Input),
|
187
|
-
TerminalShop::Converter::Input
|
188
|
-
),
|
189
|
-
spec: T.any(
|
190
|
-
T::Hash[Symbol, T.anything],
|
191
|
-
T.proc.returns(TerminalShop::Converter::Input),
|
192
|
-
TerminalShop::Converter::Input
|
193
|
-
)
|
258
|
+
key: T.any(Symbol, T::Hash[Symbol, T.anything], T.proc.returns(Variants), Variants),
|
259
|
+
spec: T.any(T::Hash[Symbol, T.anything], T.proc.returns(Variants), Variants)
|
194
260
|
)
|
195
261
|
.void
|
196
262
|
end
|
197
263
|
private def variant(key, spec = nil)
|
198
264
|
end
|
199
265
|
|
200
|
-
|
266
|
+
# @api private
|
267
|
+
sig { params(value: T.anything).returns(T.nilable(Variants)) }
|
201
268
|
private def resolve_variant(value)
|
202
269
|
end
|
203
270
|
end
|
@@ -211,14 +278,17 @@ module TerminalShop
|
|
211
278
|
end
|
212
279
|
|
213
280
|
class << self
|
281
|
+
# @api private
|
214
282
|
sig { override.params(value: T.anything).returns(T.anything) }
|
215
283
|
def coerce(value)
|
216
284
|
end
|
217
285
|
|
286
|
+
# @api private
|
218
287
|
sig { override.params(value: T.anything).returns(T.anything) }
|
219
288
|
def dump(value)
|
220
289
|
end
|
221
290
|
|
291
|
+
# @api private
|
222
292
|
sig do
|
223
293
|
override
|
224
294
|
.params(value: T.anything)
|
@@ -229,20 +299,27 @@ module TerminalShop
|
|
229
299
|
end
|
230
300
|
end
|
231
301
|
|
302
|
+
# @api private
|
303
|
+
#
|
304
|
+
# Array of items of a given type.
|
232
305
|
class ArrayOf
|
306
|
+
include TerminalShop::Converter
|
307
|
+
|
233
308
|
abstract!
|
309
|
+
final!
|
234
310
|
|
235
|
-
|
311
|
+
Elem = type_member(:out)
|
236
312
|
|
237
|
-
sig { params(other: T.anything).returns(T::Boolean) }
|
313
|
+
sig(:final) { params(other: T.anything).returns(T::Boolean) }
|
238
314
|
def ===(other)
|
239
315
|
end
|
240
316
|
|
241
|
-
sig { params(other: T.anything).returns(T::Boolean) }
|
317
|
+
sig(:final) { params(other: T.anything).returns(T::Boolean) }
|
242
318
|
def ==(other)
|
243
319
|
end
|
244
320
|
|
245
|
-
|
321
|
+
# @api private
|
322
|
+
sig(:final) do
|
246
323
|
override
|
247
324
|
.params(value: T.any(T::Enumerable[T.anything], T.anything))
|
248
325
|
.returns(T.any(T::Array[T.anything], T.anything))
|
@@ -250,7 +327,8 @@ module TerminalShop
|
|
250
327
|
def coerce(value)
|
251
328
|
end
|
252
329
|
|
253
|
-
|
330
|
+
# @api private
|
331
|
+
sig(:final) do
|
254
332
|
override
|
255
333
|
.params(value: T.any(T::Enumerable[T.anything], T.anything))
|
256
334
|
.returns(T.any(T::Array[T.anything], T.anything))
|
@@ -258,7 +336,8 @@ module TerminalShop
|
|
258
336
|
def dump(value)
|
259
337
|
end
|
260
338
|
|
261
|
-
|
339
|
+
# @api private
|
340
|
+
sig(:final) do
|
262
341
|
override
|
263
342
|
.params(value: T.anything)
|
264
343
|
.returns(T.any([T::Boolean, T.anything, NilClass], [T::Boolean, T::Boolean, Integer]))
|
@@ -266,11 +345,13 @@ module TerminalShop
|
|
266
345
|
def try_strict_coerce(value)
|
267
346
|
end
|
268
347
|
|
269
|
-
|
348
|
+
# @api private
|
349
|
+
sig(:final) { returns(Elem) }
|
270
350
|
protected def item_type
|
271
351
|
end
|
272
352
|
|
273
|
-
|
353
|
+
# @api private
|
354
|
+
sig(:final) do
|
274
355
|
params(
|
275
356
|
type_info: T.any(
|
276
357
|
T::Hash[Symbol, T.anything],
|
@@ -285,20 +366,27 @@ module TerminalShop
|
|
285
366
|
end
|
286
367
|
end
|
287
368
|
|
369
|
+
# @api private
|
370
|
+
#
|
371
|
+
# Hash of items of a given type.
|
288
372
|
class HashOf
|
373
|
+
include TerminalShop::Converter
|
374
|
+
|
289
375
|
abstract!
|
376
|
+
final!
|
290
377
|
|
291
|
-
|
378
|
+
Elem = type_member(:out)
|
292
379
|
|
293
|
-
sig { params(other: T.anything).returns(T::Boolean) }
|
380
|
+
sig(:final) { params(other: T.anything).returns(T::Boolean) }
|
294
381
|
def ===(other)
|
295
382
|
end
|
296
383
|
|
297
|
-
sig { params(other: T.anything).returns(T::Boolean) }
|
384
|
+
sig(:final) { params(other: T.anything).returns(T::Boolean) }
|
298
385
|
def ==(other)
|
299
386
|
end
|
300
387
|
|
301
|
-
|
388
|
+
# @api private
|
389
|
+
sig(:final) do
|
302
390
|
override
|
303
391
|
.params(value: T.any(T::Hash[T.anything, T.anything], T.anything))
|
304
392
|
.returns(T.any(T::Hash[Symbol, T.anything], T.anything))
|
@@ -306,7 +394,8 @@ module TerminalShop
|
|
306
394
|
def coerce(value)
|
307
395
|
end
|
308
396
|
|
309
|
-
|
397
|
+
# @api private
|
398
|
+
sig(:final) do
|
310
399
|
override
|
311
400
|
.params(value: T.any(T::Hash[T.anything, T.anything], T.anything))
|
312
401
|
.returns(T.any(T::Hash[Symbol, T.anything], T.anything))
|
@@ -314,7 +403,8 @@ module TerminalShop
|
|
314
403
|
def dump(value)
|
315
404
|
end
|
316
405
|
|
317
|
-
|
406
|
+
# @api private
|
407
|
+
sig(:final) do
|
318
408
|
override
|
319
409
|
.params(value: T.anything)
|
320
410
|
.returns(T.any([T::Boolean, T.anything, NilClass], [T::Boolean, T::Boolean, Integer]))
|
@@ -322,11 +412,13 @@ module TerminalShop
|
|
322
412
|
def try_strict_coerce(value)
|
323
413
|
end
|
324
414
|
|
325
|
-
|
415
|
+
# @api private
|
416
|
+
sig(:final) { returns(Elem) }
|
326
417
|
protected def item_type
|
327
418
|
end
|
328
419
|
|
329
|
-
|
420
|
+
# @api private
|
421
|
+
sig(:final) do
|
330
422
|
params(
|
331
423
|
type_info: T.any(
|
332
424
|
T::Hash[Symbol, T.anything],
|
@@ -342,13 +434,17 @@ module TerminalShop
|
|
342
434
|
end
|
343
435
|
|
344
436
|
class BaseModel
|
345
|
-
abstract!
|
346
|
-
|
347
437
|
extend TerminalShop::Converter
|
348
438
|
|
439
|
+
abstract!
|
440
|
+
|
349
441
|
KnownFieldShape = T.type_alias { {mode: T.nilable(Symbol), required: T::Boolean} }
|
350
442
|
|
351
443
|
class << self
|
444
|
+
# @api private
|
445
|
+
#
|
446
|
+
# Assumes superclass fields are totally defined before fields are accessed /
|
447
|
+
# defined on subclasses.
|
352
448
|
sig do
|
353
449
|
returns(
|
354
450
|
T::Hash[
|
@@ -363,6 +459,7 @@ module TerminalShop
|
|
363
459
|
def known_fields
|
364
460
|
end
|
365
461
|
|
462
|
+
# @api private
|
366
463
|
sig do
|
367
464
|
returns(
|
368
465
|
T::Hash[Symbol,
|
@@ -372,10 +469,12 @@ module TerminalShop
|
|
372
469
|
def fields
|
373
470
|
end
|
374
471
|
|
472
|
+
# @api private
|
375
473
|
sig { returns(T::Hash[Symbol, T.proc.returns(T::Class[T.anything])]) }
|
376
474
|
def defaults
|
377
475
|
end
|
378
476
|
|
477
|
+
# @api private
|
379
478
|
sig do
|
380
479
|
params(
|
381
480
|
name_sym: Symbol,
|
@@ -398,6 +497,7 @@ module TerminalShop
|
|
398
497
|
private def add_field(name_sym, required:, type_info:, spec:)
|
399
498
|
end
|
400
499
|
|
500
|
+
# @api private
|
401
501
|
sig do
|
402
502
|
params(
|
403
503
|
name_sym: Symbol,
|
@@ -413,6 +513,7 @@ module TerminalShop
|
|
413
513
|
def required(name_sym, type_info, spec = {})
|
414
514
|
end
|
415
515
|
|
516
|
+
# @api private
|
416
517
|
sig do
|
417
518
|
params(
|
418
519
|
name_sym: Symbol,
|
@@ -428,10 +529,17 @@ module TerminalShop
|
|
428
529
|
def optional(name_sym, type_info, spec = {})
|
429
530
|
end
|
430
531
|
|
532
|
+
# @api private
|
533
|
+
#
|
534
|
+
# `request_only` attributes not excluded from `.#coerce` when receiving responses
|
535
|
+
# even if well behaved servers should not send them
|
431
536
|
sig { params(blk: T.proc.void).void }
|
432
537
|
private def request_only(&blk)
|
433
538
|
end
|
434
539
|
|
540
|
+
# @api private
|
541
|
+
#
|
542
|
+
# `response_only` attributes are omitted from `.#dump` when making requests
|
435
543
|
sig { params(blk: T.proc.void).void }
|
436
544
|
private def response_only(&blk)
|
437
545
|
end
|
@@ -442,6 +550,7 @@ module TerminalShop
|
|
442
550
|
end
|
443
551
|
|
444
552
|
class << self
|
553
|
+
# @api private
|
445
554
|
sig do
|
446
555
|
override
|
447
556
|
.params(value: T.any(TerminalShop::BaseModel, T::Hash[T.anything, T.anything], T.anything))
|
@@ -450,6 +559,7 @@ module TerminalShop
|
|
450
559
|
def coerce(value)
|
451
560
|
end
|
452
561
|
|
562
|
+
# @api private
|
453
563
|
sig do
|
454
564
|
override
|
455
565
|
.params(value: T.any(T.attached_class, T.anything))
|
@@ -458,6 +568,7 @@ module TerminalShop
|
|
458
568
|
def dump(value)
|
459
569
|
end
|
460
570
|
|
571
|
+
# @api private
|
461
572
|
sig do
|
462
573
|
override
|
463
574
|
.params(value: T.anything)
|
@@ -467,10 +578,24 @@ module TerminalShop
|
|
467
578
|
end
|
468
579
|
end
|
469
580
|
|
581
|
+
# Returns the raw value associated with the given key, if found. Otherwise, nil is
|
582
|
+
# returned.
|
583
|
+
#
|
584
|
+
# It is valid to lookup keys that are not in the API spec, for example to access
|
585
|
+
# undocumented features. This method does not parse response data into
|
586
|
+
# higher-level types. Lookup by anything other than a Symbol is an ArgumentError.
|
470
587
|
sig { params(key: Symbol).returns(T.nilable(T.anything)) }
|
471
588
|
def [](key)
|
472
589
|
end
|
473
590
|
|
591
|
+
# Returns a Hash of the data underlying this object. O(1)
|
592
|
+
#
|
593
|
+
# Keys are Symbols and values are the raw values from the response. The return
|
594
|
+
# value indicates which values were ever set on the object. i.e. there will be a
|
595
|
+
# key in this hash if they ever were, even if the set value was nil.
|
596
|
+
#
|
597
|
+
# This method is not recursive. The returned value is shared by the object, so it
|
598
|
+
# should not be mutated.
|
474
599
|
sig { overridable.returns(T::Hash[Symbol, T.anything]) }
|
475
600
|
def to_h
|
476
601
|
end
|
@@ -481,6 +606,7 @@ module TerminalShop
|
|
481
606
|
def deconstruct_keys(keys)
|
482
607
|
end
|
483
608
|
|
609
|
+
# Create a new instance of a model.
|
484
610
|
sig { params(data: T.any(T::Hash[Symbol, T.anything], T.self_type)).returns(T.attached_class) }
|
485
611
|
def self.new(data = {})
|
486
612
|
end
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
module TerminalShop
|
4
4
|
module BasePage
|
5
|
-
abstract!
|
6
|
-
|
7
5
|
Elem = type_member(:out)
|
8
6
|
|
9
7
|
sig { overridable.returns(T::Boolean) }
|
@@ -24,6 +22,7 @@ module TerminalShop
|
|
24
22
|
|
25
23
|
alias_method :enum_for, :to_enum
|
26
24
|
|
25
|
+
# @api private
|
27
26
|
sig do
|
28
27
|
params(
|
29
28
|
client: TerminalShop::BaseClient,
|
@@ -67,10 +67,12 @@ module TerminalShop
|
|
67
67
|
def view
|
68
68
|
end
|
69
69
|
|
70
|
+
# @api private
|
70
71
|
sig { override.returns(T::Hash[String, String]) }
|
71
72
|
private def auth_headers
|
72
73
|
end
|
73
74
|
|
75
|
+
# Creates and returns a new client for interacting with the API.
|
74
76
|
sig do
|
75
77
|
params(
|
76
78
|
environment: NilClass,
|
@@ -85,10 +87,19 @@ module TerminalShop
|
|
85
87
|
.returns(T.attached_class)
|
86
88
|
end
|
87
89
|
def self.new(
|
90
|
+
# Specifies the environment to use for the API.
|
91
|
+
#
|
92
|
+
# Each environment maps to a different base URL:
|
93
|
+
#
|
94
|
+
# - `production` corresponds to `https://api.terminal.shop/`
|
95
|
+
# - `dev` corresponds to `https://api.dev.terminal.shop/`
|
88
96
|
environment: nil,
|
97
|
+
# Override the default base URL for the API, e.g., `"https://api.example.com/v2/"`
|
89
98
|
base_url: nil,
|
99
|
+
# Defaults to `ENV["TERMINAL_BEARER_TOKEN"]`
|
90
100
|
bearer_token: ENV["TERMINAL_BEARER_TOKEN"],
|
91
101
|
app_id: nil,
|
102
|
+
# Max number of retries to attempt after a failed retryable request.
|
92
103
|
max_retries: DEFAULT_MAX_RETRIES,
|
93
104
|
timeout: DEFAULT_TIMEOUT_IN_SECONDS,
|
94
105
|
initial_retry_delay: DEFAULT_INITIAL_RETRY_DELAY,
|