lithic 0.1.0.pre.alpha.5 → 0.1.0.pre.alpha.6

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 (116) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -5
  3. data/lib/lithic/internal/cursor_page.rb +5 -1
  4. data/lib/lithic/internal/single_page.rb +5 -1
  5. data/lib/lithic/internal/transport/base_client.rb +2 -2
  6. data/lib/lithic/internal/transport/pooled_net_requester.rb +1 -1
  7. data/lib/lithic/internal/type/array_of.rb +5 -3
  8. data/lib/lithic/internal/type/base_model.rb +12 -6
  9. data/lib/lithic/internal/type/base_page.rb +4 -1
  10. data/lib/lithic/internal/type/{boolean_model.rb → boolean.rb} +2 -2
  11. data/lib/lithic/internal/type/converter.rb +6 -1
  12. data/lib/lithic/internal/type/enum.rb +2 -0
  13. data/lib/lithic/internal/type/hash_of.rb +3 -1
  14. data/lib/lithic/internal/util.rb +28 -45
  15. data/lib/lithic/models/account_holder.rb +1 -2
  16. data/lib/lithic/models/account_holder_create_params.rb +89 -93
  17. data/lib/lithic/models/auth_rules/auth_rule.rb +1 -1
  18. data/lib/lithic/models/auth_rules/v2/backtest_results.rb +2 -2
  19. data/lib/lithic/models/auth_rules/v2_apply_params.rb +1 -1
  20. data/lib/lithic/models/auth_rules/v2_apply_response.rb +1 -1
  21. data/lib/lithic/models/auth_rules/v2_create_params.rb +1 -1
  22. data/lib/lithic/models/auth_rules/v2_create_response.rb +1 -1
  23. data/lib/lithic/models/auth_rules/v2_draft_response.rb +1 -1
  24. data/lib/lithic/models/auth_rules/v2_list_response.rb +1 -1
  25. data/lib/lithic/models/auth_rules/v2_promote_response.rb +1 -1
  26. data/lib/lithic/models/auth_rules/v2_retrieve_response.rb +1 -1
  27. data/lib/lithic/models/auth_rules/v2_update_params.rb +1 -1
  28. data/lib/lithic/models/auth_rules/v2_update_response.rb +1 -1
  29. data/lib/lithic/models/card_convert_physical_params.rb +5 -5
  30. data/lib/lithic/models/card_reissue_params.rb +5 -5
  31. data/lib/lithic/models/card_renew_params.rb +5 -5
  32. data/lib/lithic/models/credit_products/prime_rate_retrieve_response.rb +1 -1
  33. data/lib/lithic/models/digital_card_art.rb +2 -2
  34. data/lib/lithic/models/event_list_params.rb +1 -1
  35. data/lib/lithic/models/event_subscription.rb +1 -1
  36. data/lib/lithic/models/events/event_subscription_resend_params.rb +27 -0
  37. data/lib/lithic/models/events/subscription_create_params.rb +1 -1
  38. data/lib/lithic/models/events/subscription_update_params.rb +1 -1
  39. data/lib/lithic/models/external_bank_account_create_params.rb +1 -1
  40. data/lib/lithic/models/financial_account.rb +11 -13
  41. data/lib/lithic/models/financial_account_create_params.rb +1 -1
  42. data/lib/lithic/models/financial_account_update_status_params.rb +9 -9
  43. data/lib/lithic/models/financial_accounts/financial_account_credit_config.rb +1 -1
  44. data/lib/lithic/models/financial_accounts/loan_tape.rb +11 -11
  45. data/lib/lithic/models/financial_accounts/statement.rb +11 -11
  46. data/lib/lithic/models/financial_accounts/statement_list_params.rb +1 -1
  47. data/lib/lithic/models/financial_accounts/statements/statement_line_items.rb +1 -1
  48. data/lib/lithic/models/financial_accounts/statements.rb +1 -1
  49. data/lib/lithic/models/kyb.rb +89 -93
  50. data/lib/lithic/models/responder_endpoint_create_response.rb +1 -1
  51. data/lib/lithic/models/responder_endpoint_status.rb +1 -1
  52. data/lib/lithic/models/settlement_report.rb +1 -1
  53. data/lib/lithic/models/three_ds/authentication_retrieve_response.rb +3 -3
  54. data/lib/lithic/models/transaction.rb +5 -5
  55. data/lib/lithic/models/transaction_simulate_authorization_params.rb +1 -1
  56. data/lib/lithic/resources/account_holders.rb +3 -3
  57. data/lib/lithic/resources/accounts.rb +1 -1
  58. data/lib/lithic/resources/auth_rules/v2/backtests.rb +1 -1
  59. data/lib/lithic/resources/book_transfers.rb +1 -1
  60. data/lib/lithic/resources/cards/financial_transactions.rb +1 -1
  61. data/lib/lithic/resources/cards.rb +10 -7
  62. data/lib/lithic/resources/disputes.rb +2 -2
  63. data/lib/lithic/resources/events/event_subscriptions.rb +41 -0
  64. data/lib/lithic/resources/events/subscriptions.rb +3 -3
  65. data/lib/lithic/resources/events.rb +6 -2
  66. data/lib/lithic/resources/external_payments.rb +1 -1
  67. data/lib/lithic/resources/financial_accounts/financial_transactions.rb +1 -1
  68. data/lib/lithic/resources/financial_accounts/loan_tapes.rb +1 -1
  69. data/lib/lithic/resources/financial_accounts/statements.rb +1 -1
  70. data/lib/lithic/resources/financial_accounts.rb +5 -5
  71. data/lib/lithic/resources/management_operations.rb +1 -1
  72. data/lib/lithic/resources/payments.rb +2 -2
  73. data/lib/lithic/resources/reports/settlement/network_totals.rb +1 -1
  74. data/lib/lithic/resources/tokenizations.rb +1 -1
  75. data/lib/lithic/resources/transactions.rb +1 -1
  76. data/lib/lithic/version.rb +1 -1
  77. data/lib/lithic.rb +3 -1
  78. data/rbi/lib/lithic/internal/type/array_of.rbi +2 -2
  79. data/rbi/lib/lithic/internal/type/{boolean_model.rbi → boolean.rbi} +1 -1
  80. data/rbi/lib/lithic/internal/util.rbi +7 -5
  81. data/rbi/lib/lithic/models/account_holder.rbi +1 -2
  82. data/rbi/lib/lithic/models/account_holder_create_params.rbi +95 -95
  83. data/rbi/lib/lithic/models/card_convert_physical_params.rbi +5 -5
  84. data/rbi/lib/lithic/models/card_reissue_params.rbi +5 -5
  85. data/rbi/lib/lithic/models/card_renew_params.rbi +5 -5
  86. data/rbi/lib/lithic/models/events/event_subscription_resend_params.rbi +29 -0
  87. data/rbi/lib/lithic/models/financial_account.rbi +17 -19
  88. data/rbi/lib/lithic/models/financial_account_update_status_params.rbi +15 -30
  89. data/rbi/lib/lithic/models/financial_accounts/loan_tape.rbi +18 -18
  90. data/rbi/lib/lithic/models/financial_accounts/statement.rbi +18 -18
  91. data/rbi/lib/lithic/models/kyb.rbi +95 -95
  92. data/rbi/lib/lithic/resources/account_holders.rbi +6 -14
  93. data/rbi/lib/lithic/resources/cards.rbi +15 -12
  94. data/rbi/lib/lithic/resources/events/event_subscriptions.rbi +26 -0
  95. data/rbi/lib/lithic/resources/events.rbi +3 -0
  96. data/rbi/lib/lithic/resources/financial_accounts.rbi +3 -3
  97. data/rbi/lib/lithic/version.rbi +1 -1
  98. data/sig/lithic/internal/type/array_of.rbs +2 -2
  99. data/sig/lithic/internal/type/{boolean_model.rbs → boolean.rbs} +1 -1
  100. data/sig/lithic/internal/util.rbs +5 -5
  101. data/sig/lithic/models/account_holder_create_params.rbs +47 -43
  102. data/sig/lithic/models/card_convert_physical_params.rbs +2 -2
  103. data/sig/lithic/models/card_reissue_params.rbs +2 -2
  104. data/sig/lithic/models/card_renew_params.rbs +2 -2
  105. data/sig/lithic/models/events/event_subscription_resend_params.rbs +22 -0
  106. data/sig/lithic/models/financial_account.rbs +6 -6
  107. data/sig/lithic/models/financial_account_update_status_params.rbs +6 -6
  108. data/sig/lithic/models/financial_accounts/loan_tape.rbs +6 -6
  109. data/sig/lithic/models/financial_accounts/statement.rbs +6 -6
  110. data/sig/lithic/models/kyb.rbs +47 -43
  111. data/sig/lithic/resources/account_holders.rbs +1 -1
  112. data/sig/lithic/resources/events/event_subscriptions.rbs +15 -0
  113. data/sig/lithic/resources/events.rbs +2 -0
  114. data/sig/lithic/resources/financial_accounts.rbs +1 -1
  115. data/sig/lithic/version.rbs +1 -1
  116. metadata +11 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c878a0ee5f6aba02f1f1ccd5ea1afeb092e3b5b71495a3ebf590154ad80b4d88
4
- data.tar.gz: d849bdf0caf2255bddaaa86f9ed6c3af7a1b4e277015cdae0adaba2861f48e3e
3
+ metadata.gz: 6cc0455f8a47c113c091409b3b4ed5b5522a3ae3c2272f68701084ffbb4b35bf
4
+ data.tar.gz: 1bc14153bdcce95840ab82520a99ca49f9a943850313c0f73fa15a2a8d4cfc94
5
5
  SHA512:
6
- metadata.gz: 7be928a465d075049a036380e5c195b634095d0a417bc1c4ca451db1a6aa0a87661ac51e528c5fcdb3cff69ce6281675063927becb88abb11ff066b8cae65c50
7
- data.tar.gz: b9711354f43f14e04e7fbe2aa47f0d6faa580271e67c76981f3074ce17e02bb5ef1318773424ac6272c068b6f67d1ade506bec1c57896fe9f95856dd1a0b232f
6
+ metadata.gz: f8c91140b58743c9972ebb4d79a003844f242f076056a3c1ce7052125ec5c6941bf1033972b23f9c8637768123abc450c32efa651ea59c9acf571c673b021f14
7
+ data.tar.gz: 12ccc695ebb93e4df2aa828dbff4bece059d99ddd249dfa7e837229c01ca196a5a7956d832fc01557ffa33a524231e880aea6c8578d238713b58161b7cf1c04e
data/README.md CHANGED
@@ -12,10 +12,14 @@ The underlying REST API documentation can be found on [docs.lithic.com](https://
12
12
 
13
13
  To use this gem, install via Bundler by adding the following to your application's `Gemfile`:
14
14
 
15
+ <!-- x-release-please-start-version -->
16
+
15
17
  ```ruby
16
- gem "lithic", "~> 0.1.0.pre.alpha.4"
18
+ gem "lithic", "~> 0.1.0.pre.alpha.5"
17
19
  ```
18
20
 
21
+ <!-- x-release-please-end -->
22
+
19
23
  To fetch an initial copy of the gem:
20
24
 
21
25
  ```sh
@@ -123,9 +127,23 @@ lithic.cards.list(page_size: 10, request_options: {timeout: 5})
123
127
 
124
128
  ## LSP Support
125
129
 
126
- ### Sorbet
130
+ ### Solargraph
131
+
132
+ This library includes [Solargraph](https://solargraph.org) support for both auto completion and go to definition.
133
+
134
+ ```ruby
135
+ gem "solargraph", group: :development
136
+ ```
137
+
138
+ After Solargraph is installed, **you must populate its index** either via the provided editor command, or by running the following in your terminal:
127
139
 
128
- **This library emits an intentional warning under the [`tapioca` toolchain](https://github.com/Shopify/tapioca)**. This is normal, and does not impact functionality.
140
+ ```sh
141
+ bundle exec solargraph gems
142
+ ```
143
+
144
+ Otherwise Solargraph will not be able to provide type information or auto-completion for any non-indexed libraries.
145
+
146
+ ### Sorbet
129
147
 
130
148
  This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`.
131
149
 
@@ -136,11 +154,17 @@ Due to limitations with the Sorbet type system, where a method otherwise can tak
136
154
  Please follow Sorbet's [setup guides](https://sorbet.org/docs/adopting) for best experience.
137
155
 
138
156
  ```ruby
139
- model = Lithic::Models::CardCreateParams.new(type: "SINGLE_USE")
157
+ params = Lithic::Models::CardCreateParams.new(type: "SINGLE_USE")
140
158
 
141
- lithic.cards.create(**model)
159
+ lithic.cards.create(**params)
142
160
  ```
143
161
 
162
+ Note: **This library emits an intentional warning under the [`tapioca` toolchain](https://github.com/Shopify/tapioca)**. This is normal, and does not impact functionality.
163
+
164
+ ### Ruby LSP
165
+
166
+ The Ruby LSP has [best effort support](https://shopify.github.io/ruby-lsp/#guessed-types) for inferring type information from Ruby code, and as such it may not always be able to provide accurate type information.
167
+
144
168
  ## Advanced
145
169
 
146
170
  ### Making custom/undocumented requests
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Lithic
4
4
  module Internal
5
+ # @generic Elem
6
+ #
5
7
  # @example
6
8
  # if cursor_page.has_next?
7
9
  # cursor_page = cursor_page.next_page
@@ -14,7 +16,7 @@ module Lithic
14
16
  class CursorPage
15
17
  include Lithic::Internal::Type::BasePage
16
18
 
17
- # @return [Array<Object>, nil]
19
+ # @return [Array<generic<Elem>>, nil]
18
20
  attr_accessor :data
19
21
 
20
22
  # @return [Boolean]
@@ -61,6 +63,8 @@ module Lithic
61
63
  end
62
64
 
63
65
  # @param blk [Proc]
66
+ #
67
+ # @yieldparam [generic<Elem>]
64
68
  def auto_paging_each(&blk)
65
69
  unless block_given?
66
70
  raise ArgumentError.new("A block must be given to ##{__method__}")
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Lithic
4
4
  module Internal
5
+ # @generic Elem
6
+ #
5
7
  # @example
6
8
  # if single_page.has_next?
7
9
  # single_page = single_page.next_page
@@ -14,7 +16,7 @@ module Lithic
14
16
  class SinglePage
15
17
  include Lithic::Internal::Type::BasePage
16
18
 
17
- # @return [Array<Object>, nil]
19
+ # @return [Array<generic<Elem>>, nil]
18
20
  attr_accessor :data
19
21
 
20
22
  # @return [Boolean]
@@ -55,6 +57,8 @@ module Lithic
55
57
  end
56
58
 
57
59
  # @param blk [Proc]
60
+ #
61
+ # @yieldparam [generic<Elem>]
58
62
  def auto_paging_each(&blk)
59
63
  unless block_given?
60
64
  raise ArgumentError.new("A block must be given to ##{__method__}")
@@ -131,7 +131,7 @@ module Lithic
131
131
  # @api private
132
132
  #
133
133
  # @param status [Integer, Lithic::Errors::APIConnectionError]
134
- # @param stream [Enumerable, nil]
134
+ # @param stream [Enumerable<String>, nil]
135
135
  def reap_connection!(status, stream:)
136
136
  case status
137
137
  in (..199) | (300..499)
@@ -328,7 +328,7 @@ module Lithic
328
328
  # @param send_retry_header [Boolean]
329
329
  #
330
330
  # @raise [Lithic::Errors::APIError]
331
- # @return [Array(Integer, Net::HTTPResponse, Enumerable)]
331
+ # @return [Array(Integer, Net::HTTPResponse, Enumerable<String>)]
332
332
  private def send_request(request, redirect_count:, retry_count:, send_retry_header:)
333
333
  url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout)
334
334
  input = {**request.except(:timeout), deadline: Lithic::Internal::Util.monotonic_secs + timeout}
@@ -119,7 +119,7 @@ module Lithic
119
119
  #
120
120
  # @option request [Float] :deadline
121
121
  #
122
- # @return [Array(Integer, Net::HTTPResponse, Enumerable)]
122
+ # @return [Array(Integer, Net::HTTPResponse, Enumerable<String>)]
123
123
  def execute(request)
124
124
  url, deadline = request.fetch_values(:url, :deadline)
125
125
 
@@ -7,6 +7,8 @@ module Lithic
7
7
  #
8
8
  # @abstract
9
9
  #
10
+ # @generic Elem
11
+ #
10
12
  # Array of items of a given type.
11
13
  class ArrayOf
12
14
  include Lithic::Internal::Type::Converter
@@ -40,7 +42,7 @@ module Lithic
40
42
 
41
43
  # @api private
42
44
  #
43
- # @param value [Enumerable, Object]
45
+ # @param value [Array<Object>, Object]
44
46
  #
45
47
  # @param state [Hash{Symbol=>Object}] .
46
48
  #
@@ -75,7 +77,7 @@ module Lithic
75
77
 
76
78
  # @api private
77
79
  #
78
- # @param value [Enumerable, Object]
80
+ # @param value [Array<Object>, Object]
79
81
  #
80
82
  # @return [Array<Object>, Object]
81
83
  def dump(value)
@@ -85,7 +87,7 @@ module Lithic
85
87
 
86
88
  # @api private
87
89
  #
88
- # @return [Lithic::Internal::Type::Converter, Class]
90
+ # @return [generic<Elem>]
89
91
  protected def item_type = @item_type_fn.call
90
92
 
91
93
  # @api private
@@ -168,7 +168,9 @@ module Lithic
168
168
  # @param other [Object]
169
169
  #
170
170
  # @return [Boolean]
171
- def ==(other) = other.is_a?(Class) && other <= Lithic::Internal::Type::BaseModel && other.fields == fields
171
+ def ==(other)
172
+ other.is_a?(Class) && other <= Lithic::Internal::Type::BaseModel && other.fields == fields
173
+ end
172
174
  end
173
175
 
174
176
  # @param other [Object]
@@ -256,6 +258,7 @@ module Lithic
256
258
  return super
257
259
  end
258
260
 
261
+ is_param = singleton_class <= Lithic::Internal::Type::RequestParameters::Converter
259
262
  acc = {}
260
263
 
261
264
  coerced.each do |key, val|
@@ -264,19 +267,21 @@ module Lithic
264
267
  in nil
265
268
  acc.store(name, super(val))
266
269
  else
267
- mode, api_name, type_fn = field.fetch_values(:mode, :api_name, :type_fn)
270
+ mode, type_fn = field.fetch_values(:mode, :type_fn)
268
271
  case mode
269
272
  in :coerce
270
273
  next
271
274
  else
272
275
  target = type_fn.call
276
+ api_name = is_param ? name : field.fetch(:api_name)
273
277
  acc.store(api_name, Lithic::Internal::Type::Converter.dump(target, val))
274
278
  end
275
279
  end
276
280
  end
277
281
 
278
- known_fields.each_value do |field|
279
- mode, api_name, const = field.fetch_values(:mode, :api_name, :const)
282
+ known_fields.each do |name, field|
283
+ mode, const = field.fetch_values(:mode, :const)
284
+ api_name = is_param ? name : field.fetch(:api_name)
280
285
  next if mode == :coerce || acc.key?(api_name) || const == Lithic::Internal::OMIT
281
286
  acc.store(api_name, const)
282
287
  end
@@ -350,7 +355,8 @@ module Lithic
350
355
  in Hash => coerced
351
356
  @data = coerced
352
357
  else
353
- raise ArgumentError.new("Expected a #{Hash} or #{Lithic::Internal::Type::BaseModel}, got #{data.inspect}")
358
+ message = "Expected a #{Hash} or #{Lithic::Internal::Type::BaseModel}, got #{data.inspect}"
359
+ raise ArgumentError.new(message)
354
360
  end
355
361
  end
356
362
 
@@ -358,7 +364,7 @@ module Lithic
358
364
  def inspect
359
365
  rows = self.class.known_fields.keys.map do
360
366
  "#{_1}=#{@data.key?(_1) ? public_send(_1) : ''}"
361
- rescue Lithic::ConversionError
367
+ rescue Lithic::Errors::ConversionError
362
368
  "#{_1}=#{@data.fetch(_1)}"
363
369
  end
364
370
  "#<#{self.class.name}:0x#{object_id.to_s(16)} #{rows.join(' ')}>"
@@ -3,6 +3,8 @@
3
3
  module Lithic
4
4
  module Internal
5
5
  module Type
6
+ # @generic Elem
7
+ #
6
8
  # This module provides a base implementation for paginated responses in the SDK.
7
9
  module BasePage
8
10
  # rubocop:disable Lint/UnusedMethodArgument
@@ -16,10 +18,11 @@ module Lithic
16
18
 
17
19
  # @param blk [Proc]
18
20
  #
21
+ # @yieldparam [generic<Elem>]
19
22
  # @return [void]
20
23
  def auto_paging_each(&blk) = (raise NotImplementedError)
21
24
 
22
- # @return [Enumerable]
25
+ # @return [Enumerable<generic<Elem>>]
23
26
  def to_enum = super(:auto_paging_each)
24
27
 
25
28
  alias_method :enum_for, :to_enum
@@ -8,7 +8,7 @@ module Lithic
8
8
  # @abstract
9
9
  #
10
10
  # Ruby has no Boolean class; this is something for models to refer to.
11
- class BooleanModel
11
+ class Boolean
12
12
  extend Lithic::Internal::Type::Converter
13
13
 
14
14
  # @param other [Object]
@@ -19,7 +19,7 @@ module Lithic
19
19
  # @param other [Object]
20
20
  #
21
21
  # @return [Boolean]
22
- def self.==(other) = other.is_a?(Class) && other <= Lithic::Internal::Type::BooleanModel
22
+ def self.==(other) = other.is_a?(Class) && other <= Lithic::Internal::Type::Boolean
23
23
 
24
24
  class << self
25
25
  # @api private
@@ -64,7 +64,7 @@ module Lithic
64
64
  in Hash
65
65
  type_info(spec.slice(:const, :enum, :union).first&.last)
66
66
  in true | false
67
- -> { Lithic::Internal::Type::BooleanModel }
67
+ -> { Lithic::Internal::Type::Boolean }
68
68
  in Lithic::Internal::Type::Converter | Class | Symbol
69
69
  -> { spec }
70
70
  in NilClass | Integer | Float
@@ -168,6 +168,9 @@ module Lithic
168
168
  in String | Symbol | Numeric
169
169
  exactness[value.is_a?(Numeric) ? :maybe : :yes] += 1
170
170
  return value.to_s
171
+ in StringIO
172
+ exactness[:yes] += 1
173
+ return value.string
171
174
  else
172
175
  if strictness == :strong
173
176
  message = "no implicit conversion of #{value.class} into #{target.inspect}"
@@ -209,7 +212,9 @@ module Lithic
209
212
  #
210
213
  # @return [Object]
211
214
  def dump(target, value)
215
+ # rubocop:disable Layout/LineLength
212
216
  target.is_a?(Lithic::Internal::Type::Converter) ? target.dump(value) : Lithic::Internal::Type::Unknown.dump(value)
217
+ # rubocop:enable Layout/LineLength
213
218
  end
214
219
  end
215
220
  end
@@ -58,7 +58,9 @@ module Lithic
58
58
  #
59
59
  # @return [Boolean]
60
60
  def ==(other)
61
+ # rubocop:disable Layout/LineLength
61
62
  other.is_a?(Module) && other.singleton_class <= Lithic::Internal::Type::Enum && other.values.to_set == values.to_set
63
+ # rubocop:enable Layout/LineLength
62
64
  end
63
65
 
64
66
  # @api private
@@ -7,6 +7,8 @@ module Lithic
7
7
  #
8
8
  # @abstract
9
9
  #
10
+ # @generic Elem
11
+ #
10
12
  # Hash of items of a given type.
11
13
  class HashOf
12
14
  include Lithic::Internal::Type::Converter
@@ -111,7 +113,7 @@ module Lithic
111
113
 
112
114
  # @api private
113
115
  #
114
- # @return [Lithic::Internal::Type::Converter, Class]
116
+ # @return [generic<Elem>]
115
117
  protected def item_type = @item_type_fn.call
116
118
 
117
119
  # @api private
@@ -61,7 +61,7 @@ module Lithic
61
61
  # @return [Boolean]
62
62
  def primitive?(input)
63
63
  case input
64
- in true | false | Integer | Float | Symbol | String
64
+ in true | false | Numeric | Symbol | String
65
65
  true
66
66
  else
67
67
  false
@@ -70,13 +70,11 @@ module Lithic
70
70
 
71
71
  # @api private
72
72
  #
73
- # @param input [Object]
73
+ # @param input [String, Boolean]
74
74
  #
75
75
  # @return [Boolean, Object]
76
76
  def coerce_boolean(input)
77
77
  case input.is_a?(String) ? input.downcase : input
78
- in Numeric
79
- input.nonzero?
80
78
  in "true"
81
79
  true
82
80
  in "false"
@@ -88,7 +86,7 @@ module Lithic
88
86
 
89
87
  # @api private
90
88
  #
91
- # @param input [Object]
89
+ # @param input [String, Boolean]
92
90
  #
93
91
  # @raise [ArgumentError]
94
92
  # @return [Boolean, nil]
@@ -103,34 +101,20 @@ module Lithic
103
101
 
104
102
  # @api private
105
103
  #
106
- # @param input [Object]
104
+ # @param input [String, Integer]
107
105
  #
108
106
  # @return [Integer, Object]
109
107
  def coerce_integer(input)
110
- case input
111
- in true
112
- 1
113
- in false
114
- 0
115
- else
116
- Integer(input, exception: false) || input
117
- end
108
+ Integer(input, exception: false) || input
118
109
  end
119
110
 
120
111
  # @api private
121
112
  #
122
- # @param input [Object]
113
+ # @param input [String, Integer, Float]
123
114
  #
124
115
  # @return [Float, Object]
125
116
  def coerce_float(input)
126
- case input
127
- in true
128
- 1.0
129
- in false
130
- 0.0
131
- else
132
- Float(input, exception: false) || input
133
- end
117
+ Float(input, exception: false) || input
134
118
  end
135
119
 
136
120
  # @api private
@@ -159,12 +143,7 @@ module Lithic
159
143
  private def deep_merge_lr(lhs, rhs, concat: false)
160
144
  case [lhs, rhs, concat]
161
145
  in [Hash, Hash, _]
162
- rhs_cleaned = rhs.reject { _2 == Lithic::Internal::OMIT }
163
- lhs
164
- .reject { |key, _| rhs[key] == Lithic::Internal::OMIT }
165
- .merge(rhs_cleaned) do |_, old_val, new_val|
166
- deep_merge_lr(old_val, new_val, concat: concat)
167
- end
146
+ lhs.merge(rhs) { deep_merge_lr(_2, _3, concat: concat) }
168
147
  in [Array, Array, true]
169
148
  lhs.concat(rhs)
170
149
  else
@@ -362,7 +341,7 @@ module Lithic
362
341
  value =
363
342
  case val
364
343
  in Array
365
- val.map { _1.to_s.strip }.join(", ")
344
+ val.filter_map { _1&.to_s&.strip }.join(", ")
366
345
  else
367
346
  val&.to_s&.strip
368
347
  end
@@ -419,7 +398,7 @@ module Lithic
419
398
 
420
399
  # @api private
421
400
  #
422
- # @param stream [String, IO, StringIO, Enumerable]
401
+ # @param stream [String, IO, StringIO, Enumerable<String>]
423
402
  # @param blk [Proc]
424
403
  #
425
404
  # @yieldparam [String]
@@ -434,7 +413,7 @@ module Lithic
434
413
  # @param blk [Proc]
435
414
  #
436
415
  # @yieldparam [Enumerator::Yielder]
437
- # @return [Enumerable]
416
+ # @return [Enumerable<String>]
438
417
  def writable_enum(&blk)
439
418
  Enumerator.new do |y|
440
419
  y.define_singleton_method(:write) do
@@ -469,7 +448,7 @@ module Lithic
469
448
  case val
470
449
  in IO
471
450
  y << "Content-Type: application/octet-stream\r\n\r\n"
472
- IO.copy_stream(val, y)
451
+ IO.copy_stream(val.tap(&:rewind), y)
473
452
  in StringIO
474
453
  y << "Content-Type: application/octet-stream\r\n\r\n"
475
454
  y << val.string
@@ -490,7 +469,7 @@ module Lithic
490
469
  #
491
470
  # @param body [Object]
492
471
  #
493
- # @return [Array(String, Enumerable)]
472
+ # @return [Array(String, Enumerable<String>)]
494
473
  private def encode_multipart_streaming(body)
495
474
  boundary = SecureRandom.urlsafe_base64(60)
496
475
 
@@ -525,7 +504,7 @@ module Lithic
525
504
  def encode_content(headers, body)
526
505
  content_type = headers["content-type"]
527
506
  case [content_type, body]
528
- in [%r{^application/(?:vnd\.api\+)?json}, Hash | Array]
507
+ in [%r{^application/(?:vnd\.api\+)?json}, _] unless body.nil?
529
508
  [headers, JSON.fast_generate(body)]
530
509
  in [%r{^application/(?:x-)?jsonl}, Enumerable]
531
510
  [headers, body.lazy.map { JSON.fast_generate(_1) }]
@@ -533,8 +512,12 @@ module Lithic
533
512
  boundary, strio = encode_multipart_streaming(body)
534
513
  headers = {**headers, "content-type" => "#{content_type}; boundary=#{boundary}"}
535
514
  [headers, strio]
515
+ in [_, IO]
516
+ [headers, body.tap(&:rewind)]
536
517
  in [_, StringIO]
537
518
  [headers, body.string]
519
+ in [_, Symbol | Numeric]
520
+ [headers, body.to_s]
538
521
  else
539
522
  [headers, body]
540
523
  end
@@ -543,7 +526,7 @@ module Lithic
543
526
  # @api private
544
527
  #
545
528
  # @param headers [Hash{String=>String}, Net::HTTPHeader]
546
- # @param stream [Enumerable]
529
+ # @param stream [Enumerable<String>]
547
530
  # @param suppress_error [Boolean]
548
531
  #
549
532
  # @raise [JSON::ParserError]
@@ -580,11 +563,11 @@ module Lithic
580
563
  #
581
564
  # https://doc.rust-lang.org/std/iter/trait.FusedIterator.html
582
565
  #
583
- # @param enum [Enumerable]
566
+ # @param enum [Enumerable<Object>]
584
567
  # @param external [Boolean]
585
568
  # @param close [Proc]
586
569
  #
587
- # @return [Enumerable]
570
+ # @return [Enumerable<Object>]
588
571
  def fused_enum(enum, external: false, &close)
589
572
  fused = false
590
573
  iter = Enumerator.new do |y|
@@ -610,7 +593,7 @@ module Lithic
610
593
 
611
594
  # @api private
612
595
  #
613
- # @param enum [Enumerable, nil]
596
+ # @param enum [Enumerable<Object>, nil]
614
597
  def close_fused!(enum)
615
598
  return unless enum.is_a?(Enumerator)
616
599
 
@@ -621,11 +604,11 @@ module Lithic
621
604
 
622
605
  # @api private
623
606
  #
624
- # @param enum [Enumerable, nil]
607
+ # @param enum [Enumerable<Object>, nil]
625
608
  # @param blk [Proc]
626
609
  #
627
610
  # @yieldparam [Enumerator::Yielder]
628
- # @return [Enumerable]
611
+ # @return [Enumerable<Object>]
629
612
  def chain_fused(enum, &blk)
630
613
  iter = Enumerator.new { blk.call(_1) }
631
614
  fused_enum(iter) { close_fused!(enum) }
@@ -635,9 +618,9 @@ module Lithic
635
618
  class << self
636
619
  # @api private
637
620
  #
638
- # @param enum [Enumerable]
621
+ # @param enum [Enumerable<String>]
639
622
  #
640
- # @return [Enumerable]
623
+ # @return [Enumerable<String>]
641
624
  def decode_lines(enum)
642
625
  re = /(\r\n|\r|\n)/
643
626
  buffer = String.new.b
@@ -671,9 +654,9 @@ module Lithic
671
654
  #
672
655
  # https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream
673
656
  #
674
- # @param lines [Enumerable]
657
+ # @param lines [Enumerable<String>]
675
658
  #
676
- # @return [Hash{Symbol=>Object}]
659
+ # @return [Enumerable<Hash{Symbol=>Object}>]
677
660
  def decode_sse(lines)
678
661
  # rubocop:disable Metrics/BlockLength
679
662
  chain_fused(lines) do |y|
@@ -27,8 +27,7 @@ module Lithic
27
27
  # attr_writer :account_token
28
28
 
29
29
  # @!attribute [r] beneficial_owner_entities
30
- # Only present when user_type == "BUSINESS". List of all entities with >25%
31
- # ownership in the company.
30
+ # Deprecated. Only present when user_type == "BUSINESS".
32
31
  #
33
32
  # @return [Array<Lithic::Models::AccountHolder::BeneficialOwnerEntity>, nil]
34
33
  optional :beneficial_owner_entities,