lithic 0.1.0.pre.alpha.25 → 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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/README.md +94 -54
  4. data/lib/lithic/client.rb +8 -4
  5. data/lib/lithic/internal/transport/pooled_net_requester.rb +3 -1
  6. data/lib/lithic/internal/type/array_of.rb +8 -0
  7. data/lib/lithic/internal/type/base_model.rb +15 -0
  8. data/lib/lithic/internal/type/boolean.rb +8 -0
  9. data/lib/lithic/internal/type/enum.rb +12 -0
  10. data/lib/lithic/internal/type/file_input.rb +7 -0
  11. data/lib/lithic/internal/type/hash_of.rb +8 -0
  12. data/lib/lithic/internal/type/union.rb +12 -0
  13. data/lib/lithic/internal/type/unknown.rb +8 -0
  14. data/lib/lithic/internal/util.rb +45 -0
  15. data/lib/lithic/internal.rb +3 -0
  16. data/lib/lithic/models/account_holder_update_response.rb +0 -9
  17. data/lib/lithic/models/auth_rules/auth_rule_condition.rb +0 -4
  18. data/lib/lithic/models/auth_rules/v2_apply_response.rb +0 -20
  19. data/lib/lithic/models/auth_rules/v2_create_params.rb +0 -10
  20. data/lib/lithic/models/auth_rules/v2_create_response.rb +0 -20
  21. data/lib/lithic/models/auth_rules/v2_draft_params.rb +0 -10
  22. data/lib/lithic/models/auth_rules/v2_draft_response.rb +0 -20
  23. data/lib/lithic/models/auth_rules/v2_list_response.rb +0 -20
  24. data/lib/lithic/models/auth_rules/v2_promote_response.rb +0 -20
  25. data/lib/lithic/models/auth_rules/v2_retrieve_response.rb +0 -20
  26. data/lib/lithic/models/auth_rules/v2_update_response.rb +0 -20
  27. data/lib/lithic/models/auth_rules/velocity_limit_params.rb +0 -4
  28. data/lib/lithic/models/card_web_provision_params.rb +32 -0
  29. data/lib/lithic/models/card_web_provision_response.rb +83 -0
  30. data/lib/lithic/models/funding_event_list_params.rb +43 -0
  31. data/lib/lithic/models/funding_event_list_response.rb +104 -0
  32. data/lib/lithic/models/funding_event_retrieve_details_params.rb +14 -0
  33. data/lib/lithic/models/funding_event_retrieve_details_response.rb +33 -0
  34. data/lib/lithic/models/funding_event_retrieve_params.rb +14 -0
  35. data/lib/lithic/models/funding_event_retrieve_response.rb +104 -0
  36. data/lib/lithic/models.rb +38 -19
  37. data/lib/lithic/resources/cards.rb +29 -0
  38. data/lib/lithic/resources/funding_events.rb +84 -0
  39. data/lib/lithic/version.rb +1 -1
  40. data/lib/lithic.rb +9 -0
  41. data/rbi/lithic/client.rbi +3 -0
  42. data/rbi/lithic/internal/transport/pooled_net_requester.rbi +5 -1
  43. data/rbi/lithic/internal/type/array_of.rbi +6 -0
  44. data/rbi/lithic/internal/type/base_model.rbi +5 -0
  45. data/rbi/lithic/internal/type/boolean.rbi +6 -0
  46. data/rbi/lithic/internal/type/enum.rbi +5 -0
  47. data/rbi/lithic/internal/type/file_input.rbi +5 -0
  48. data/rbi/lithic/internal/type/hash_of.rbi +6 -0
  49. data/rbi/lithic/internal/type/union.rbi +5 -0
  50. data/rbi/lithic/internal/type/unknown.rbi +6 -0
  51. data/rbi/lithic/internal/util.rbi +31 -0
  52. data/rbi/lithic/internal.rbi +3 -0
  53. data/rbi/lithic/models/auth_rules/auth_rule_condition.rbi +12 -4
  54. data/rbi/lithic/models/auth_rules/v2_apply_response.rbi +4 -20
  55. data/rbi/lithic/models/auth_rules/v2_create_response.rbi +4 -20
  56. data/rbi/lithic/models/auth_rules/v2_draft_response.rbi +4 -20
  57. data/rbi/lithic/models/auth_rules/v2_list_response.rbi +4 -20
  58. data/rbi/lithic/models/auth_rules/v2_promote_response.rbi +4 -20
  59. data/rbi/lithic/models/auth_rules/v2_retrieve_response.rbi +4 -20
  60. data/rbi/lithic/models/auth_rules/v2_update_response.rbi +4 -20
  61. data/rbi/lithic/models/card_web_provision_params.rbi +84 -0
  62. data/rbi/lithic/models/card_web_provision_response.rbi +169 -0
  63. data/rbi/lithic/models/funding_event_list_params.rbi +72 -0
  64. data/rbi/lithic/models/funding_event_list_response.rbi +177 -0
  65. data/rbi/lithic/models/funding_event_retrieve_details_params.rbi +30 -0
  66. data/rbi/lithic/models/funding_event_retrieve_details_response.rbi +56 -0
  67. data/rbi/lithic/models/funding_event_retrieve_params.rbi +27 -0
  68. data/rbi/lithic/models/funding_event_retrieve_response.rbi +177 -0
  69. data/rbi/lithic/models.rbi +9 -0
  70. data/rbi/lithic/resources/account_holders.rbi +1 -6
  71. data/rbi/lithic/resources/cards.rbi +23 -0
  72. data/rbi/lithic/resources/funding_events.rbi +64 -0
  73. data/sig/lithic/client.rbs +2 -0
  74. data/sig/lithic/internal/transport/pooled_net_requester.rbs +2 -0
  75. data/sig/lithic/internal/type/array_of.rbs +3 -0
  76. data/sig/lithic/internal/type/base_model.rbs +2 -0
  77. data/sig/lithic/internal/type/boolean.rbs +3 -0
  78. data/sig/lithic/internal/type/enum.rbs +2 -0
  79. data/sig/lithic/internal/type/file_input.rbs +2 -0
  80. data/sig/lithic/internal/type/hash_of.rbs +3 -0
  81. data/sig/lithic/internal/type/union.rbs +2 -0
  82. data/sig/lithic/internal/type/unknown.rbs +3 -0
  83. data/sig/lithic/internal/util.rbs +12 -0
  84. data/sig/lithic/internal.rbs +2 -0
  85. data/sig/lithic/models/card_web_provision_params.rbs +33 -0
  86. data/sig/lithic/models/card_web_provision_response.rbs +68 -0
  87. data/sig/lithic/models/funding_event_list_params.rbs +31 -0
  88. data/sig/lithic/models/funding_event_list_response.rbs +65 -0
  89. data/sig/lithic/models/funding_event_retrieve_details_params.rbs +13 -0
  90. data/sig/lithic/models/funding_event_retrieve_details_response.rbs +24 -0
  91. data/sig/lithic/models/funding_event_retrieve_params.rbs +13 -0
  92. data/sig/lithic/models/funding_event_retrieve_response.rbs +65 -0
  93. data/sig/lithic/models.rbs +8 -0
  94. data/sig/lithic/resources/cards.rbs +6 -0
  95. data/sig/lithic/resources/funding_events.rbs +24 -0
  96. metadata +29 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4952d1eb7724a1f03de60971b8dbeca3f37fd7301ef2aa80b60b2aa40f585647
4
- data.tar.gz: 07ea8c2c65f441a4483af2a8017bd67b060959148ab14406b90c6b58d9195f13
3
+ metadata.gz: a598431f4650ca3d4dbe388399817b2ba7b07f77410c54bae03131474b46e553
4
+ data.tar.gz: 5f57edc9f9e7da78d4ae6b62e954ad0a23ad0f2169e4171d2e874fa9c719b96d
5
5
  SHA512:
6
- metadata.gz: 80ddde2e8b297e85b9629c40d8ef3e98c9a13a4040d32af9f079674ac4e4475c56365df21d0c3859c0e12c280c82001d7f7c836f0c8dc53d635dd3f4ca0dff2a
7
- data.tar.gz: 5ce4b9c50c79addce32d0f78a3057b22a66ef6671025c0b32a4307fe5635c0a48c2f72619d2bc3d7919742603a7f50673388f25bd9db694be903662fee05ec55
6
+ metadata.gz: de7b42dcf1fc47a0c8b1fa4c0c684d6580615451c040739ce687903d66b670c6dea14108660e5b3034b34e869c90937a43e5cbfcddbb3ff2d9b175dbd7125ee7
7
+ data.tar.gz: 2fa17bc922b1004a138a95d906da737bfe16d909237d666ab8063dd0a4bdf09b1b7c8411b792f69730817e3a26774cfe14d03bc4a4f510eff8a94013c2d70c99
data/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
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
+
23
+ ## 0.1.0-alpha.26 (2025-05-14)
24
+
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)
26
+
27
+ ### Features
28
+
29
+ * **api:** new Funding Events and Card Web Provision API's ([1e3868e](https://github.com/lithic-com/lithic-ruby/commit/1e3868e233fb636a3b783160777b77715465ac13))
30
+ * bump default connection pool size limit to minimum of 99 ([07ebbb8](https://github.com/lithic-com/lithic-ruby/commit/07ebbb88612e4156407a0b0b6828f53c82adfe31))
31
+
3
32
  ## 0.1.0-alpha.25 (2025-05-13)
4
33
 
5
34
  Full Changelog: [v0.1.0-alpha.24...v0.1.0-alpha.25](https://github.com/lithic-com/lithic-ruby/compare/v0.1.0-alpha.24...v0.1.0-alpha.25)
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.25"
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
- ### Errors
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::APIError => e
76
- puts(e.status) # 400
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
- ## Model DSL
133
+ On timeout, `Lithic::Errors::APITimeoutError` is raised.
133
134
 
134
- This library uses a simple DSL to represent request parameters and response shapes in `lib/lithic/models`.
135
+ Note that requests that time out are retried by default.
135
136
 
136
- With the right [editor plugins](https://shopify.github.io/ruby-lsp), you can ctrl-click on elements of the DSL to navigate around and explore the library.
137
+ ## Advanced concepts
137
138
 
138
- In all places where a `BaseModel` type is specified, vanilla Ruby `Hash` can also be used. For example, the following are interchangeable as arguments:
139
+ ### BaseModel
139
140
 
140
- ```ruby
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
- # This also works
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
- ## Editor support
145
+ 2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.
151
146
 
152
- A combination of [Shopify LSP](https://shopify.github.io/ruby-lsp) and [Solargraph](https://solargraph.org/) is recommended for non-[Sorbet](https://sorbet.org) users. The former is especially good at go to definition, while the latter has much better auto-completion support.
147
+ 3. Both instances and the classes themselves can be pretty-printed.
153
148
 
154
- ## Advanced concepts
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
- ### Making custom/undocumented requests
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 requests as seen in examples above.
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`. Options on the client will be respected (such as retries) when making this 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: {"he": "llo"},
187
+ body: {"hello": "world"}
173
188
  )
174
189
  ```
175
190
 
176
191
  ### Concurrency & connection pooling
177
192
 
178
- The `Lithic::Client` instances are thread-safe, and should be re-used across multiple threads. By default, each `Client` have their own HTTP connection pool, with a maximum number of connections equal to thread count.
193
+ The `Lithic::Client` instances are threadsafe, but only are fork-safe when there are no in-flight HTTP requests.
179
194
 
180
- When the maximum number of connections has been checked out from the connection pool, the `Client` will wait for an in use connection to become available. The queue time for this mechanism is accounted for by the per-request timeout.
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
- Currently, `Lithic::Client` instances are only fork-safe if there are no in-flight HTTP requests.
201
+ ## Sorbet
185
202
 
186
- ### Sorbet
203
+ This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.
187
204
 
188
- #### Enums
205
+ You can provide typesafe request parameters like so:
189
206
 
190
- Sorbet's typed enums require sub-classing of the [`T::Enum` class](https://sorbet.org/docs/tenum) from the `sorbet-runtime` gem.
207
+ ```ruby
208
+ lithic.cards.create(type: "SINGLE_USE")
209
+ ```
191
210
 
192
- Since this library does not depend on `sorbet-runtime`, it uses a [`T.all` intersection type](https://sorbet.org/docs/intersection-types) with a ruby primitive type to construct a "tagged alias" instead.
211
+ Or, equivalently:
193
212
 
194
213
  ```ruby
195
- module Lithic::AccountFinancialAccountType
196
- # This alias aids language service driven navigation.
197
- TaggedSymbol = T.type_alias { T.all(Symbol, Lithic::AccountFinancialAccountType) }
198
- end
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
- #### Argument passing trick
222
+ ### Enums
202
223
 
203
- It is possible to pass a compatible model / parameter class to a method that expects keyword arguments by using the `**` splat operator.
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
- params = Lithic::Models::CardCreateParams.new(type: "SINGLE_USE")
207
- lithic.cards.create(**params)
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
data/lib/lithic/client.rb CHANGED
@@ -98,6 +98,9 @@ module Lithic
98
98
  # @return [Lithic::Resources::ManagementOperations]
99
99
  attr_reader :management_operations
100
100
 
101
+ # @return [Lithic::Resources::FundingEvents]
102
+ attr_reader :funding_events
103
+
101
104
  # Status of api
102
105
  #
103
106
  # @overload api_status(request_options: {})
@@ -143,10 +146,10 @@ module Lithic
143
146
  api_key: ENV["LITHIC_API_KEY"],
144
147
  environment: nil,
145
148
  base_url: ENV["LITHIC_BASE_URL"],
146
- max_retries: Lithic::Client::DEFAULT_MAX_RETRIES,
147
- timeout: Lithic::Client::DEFAULT_TIMEOUT_IN_SECONDS,
148
- initial_retry_delay: Lithic::Client::DEFAULT_INITIAL_RETRY_DELAY,
149
- max_retry_delay: Lithic::Client::DEFAULT_MAX_RETRY_DELAY
149
+ max_retries: self.class::DEFAULT_MAX_RETRIES,
150
+ timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
151
+ initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
152
+ max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
150
153
  )
151
154
  base_url ||= Lithic::Client::ENVIRONMENTS.fetch(environment&.to_sym || :production) do
152
155
  message = "environment must be one of #{Lithic::Client::ENVIRONMENTS.keys}, got #{environment}"
@@ -197,6 +200,7 @@ module Lithic
197
200
  @credit_products = Lithic::Resources::CreditProducts.new(client: self)
198
201
  @external_payments = Lithic::Resources::ExternalPayments.new(client: self)
199
202
  @management_operations = Lithic::Resources::ManagementOperations.new(client: self)
203
+ @funding_events = Lithic::Resources::FundingEvents.new(client: self)
200
204
  end
201
205
  end
202
206
  end
@@ -11,6 +11,8 @@ module Lithic
11
11
  # https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49
12
12
  KEEP_ALIVE_TIMEOUT = 30
13
13
 
14
+ DEFAULT_MAX_CONNECTIONS = [Etc.nprocessors, 99].max
15
+
14
16
  class << self
15
17
  # @api private
16
18
  #
@@ -184,7 +186,7 @@ module Lithic
184
186
  # @api private
185
187
  #
186
188
  # @param size [Integer]
187
- def initialize(size: Etc.nprocessors)
189
+ def initialize(size: self.class::DEFAULT_MAX_CONNECTIONS)
188
190
  @mutex = Mutex.new
189
191
  @size = size
190
192
  @pools = {}
@@ -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]
@@ -89,6 +89,13 @@ module Lithic
89
89
 
90
90
  value
91
91
  end
92
+
93
+ # @api private
94
+ #
95
+ # @return [Object]
96
+ def to_sorbet_type
97
+ T.any(Pathname, StringIO, IO, String, Lithic::FilePart)
98
+ end
92
99
  end
93
100
  end
94
101
  end
@@ -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
@@ -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
@@ -13,5 +13,8 @@ module Lithic
13
13
  define_sorbet_constant!(:AnyHash) do
14
14
  T.type_alias { T::Hash[Symbol, T.anything] }
15
15
  end
16
+ define_sorbet_constant!(:FileInput) do
17
+ T.type_alias { T.any(Pathname, StringIO, IO, String, Lithic::FilePart) }
18
+ end
16
19
  end
17
20
  end
@@ -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