lithic 0.1.0.pre.alpha.26 → 0.1.0.pre.alpha.27
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 +20 -0
- data/README.md +94 -54
- data/lib/lithic/internal/type/array_of.rb +8 -0
- data/lib/lithic/internal/type/base_model.rb +15 -0
- data/lib/lithic/internal/type/boolean.rb +8 -0
- data/lib/lithic/internal/type/enum.rb +12 -0
- data/lib/lithic/internal/type/file_input.rb +7 -0
- data/lib/lithic/internal/type/hash_of.rb +8 -0
- data/lib/lithic/internal/type/union.rb +12 -0
- data/lib/lithic/internal/type/unknown.rb +8 -0
- data/lib/lithic/internal/util.rb +45 -0
- data/lib/lithic/internal.rb +3 -0
- data/lib/lithic/models/account_holder_update_response.rb +0 -9
- data/lib/lithic/models/auth_rules/auth_rule_condition.rb +0 -4
- data/lib/lithic/models/auth_rules/v2_apply_response.rb +0 -20
- data/lib/lithic/models/auth_rules/v2_create_params.rb +0 -10
- data/lib/lithic/models/auth_rules/v2_create_response.rb +0 -20
- data/lib/lithic/models/auth_rules/v2_draft_params.rb +0 -10
- data/lib/lithic/models/auth_rules/v2_draft_response.rb +0 -20
- data/lib/lithic/models/auth_rules/v2_list_response.rb +0 -20
- data/lib/lithic/models/auth_rules/v2_promote_response.rb +0 -20
- data/lib/lithic/models/auth_rules/v2_retrieve_response.rb +0 -20
- data/lib/lithic/models/auth_rules/v2_update_response.rb +0 -20
- data/lib/lithic/models/auth_rules/velocity_limit_params.rb +0 -4
- data/lib/lithic/models.rb +30 -19
- data/lib/lithic/version.rb +1 -1
- data/rbi/lithic/internal/type/array_of.rbi +6 -0
- data/rbi/lithic/internal/type/base_model.rbi +5 -0
- data/rbi/lithic/internal/type/boolean.rbi +6 -0
- data/rbi/lithic/internal/type/enum.rbi +5 -0
- data/rbi/lithic/internal/type/file_input.rbi +5 -0
- data/rbi/lithic/internal/type/hash_of.rbi +6 -0
- data/rbi/lithic/internal/type/union.rbi +5 -0
- data/rbi/lithic/internal/type/unknown.rbi +6 -0
- data/rbi/lithic/internal/util.rbi +31 -0
- data/rbi/lithic/internal.rbi +3 -0
- data/rbi/lithic/models/auth_rules/auth_rule_condition.rbi +12 -4
- data/rbi/lithic/models/auth_rules/v2_apply_response.rbi +4 -20
- data/rbi/lithic/models/auth_rules/v2_create_response.rbi +4 -20
- data/rbi/lithic/models/auth_rules/v2_draft_response.rbi +4 -20
- data/rbi/lithic/models/auth_rules/v2_list_response.rbi +4 -20
- data/rbi/lithic/models/auth_rules/v2_promote_response.rbi +4 -20
- data/rbi/lithic/models/auth_rules/v2_retrieve_response.rbi +4 -20
- data/rbi/lithic/models/auth_rules/v2_update_response.rbi +4 -20
- data/rbi/lithic/resources/account_holders.rbi +1 -6
- data/sig/lithic/internal/type/array_of.rbs +3 -0
- data/sig/lithic/internal/type/base_model.rbs +2 -0
- data/sig/lithic/internal/type/boolean.rbs +3 -0
- data/sig/lithic/internal/type/enum.rbs +2 -0
- data/sig/lithic/internal/type/file_input.rbs +2 -0
- data/sig/lithic/internal/type/hash_of.rbs +3 -0
- data/sig/lithic/internal/type/union.rbs +2 -0
- data/sig/lithic/internal/type/unknown.rbs +3 -0
- data/sig/lithic/internal/util.rbs +12 -0
- data/sig/lithic/internal.rbs +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a598431f4650ca3d4dbe388399817b2ba7b07f77410c54bae03131474b46e553
|
4
|
+
data.tar.gz: 5f57edc9f9e7da78d4ae6b62e954ad0a23ad0f2169e4171d2e874fa9c719b96d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de7b42dcf1fc47a0c8b1fa4c0c684d6580615451c040739ce687903d66b670c6dea14108660e5b3034b34e869c90937a43e5cbfcddbb3ff2d9b175dbd7125ee7
|
7
|
+
data.tar.gz: 2fa17bc922b1004a138a95d906da737bfe16d909237d666ab8063dd0a4bdf09b1b7c8411b792f69730817e3a26774cfe14d03bc4a4f510eff8a94013c2d70c99
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.1.0-alpha.27 (2025-05-20)
|
4
|
+
|
5
|
+
Full Changelog: [v0.1.0-alpha.26...v0.1.0-alpha.27](https://github.com/lithic-com/lithic-ruby/compare/v0.1.0-alpha.26...v0.1.0-alpha.27)
|
6
|
+
|
7
|
+
### Bug Fixes
|
8
|
+
|
9
|
+
* correctly instantiate sorbet type aliases for enums and unions ([456477f](https://github.com/lithic-com/lithic-ruby/commit/456477fed1f46dd9ecfd278ddda29c642e5684f7))
|
10
|
+
|
11
|
+
|
12
|
+
### Chores
|
13
|
+
|
14
|
+
* refine Yard and Sorbet types and ensure linting is turned on for examples ([1c7093d](https://github.com/lithic-com/lithic-ruby/commit/1c7093dac0961af658685d5788c2b0dbe1871947))
|
15
|
+
* use sorbet union aliases where available ([68cbe7c](https://github.com/lithic-com/lithic-ruby/commit/68cbe7c8831d674ddb1080ca53ae1018966f1c87))
|
16
|
+
* whitespaces ([862a44f](https://github.com/lithic-com/lithic-ruby/commit/862a44f890c5b9d0034a99e2d09125f9a4551a1b))
|
17
|
+
|
18
|
+
|
19
|
+
### Documentation
|
20
|
+
|
21
|
+
* rewrite much of README.md for readability ([786647f](https://github.com/lithic-com/lithic-ruby/commit/786647f1e376849b800dfb59fdc941925590ab17))
|
22
|
+
|
3
23
|
## 0.1.0-alpha.26 (2025-05-14)
|
4
24
|
|
5
25
|
Full Changelog: [v0.1.0-alpha.25...v0.1.0-alpha.26](https://github.com/lithic-com/lithic-ruby/compare/v0.1.0-alpha.25...v0.1.0-alpha.26)
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Lithic Ruby API library
|
2
2
|
|
3
|
-
The Lithic Ruby library provides convenient access to the Lithic REST API from any Ruby 3.2.0+ application.
|
3
|
+
The Lithic Ruby library provides convenient access to the Lithic REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/lithic-com/lithic-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.
|
4
4
|
|
5
5
|
## Documentation
|
6
6
|
|
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
|
|
15
15
|
<!-- x-release-please-start-version -->
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
gem "lithic", "~> 0.1.0.pre.alpha.
|
18
|
+
gem "lithic", "~> 0.1.0.pre.alpha.27"
|
19
19
|
```
|
20
20
|
|
21
21
|
<!-- x-release-please-end -->
|
@@ -36,16 +36,6 @@ card = lithic.cards.create(type: "SINGLE_USE")
|
|
36
36
|
puts(card.token)
|
37
37
|
```
|
38
38
|
|
39
|
-
## Sorbet
|
40
|
-
|
41
|
-
This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`.
|
42
|
-
|
43
|
-
When using sorbet, it is recommended to use model classes as below. This provides stronger type checking and tooling integration.
|
44
|
-
|
45
|
-
```ruby
|
46
|
-
lithic.cards.create(type: "SINGLE_USE")
|
47
|
-
```
|
48
|
-
|
49
39
|
### Pagination
|
50
40
|
|
51
41
|
List methods in the Lithic API are paginated.
|
@@ -65,15 +55,30 @@ page.auto_paging_each do |card|
|
|
65
55
|
end
|
66
56
|
```
|
67
57
|
|
68
|
-
|
58
|
+
Alternatively, you can use the `#next_page?` and `#next_page` methods for more granular control working with pages.
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
if page.next_page?
|
62
|
+
new_page = page.next_page
|
63
|
+
puts(new_page.data[0].product_id)
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
### Handling errors
|
69
68
|
|
70
69
|
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Lithic::Errors::APIError` will be thrown:
|
71
70
|
|
72
71
|
```ruby
|
73
72
|
begin
|
74
73
|
card = lithic.cards.create(type: "MERCHANT_LOCKED")
|
75
|
-
rescue Lithic::Errors::
|
76
|
-
puts(
|
74
|
+
rescue Lithic::Errors::APIConnectionError => e
|
75
|
+
puts("The server could not be reached")
|
76
|
+
puts(e.cause) # an underlying Exception, likely raised within `net/http`
|
77
|
+
rescue Lithic::Errors::RateLimitError => e
|
78
|
+
puts("A 429 status code was received; we should back off a bit.")
|
79
|
+
rescue Lithic::Errors::APIStatusError => e
|
80
|
+
puts("Another non-200-range status code was received")
|
81
|
+
puts(e.status)
|
77
82
|
end
|
78
83
|
```
|
79
84
|
|
@@ -113,11 +118,7 @@ lithic.cards.list(page_size: 10, request_options: {max_retries: 5})
|
|
113
118
|
|
114
119
|
### Timeouts
|
115
120
|
|
116
|
-
By default, requests will time out after 60 seconds.
|
117
|
-
|
118
|
-
Timeouts are applied separately to the initial connection and the overall request time, so in some cases a request could wait 2\*timeout seconds before it fails.
|
119
|
-
|
120
|
-
You can use the `timeout` option to configure or disable this:
|
121
|
+
By default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:
|
121
122
|
|
122
123
|
```ruby
|
123
124
|
# Configure the default for all requests:
|
@@ -129,39 +130,53 @@ lithic = Lithic::Client.new(
|
|
129
130
|
lithic.cards.list(page_size: 10, request_options: {timeout: 5})
|
130
131
|
```
|
131
132
|
|
132
|
-
|
133
|
+
On timeout, `Lithic::Errors::APITimeoutError` is raised.
|
133
134
|
|
134
|
-
|
135
|
+
Note that requests that time out are retried by default.
|
135
136
|
|
136
|
-
|
137
|
+
## Advanced concepts
|
137
138
|
|
138
|
-
|
139
|
+
### BaseModel
|
139
140
|
|
140
|
-
|
141
|
-
# This has tooling readability, for auto-completion, static analysis, and goto definition with supported language services
|
142
|
-
params = Lithic::Models::CardCreateParams.new(type: "SINGLE_USE")
|
141
|
+
All parameter and response objects inherit from `Lithic::Internal::Type::BaseModel`, which provides several conveniences, including:
|
143
142
|
|
144
|
-
|
145
|
-
params = {
|
146
|
-
type: "SINGLE_USE"
|
147
|
-
}
|
148
|
-
```
|
143
|
+
1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.
|
149
144
|
|
150
|
-
|
145
|
+
2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.
|
151
146
|
|
152
|
-
|
147
|
+
3. Both instances and the classes themselves can be pretty-printed.
|
153
148
|
|
154
|
-
|
149
|
+
4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.
|
150
|
+
|
151
|
+
### Making custom or undocumented requests
|
152
|
+
|
153
|
+
#### Undocumented properties
|
154
|
+
|
155
|
+
You can send undocumented parameters to any endpoint, and read undocumented response properties, like so:
|
155
156
|
|
156
|
-
|
157
|
+
Note: the `extra_` parameters of the same name overrides the documented parameters.
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
page =
|
161
|
+
lithic.cards.list(
|
162
|
+
page_size: 10,
|
163
|
+
request_options: {
|
164
|
+
extra_query: {my_query_parameter: value},
|
165
|
+
extra_body: {my_body_parameter: value},
|
166
|
+
extra_headers: {"my-header": value}
|
167
|
+
}
|
168
|
+
)
|
169
|
+
|
170
|
+
puts(page[:my_undocumented_property])
|
171
|
+
```
|
157
172
|
|
158
173
|
#### Undocumented request params
|
159
174
|
|
160
|
-
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a
|
175
|
+
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request as seen in examples above.
|
161
176
|
|
162
177
|
#### Undocumented endpoints
|
163
178
|
|
164
|
-
To make requests to undocumented endpoints, you can make requests using `client.request
|
179
|
+
To make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:
|
165
180
|
|
166
181
|
```ruby
|
167
182
|
response = client.request(
|
@@ -169,42 +184,67 @@ response = client.request(
|
|
169
184
|
path: '/undocumented/endpoint',
|
170
185
|
query: {"dog": "woof"},
|
171
186
|
headers: {"useful-header": "interesting-value"},
|
172
|
-
body: {"
|
187
|
+
body: {"hello": "world"}
|
173
188
|
)
|
174
189
|
```
|
175
190
|
|
176
191
|
### Concurrency & connection pooling
|
177
192
|
|
178
|
-
The `Lithic::Client` instances are
|
193
|
+
The `Lithic::Client` instances are threadsafe, but only are fork-safe when there are no in-flight HTTP requests.
|
179
194
|
|
180
|
-
|
195
|
+
Each instance of `Lithic::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.
|
196
|
+
|
197
|
+
When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.
|
181
198
|
|
182
199
|
Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.
|
183
200
|
|
184
|
-
|
201
|
+
## Sorbet
|
185
202
|
|
186
|
-
|
203
|
+
This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.
|
187
204
|
|
188
|
-
|
205
|
+
You can provide typesafe request parameters like so:
|
189
206
|
|
190
|
-
|
207
|
+
```ruby
|
208
|
+
lithic.cards.create(type: "SINGLE_USE")
|
209
|
+
```
|
191
210
|
|
192
|
-
|
211
|
+
Or, equivalently:
|
193
212
|
|
194
213
|
```ruby
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
214
|
+
# Hashes work, but are not typesafe:
|
215
|
+
lithic.cards.create(type: "SINGLE_USE")
|
216
|
+
|
217
|
+
# You can also splat a full Params class:
|
218
|
+
params = Lithic::CardCreateParams.new(type: "SINGLE_USE")
|
219
|
+
lithic.cards.create(**params)
|
199
220
|
```
|
200
221
|
|
201
|
-
|
222
|
+
### Enums
|
202
223
|
|
203
|
-
|
224
|
+
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:
|
204
225
|
|
205
226
|
```ruby
|
206
|
-
|
207
|
-
|
227
|
+
# :ACTIVE
|
228
|
+
puts(Lithic::AccountUpdateParams::State::ACTIVE)
|
229
|
+
|
230
|
+
# Revealed type: `T.all(Lithic::AccountUpdateParams::State, Symbol)`
|
231
|
+
T.reveal_type(Lithic::AccountUpdateParams::State::ACTIVE)
|
232
|
+
```
|
233
|
+
|
234
|
+
Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:
|
235
|
+
|
236
|
+
```ruby
|
237
|
+
# Using the enum constants preserves the tagged type information:
|
238
|
+
lithic.accounts.update(
|
239
|
+
state: Lithic::AccountUpdateParams::State::ACTIVE,
|
240
|
+
# …
|
241
|
+
)
|
242
|
+
|
243
|
+
# Literal values is also permissible:
|
244
|
+
lithic.accounts.update(
|
245
|
+
state: :ACTIVE,
|
246
|
+
# …
|
247
|
+
)
|
208
248
|
```
|
209
249
|
|
210
250
|
## Versioning
|
@@ -12,6 +12,7 @@ module Lithic
|
|
12
12
|
# Array of items of a given type.
|
13
13
|
class ArrayOf
|
14
14
|
include Lithic::Internal::Type::Converter
|
15
|
+
include Lithic::Internal::Util::SorbetRuntimeSupport
|
15
16
|
|
16
17
|
private_class_method :new
|
17
18
|
|
@@ -110,6 +111,13 @@ module Lithic
|
|
110
111
|
end
|
111
112
|
end
|
112
113
|
|
114
|
+
# @api private
|
115
|
+
#
|
116
|
+
# @return [Object]
|
117
|
+
def to_sorbet_type
|
118
|
+
T::Array[Lithic::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(item_type)]
|
119
|
+
end
|
120
|
+
|
113
121
|
# @api private
|
114
122
|
#
|
115
123
|
# @return [generic<Elem>]
|
@@ -304,6 +304,13 @@ module Lithic
|
|
304
304
|
|
305
305
|
acc
|
306
306
|
end
|
307
|
+
|
308
|
+
# @api private
|
309
|
+
#
|
310
|
+
# @return [Object]
|
311
|
+
def to_sorbet_type
|
312
|
+
self
|
313
|
+
end
|
307
314
|
end
|
308
315
|
|
309
316
|
class << self
|
@@ -386,6 +393,14 @@ module Lithic
|
|
386
393
|
# @param keys [Array<Symbol>, nil]
|
387
394
|
#
|
388
395
|
# @return [Hash{Symbol=>Object}]
|
396
|
+
#
|
397
|
+
# @example
|
398
|
+
# # `address` is a `Lithic::Address`
|
399
|
+
# address => {
|
400
|
+
# address1: address1,
|
401
|
+
# city: city,
|
402
|
+
# country: country
|
403
|
+
# }
|
389
404
|
def deconstruct_keys(keys)
|
390
405
|
(keys || self.class.known_fields.keys)
|
391
406
|
.filter_map do |k|
|
@@ -10,6 +10,7 @@ module Lithic
|
|
10
10
|
# Ruby has no Boolean class; this is something for models to refer to.
|
11
11
|
class Boolean
|
12
12
|
extend Lithic::Internal::Type::Converter
|
13
|
+
extend Lithic::Internal::Util::SorbetRuntimeSupport
|
13
14
|
|
14
15
|
private_class_method :new
|
15
16
|
|
@@ -56,6 +57,13 @@ module Lithic
|
|
56
57
|
# @option state [Boolean] :can_retry
|
57
58
|
#
|
58
59
|
# @return [Boolean, Object]
|
60
|
+
|
61
|
+
# @api private
|
62
|
+
#
|
63
|
+
# @return [Object]
|
64
|
+
def to_sorbet_type
|
65
|
+
T::Boolean
|
66
|
+
end
|
59
67
|
end
|
60
68
|
end
|
61
69
|
end
|
@@ -108,6 +108,18 @@ module Lithic
|
|
108
108
|
#
|
109
109
|
# @return [Symbol, Object]
|
110
110
|
|
111
|
+
# @api private
|
112
|
+
#
|
113
|
+
# @return [Object]
|
114
|
+
def to_sorbet_type
|
115
|
+
case values
|
116
|
+
in []
|
117
|
+
T.noreturn
|
118
|
+
in [value, *_]
|
119
|
+
T.all(Lithic::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(value), self)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
111
123
|
# @api private
|
112
124
|
#
|
113
125
|
# @param depth [Integer]
|
@@ -12,6 +12,7 @@ module Lithic
|
|
12
12
|
# Hash of items of a given type.
|
13
13
|
class HashOf
|
14
14
|
include Lithic::Internal::Type::Converter
|
15
|
+
include Lithic::Internal::Util::SorbetRuntimeSupport
|
15
16
|
|
16
17
|
private_class_method :new
|
17
18
|
|
@@ -130,6 +131,13 @@ module Lithic
|
|
130
131
|
end
|
131
132
|
end
|
132
133
|
|
134
|
+
# @api private
|
135
|
+
#
|
136
|
+
# @return [Object]
|
137
|
+
def to_sorbet_type
|
138
|
+
T::Hash[Lithic::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(item_type)]
|
139
|
+
end
|
140
|
+
|
133
141
|
# @api private
|
134
142
|
#
|
135
143
|
# @return [generic<Elem>]
|
@@ -202,6 +202,18 @@ module Lithic
|
|
202
202
|
super
|
203
203
|
end
|
204
204
|
|
205
|
+
# @api private
|
206
|
+
#
|
207
|
+
# @return [Object]
|
208
|
+
def to_sorbet_type
|
209
|
+
case (v = variants)
|
210
|
+
in []
|
211
|
+
T.noreturn
|
212
|
+
else
|
213
|
+
T.any(*v.map { Lithic::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) })
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
205
217
|
# rubocop:enable Style/CaseEquality
|
206
218
|
# rubocop:enable Style/HashEachMethods
|
207
219
|
|
@@ -10,6 +10,7 @@ module Lithic
|
|
10
10
|
# When we don't know what to expect for the value.
|
11
11
|
class Unknown
|
12
12
|
extend Lithic::Internal::Type::Converter
|
13
|
+
extend Lithic::Internal::Util::SorbetRuntimeSupport
|
13
14
|
|
14
15
|
# rubocop:disable Lint/UnusedMethodArgument
|
15
16
|
|
@@ -58,6 +59,13 @@ module Lithic
|
|
58
59
|
# @option state [Boolean] :can_retry
|
59
60
|
#
|
60
61
|
# @return [Object]
|
62
|
+
|
63
|
+
# @api private
|
64
|
+
#
|
65
|
+
# @return [Object]
|
66
|
+
def to_sorbet_type
|
67
|
+
T.anything
|
68
|
+
end
|
61
69
|
end
|
62
70
|
|
63
71
|
# rubocop:enable Lint/UnusedMethodArgument
|
data/lib/lithic/internal/util.rb
CHANGED
@@ -9,6 +9,23 @@ module Lithic
|
|
9
9
|
# @return [Float]
|
10
10
|
def self.monotonic_secs = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
11
11
|
|
12
|
+
# @api private
|
13
|
+
#
|
14
|
+
# @param ns [Module, Class]
|
15
|
+
#
|
16
|
+
# @return [Enumerable<Module, Class>]
|
17
|
+
def self.walk_namespaces(ns)
|
18
|
+
ns.constants(false).lazy.flat_map do
|
19
|
+
case (c = ns.const_get(_1, false))
|
20
|
+
in Module | Class
|
21
|
+
walk_namespaces(c)
|
22
|
+
else
|
23
|
+
[]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
.chain([ns])
|
27
|
+
end
|
28
|
+
|
12
29
|
class << self
|
13
30
|
# @api private
|
14
31
|
#
|
@@ -826,11 +843,39 @@ module Lithic
|
|
826
843
|
sorbet_runtime_constants.fetch(name).call
|
827
844
|
end
|
828
845
|
|
846
|
+
# @api private
|
847
|
+
#
|
848
|
+
# @param name [Symbol]
|
849
|
+
#
|
850
|
+
# @return [Boolean]
|
851
|
+
def sorbet_constant_defined?(name) = sorbet_runtime_constants.key?(name)
|
852
|
+
|
829
853
|
# @api private
|
830
854
|
#
|
831
855
|
# @param name [Symbol]
|
832
856
|
# @param blk [Proc]
|
833
857
|
def define_sorbet_constant!(name, &blk) = sorbet_runtime_constants.store(name, blk)
|
858
|
+
|
859
|
+
# @api private
|
860
|
+
#
|
861
|
+
# @return [Object]
|
862
|
+
def to_sorbet_type = raise NotImplementedError
|
863
|
+
|
864
|
+
class << self
|
865
|
+
# @api private
|
866
|
+
#
|
867
|
+
# @param type [Lithic::Internal::Util::SorbetRuntimeSupport, Object]
|
868
|
+
#
|
869
|
+
# @return [Object]
|
870
|
+
def to_sorbet_type(type)
|
871
|
+
case type
|
872
|
+
in Lithic::Internal::Util::SorbetRuntimeSupport
|
873
|
+
type.to_sorbet_type
|
874
|
+
else
|
875
|
+
type
|
876
|
+
end
|
877
|
+
end
|
878
|
+
end
|
834
879
|
end
|
835
880
|
|
836
881
|
extend Lithic::Internal::Util::SorbetRuntimeSupport
|
data/lib/lithic/internal.rb
CHANGED
@@ -921,15 +921,6 @@ module Lithic
|
|
921
921
|
|
922
922
|
# @!method self.variants
|
923
923
|
# @return [Array(Lithic::Models::AccountHolderUpdateResponse::KYBKYCPatchResponse, Lithic::Models::AccountHolderUpdateResponse::PatchResponse)]
|
924
|
-
|
925
|
-
define_sorbet_constant!(:Variants) do
|
926
|
-
T.type_alias do
|
927
|
-
T.any(
|
928
|
-
Lithic::Models::AccountHolderUpdateResponse::KYBKYCPatchResponse,
|
929
|
-
Lithic::Models::AccountHolderUpdateResponse::PatchResponse
|
930
|
-
)
|
931
|
-
end
|
932
|
-
end
|
933
924
|
end
|
934
925
|
end
|
935
926
|
end
|
@@ -113,10 +113,6 @@ module Lithic
|
|
113
113
|
# @!method self.variants
|
114
114
|
# @return [Array(String, Integer, Array<String>)]
|
115
115
|
|
116
|
-
define_sorbet_constant!(:Variants) do
|
117
|
-
T.type_alias { T.any(String, Integer, T::Array[String]) }
|
118
|
-
end
|
119
|
-
|
120
116
|
# @type [Lithic::Internal::Type::Converter]
|
121
117
|
StringArray = Lithic::Internal::Type::ArrayOf[String]
|
122
118
|
end
|
@@ -180,16 +180,6 @@ module Lithic
|
|
180
180
|
|
181
181
|
# @!method self.variants
|
182
182
|
# @return [Array(Lithic::AuthRules::ConditionalBlockParameters, Lithic::AuthRules::VelocityLimitParams, Lithic::Models::AuthRules::V2ApplyResponse::CurrentVersion::Parameters::MerchantLockParameters)]
|
183
|
-
|
184
|
-
define_sorbet_constant!(:Variants) do
|
185
|
-
T.type_alias do
|
186
|
-
T.any(
|
187
|
-
Lithic::AuthRules::ConditionalBlockParameters,
|
188
|
-
Lithic::AuthRules::VelocityLimitParams,
|
189
|
-
Lithic::Models::AuthRules::V2ApplyResponse::CurrentVersion::Parameters::MerchantLockParameters
|
190
|
-
)
|
191
|
-
end
|
192
|
-
end
|
193
183
|
end
|
194
184
|
end
|
195
185
|
|
@@ -289,16 +279,6 @@ module Lithic
|
|
289
279
|
|
290
280
|
# @!method self.variants
|
291
281
|
# @return [Array(Lithic::AuthRules::ConditionalBlockParameters, Lithic::AuthRules::VelocityLimitParams, Lithic::Models::AuthRules::V2ApplyResponse::DraftVersion::Parameters::MerchantLockParameters)]
|
292
|
-
|
293
|
-
define_sorbet_constant!(:Variants) do
|
294
|
-
T.type_alias do
|
295
|
-
T.any(
|
296
|
-
Lithic::AuthRules::ConditionalBlockParameters,
|
297
|
-
Lithic::AuthRules::VelocityLimitParams,
|
298
|
-
Lithic::Models::AuthRules::V2ApplyResponse::DraftVersion::Parameters::MerchantLockParameters
|
299
|
-
)
|
300
|
-
end
|
301
|
-
end
|
302
282
|
end
|
303
283
|
end
|
304
284
|
|
@@ -138,16 +138,6 @@ module Lithic
|
|
138
138
|
|
139
139
|
# @!method self.variants
|
140
140
|
# @return [Array(Lithic::AuthRules::ConditionalBlockParameters, Lithic::AuthRules::VelocityLimitParams, Lithic::AuthRules::V2CreateParams::Parameters::MerchantLockParameters)]
|
141
|
-
|
142
|
-
define_sorbet_constant!(:Variants) do
|
143
|
-
T.type_alias do
|
144
|
-
T.any(
|
145
|
-
Lithic::AuthRules::ConditionalBlockParameters,
|
146
|
-
Lithic::AuthRules::VelocityLimitParams,
|
147
|
-
Lithic::AuthRules::V2CreateParams::Parameters::MerchantLockParameters
|
148
|
-
)
|
149
|
-
end
|
150
|
-
end
|
151
141
|
end
|
152
142
|
|
153
143
|
# The type of Auth Rule
|
@@ -181,16 +181,6 @@ module Lithic
|
|
181
181
|
|
182
182
|
# @!method self.variants
|
183
183
|
# @return [Array(Lithic::AuthRules::ConditionalBlockParameters, Lithic::AuthRules::VelocityLimitParams, Lithic::Models::AuthRules::V2CreateResponse::CurrentVersion::Parameters::MerchantLockParameters)]
|
184
|
-
|
185
|
-
define_sorbet_constant!(:Variants) do
|
186
|
-
T.type_alias do
|
187
|
-
T.any(
|
188
|
-
Lithic::AuthRules::ConditionalBlockParameters,
|
189
|
-
Lithic::AuthRules::VelocityLimitParams,
|
190
|
-
Lithic::Models::AuthRules::V2CreateResponse::CurrentVersion::Parameters::MerchantLockParameters
|
191
|
-
)
|
192
|
-
end
|
193
|
-
end
|
194
184
|
end
|
195
185
|
end
|
196
186
|
|
@@ -290,16 +280,6 @@ module Lithic
|
|
290
280
|
|
291
281
|
# @!method self.variants
|
292
282
|
# @return [Array(Lithic::AuthRules::ConditionalBlockParameters, Lithic::AuthRules::VelocityLimitParams, Lithic::Models::AuthRules::V2CreateResponse::DraftVersion::Parameters::MerchantLockParameters)]
|
293
|
-
|
294
|
-
define_sorbet_constant!(:Variants) do
|
295
|
-
T.type_alias do
|
296
|
-
T.any(
|
297
|
-
Lithic::AuthRules::ConditionalBlockParameters,
|
298
|
-
Lithic::AuthRules::VelocityLimitParams,
|
299
|
-
Lithic::Models::AuthRules::V2CreateResponse::DraftVersion::Parameters::MerchantLockParameters
|
300
|
-
)
|
301
|
-
end
|
302
|
-
end
|
303
283
|
end
|
304
284
|
end
|
305
285
|
|
@@ -90,16 +90,6 @@ module Lithic
|
|
90
90
|
|
91
91
|
# @!method self.variants
|
92
92
|
# @return [Array(Lithic::AuthRules::ConditionalBlockParameters, Lithic::AuthRules::VelocityLimitParams, Lithic::AuthRules::V2DraftParams::Parameters::MerchantLockParameters)]
|
93
|
-
|
94
|
-
define_sorbet_constant!(:Variants) do
|
95
|
-
T.type_alias do
|
96
|
-
T.any(
|
97
|
-
Lithic::AuthRules::ConditionalBlockParameters,
|
98
|
-
Lithic::AuthRules::VelocityLimitParams,
|
99
|
-
Lithic::AuthRules::V2DraftParams::Parameters::MerchantLockParameters
|
100
|
-
)
|
101
|
-
end
|
102
|
-
end
|
103
93
|
end
|
104
94
|
end
|
105
95
|
end
|