modern_treasury 0.6.0 → 0.7.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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/README.md +9 -9
  4. data/lib/modern_treasury/errors.rb +25 -11
  5. data/lib/modern_treasury/file_part.rb +10 -7
  6. data/lib/modern_treasury/internal/page.rb +3 -3
  7. data/lib/modern_treasury/internal/transport/base_client.rb +11 -7
  8. data/lib/modern_treasury/internal/transport/pooled_net_requester.rb +7 -10
  9. data/lib/modern_treasury/internal/type/base_page.rb +1 -1
  10. data/lib/modern_treasury/internal/type/file_input.rb +7 -4
  11. data/lib/modern_treasury/internal/util.rb +5 -5
  12. data/lib/modern_treasury/models/bulk_request_create_params.rb +49 -2
  13. data/lib/modern_treasury/models/counterparty.rb +5 -18
  14. data/lib/modern_treasury/models/counterparty_create_params.rb +5 -16
  15. data/lib/modern_treasury/models/incoming_payment_detail.rb +23 -1
  16. data/lib/modern_treasury/models/internal_account.rb +25 -1
  17. data/lib/modern_treasury/models/internal_account_list_params.rb +23 -1
  18. data/lib/modern_treasury/models/invoice_list_params.rb +17 -1
  19. data/lib/modern_treasury/models/payment_order.rb +175 -1
  20. data/lib/modern_treasury/models/payment_order_create_async_params.rb +22 -1
  21. data/lib/modern_treasury/models/payment_order_create_params.rb +22 -1
  22. data/lib/modern_treasury/models/payment_order_list_params.rb +1 -0
  23. data/lib/modern_treasury/models/payment_order_update_params.rb +23 -1
  24. data/lib/modern_treasury/models/payment_orders/reversal.rb +24 -1
  25. data/lib/modern_treasury/models/payment_reference.rb +1 -0
  26. data/lib/modern_treasury/models/return_create_params.rb +21 -1
  27. data/lib/modern_treasury/models/return_object.rb +25 -1
  28. data/lib/modern_treasury/models/transaction.rb +1 -0
  29. data/lib/modern_treasury/resources/counterparties.rb +1 -1
  30. data/lib/modern_treasury/resources/internal_accounts.rb +3 -1
  31. data/lib/modern_treasury/resources/invoices.rb +5 -1
  32. data/lib/modern_treasury/resources/payment_orders.rb +9 -3
  33. data/lib/modern_treasury/resources/returns.rb +3 -1
  34. data/lib/modern_treasury/version.rb +1 -1
  35. data/rbi/modern_treasury/errors.rbi +29 -2
  36. data/rbi/modern_treasury/file_part.rbi +1 -1
  37. data/rbi/modern_treasury/internal/transport/base_client.rbi +4 -5
  38. data/rbi/modern_treasury/internal/type/base_page.rbi +1 -1
  39. data/rbi/modern_treasury/internal/util.rbi +1 -1
  40. data/rbi/modern_treasury/models/bulk_request_create_params.rbi +133 -0
  41. data/rbi/modern_treasury/models/counterparty.rbi +3 -49
  42. data/rbi/modern_treasury/models/counterparty_create_params.rbi +4 -62
  43. data/rbi/modern_treasury/models/incoming_payment_detail.rbi +54 -0
  44. data/rbi/modern_treasury/models/internal_account.rbi +52 -0
  45. data/rbi/modern_treasury/models/internal_account_list_params.rbi +66 -0
  46. data/rbi/modern_treasury/models/invoice_list_params.rbi +22 -0
  47. data/rbi/modern_treasury/models/payment_order.rbi +305 -0
  48. data/rbi/modern_treasury/models/payment_order_create_async_params.rbi +64 -0
  49. data/rbi/modern_treasury/models/payment_order_create_params.rbi +64 -0
  50. data/rbi/modern_treasury/models/payment_order_list_params.rbi +5 -0
  51. data/rbi/modern_treasury/models/payment_order_update_params.rbi +69 -0
  52. data/rbi/modern_treasury/models/payment_orders/reversal.rbi +54 -0
  53. data/rbi/modern_treasury/models/payment_reference.rbi +5 -0
  54. data/rbi/modern_treasury/models/return_create_params.rbi +64 -0
  55. data/rbi/modern_treasury/models/return_object.rbi +58 -0
  56. data/rbi/modern_treasury/models/transaction.rbi +5 -0
  57. data/rbi/modern_treasury/resources/counterparties.rbi +1 -2
  58. data/rbi/modern_treasury/resources/internal_accounts.rbi +3 -0
  59. data/rbi/modern_treasury/resources/invoices.rbi +6 -0
  60. data/rbi/modern_treasury/resources/payment_orders.rbi +12 -0
  61. data/rbi/modern_treasury/resources/returns.rbi +4 -0
  62. data/sig/modern_treasury/errors.rbs +7 -0
  63. data/sig/modern_treasury/file_part.rbs +1 -1
  64. data/sig/modern_treasury/models/bulk_request_create_params.rbs +46 -0
  65. data/sig/modern_treasury/models/counterparty.rbs +4 -18
  66. data/sig/modern_treasury/models/counterparty_create_params.rbs +5 -21
  67. data/sig/modern_treasury/models/incoming_payment_detail.rbs +18 -0
  68. data/sig/modern_treasury/models/internal_account.rbs +20 -0
  69. data/sig/modern_treasury/models/internal_account_list_params.rbs +25 -1
  70. data/sig/modern_treasury/models/invoice_list_params.rbs +14 -0
  71. data/sig/modern_treasury/models/payment_order.rbs +132 -0
  72. data/sig/modern_treasury/models/payment_order_create_async_params.rbs +22 -0
  73. data/sig/modern_treasury/models/payment_order_create_params.rbs +22 -0
  74. data/sig/modern_treasury/models/payment_order_list_params.rbs +2 -0
  75. data/sig/modern_treasury/models/payment_order_update_params.rbs +24 -0
  76. data/sig/modern_treasury/models/payment_orders/reversal.rbs +18 -0
  77. data/sig/modern_treasury/models/payment_reference.rbs +2 -0
  78. data/sig/modern_treasury/models/return_create_params.rbs +23 -1
  79. data/sig/modern_treasury/models/return_object.rbs +22 -0
  80. data/sig/modern_treasury/models/transaction.rbs +2 -0
  81. data/sig/modern_treasury/resources/counterparties.rbs +1 -1
  82. data/sig/modern_treasury/resources/internal_accounts.rbs +1 -0
  83. data/sig/modern_treasury/resources/invoices.rbs +2 -0
  84. data/sig/modern_treasury/resources/payment_orders.rbs +3 -0
  85. data/sig/modern_treasury/resources/returns.rbs +1 -0
  86. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f5ca04a82e3c5557fec0447900272e8ba64ada8767479b153e7324808f12840
4
- data.tar.gz: d38c2cd97743067d0d03fe5becf94af79e573e47205d286f6314f2976ec3d7f1
3
+ metadata.gz: '0904ee9dd1992cf68b43a7549deaa4069fea261e495029400aa45bb5b8df4d49'
4
+ data.tar.gz: 1982a17e4e0b307a9f75086f06920484d0597391b6263eeddc480b67f1c5f4e3
5
5
  SHA512:
6
- metadata.gz: 6d733d8bf4a0dbba49c2cac2b7e556d349c7ac492e4baa43501328f3cec3cecc3e801279d657d7d7dc9befe05de00b8cb02e736df40a3eb9d3ea580878735820
7
- data.tar.gz: fc38b14a011e9ca3889589caa11236be20a3844b992b53ec60cbc3f92ec7059549f7c0d2e738a0607ceaa0f823f27ec77aff8fede573ecdfcd5ceefc7815fc1b
6
+ metadata.gz: c7466008b3f69bda7eb2f3fd5a998407c8037edeab8ad2ba50ef9f239ef5f3a10180cb84d91eed9440f18f9b66b997d45d1b614998c80d55d1ff029f1b76606e
7
+ data.tar.gz: 0bead40bb0c48e53a10fe5b1baf301a0ccc41b8fbdd63be5220fbf553dcc3ab0ce48bcf441dbff2d8edd5f5a908d97d443b79977d6e8d0b97081eb918325f295
data/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0 (2025-10-14)
4
+
5
+ Full Changelog: [v0.6.0...v0.7.0](https://github.com/Modern-Treasury/modern-treasury-ruby/compare/v0.6.0...v0.7.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** api update ([f37bdd2](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/f37bdd2eab9164cf67cc01d7ff91eb8b43ff5156))
10
+ * **api:** api update ([0de7b36](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/0de7b367b1ba0798455460af4a1f6f902ced1fe3))
11
+ * **api:** api update ([8be10ad](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/8be10ad6a312243a6f498eae30371e573fbaa153))
12
+ * **api:** api update ([40350f0](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/40350f05ed2bf464e98b2dc71a66d20dc67c510f))
13
+ * **api:** api update ([6254376](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/6254376cd385f807e07f962f8d017a6aba11687c))
14
+ * **api:** api update ([65f533f](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/65f533f6bba9b9a26773181a7a4bc2640b8cd49b))
15
+ * **api:** api update ([84ea477](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/84ea47740ec4a929a2e396909cd300207f176023))
16
+ * **api:** api update ([53c103b](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/53c103b611ac9642c5490172097fd58e49a5415c))
17
+ * **api:** api update ([19f4fc1](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/19f4fc1d0fa8b478d9e1f416994eb3f4d1bf76ec))
18
+ * **api:** api update ([071a9fc](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/071a9fc6611d175138c211b387763ee6a5a88b5d))
19
+ * **api:** api update ([ffc7d79](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/ffc7d79a60947c41ee9d6377045b76e1f4a18c3e))
20
+ * **api:** api update ([14591db](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/14591dba3e463de9bd135c4cfb439e7bfa21b124))
21
+ * expose response headers for both streams and errors ([b2e9b9e](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/b2e9b9e7dda9b5c8e06118465be0711b65d4b209))
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * always send `filename=...` for multipart requests where a file is expected ([71bddaf](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/71bddaf2e91e843cc24450f3fc41da459dc963a0))
27
+ * coroutine leaks from connection pool ([d75fe60](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/d75fe608595aa1cb6493809e1466af4bb3c235d4))
28
+ * **internal:** use null byte as file separator in the fast formatting script ([cfc916d](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/cfc916de6390536ef027ccc7bae25a247f6602bc))
29
+ * shorten multipart boundary sep to less than RFC specificed max length ([ac1bc6a](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/ac1bc6aecbc03f55fd8e879b7585c1fe0a3a7f48))
30
+ * should not reuse buffers for `IO.copy_stream` interop ([8d4bd02](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/8d4bd02e4771eb7762f2e4ef678b0206f309eded))
31
+
32
+
33
+ ### Performance Improvements
34
+
35
+ * faster code formatting ([8cfac52](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/8cfac52d0b5fd4e38d1d0e35c2e6791a160f7ad7))
36
+
37
+
38
+ ### Chores
39
+
40
+ * allow fast-format to use bsd sed as well ([02dfec0](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/02dfec098434161efb839a0b9c4e209ff2c718b2))
41
+ * do not install brew dependencies in ./scripts/bootstrap by default ([d743aac](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/d743aac958c1613a4e44aeb09612b9dd42d60452))
42
+ * ignore linter error for tests having large collections ([8d6b26b](https://github.com/Modern-Treasury/modern-treasury-ruby/commit/8d6b26b092354a38b43270e1418d98840e1d2a1f))
43
+
3
44
  ## 0.6.0 (2025-09-11)
4
45
 
5
46
  Full Changelog: [v0.5.0...v0.6.0](https://github.com/Modern-Treasury/modern-treasury-ruby/compare/v0.5.0...v0.6.0)
data/README.md CHANGED
@@ -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 "modern_treasury", "~> 0.6.0"
18
+ gem "modern_treasury", "~> 0.7.0"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -258,25 +258,25 @@ modern_treasury.counterparties.create(**params)
258
258
  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:
259
259
 
260
260
  ```ruby
261
- # :denied
262
- puts(ModernTreasury::CounterpartyCreateParams::VerificationStatus::DENIED)
261
+ # :credit
262
+ puts(ModernTreasury::TransactionDirection::CREDIT)
263
263
 
264
- # Revealed type: `T.all(ModernTreasury::CounterpartyCreateParams::VerificationStatus, Symbol)`
265
- T.reveal_type(ModernTreasury::CounterpartyCreateParams::VerificationStatus::DENIED)
264
+ # Revealed type: `T.all(ModernTreasury::TransactionDirection, Symbol)`
265
+ T.reveal_type(ModernTreasury::TransactionDirection::CREDIT)
266
266
  ```
267
267
 
268
268
  Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:
269
269
 
270
270
  ```ruby
271
271
  # Using the enum constants preserves the tagged type information:
272
- modern_treasury.counterparties.create(
273
- verification_status: ModernTreasury::CounterpartyCreateParams::VerificationStatus::DENIED,
272
+ modern_treasury.counterparties.collect_account(
273
+ direction: ModernTreasury::TransactionDirection::CREDIT,
274
274
  # …
275
275
  )
276
276
 
277
277
  # Literal values are also permissible:
278
- modern_treasury.counterparties.create(
279
- verification_status: :denied,
278
+ modern_treasury.counterparties.collect_account(
279
+ direction: :credit,
280
280
  # …
281
281
  )
282
282
  ```
@@ -40,6 +40,9 @@ module ModernTreasury
40
40
  # @return [Integer, nil]
41
41
  attr_accessor :status
42
42
 
43
+ # @return [Hash{String=>String}, nil]
44
+ attr_accessor :headers
45
+
43
46
  # @return [Object, nil]
44
47
  attr_accessor :body
45
48
 
@@ -47,13 +50,15 @@ module ModernTreasury
47
50
  #
48
51
  # @param url [URI::Generic]
49
52
  # @param status [Integer, nil]
53
+ # @param headers [Hash{String=>String}, nil]
50
54
  # @param body [Object, nil]
51
55
  # @param request [nil]
52
56
  # @param response [nil]
53
57
  # @param message [String, nil]
54
- def initialize(url:, status: nil, body: nil, request: nil, response: nil, message: nil)
58
+ def initialize(url:, status: nil, headers: nil, body: nil, request: nil, response: nil, message: nil)
55
59
  @url = url
56
60
  @status = status
61
+ @headers = headers
57
62
  @body = body
58
63
  @request = request
59
64
  @response = response
@@ -74,6 +79,7 @@ module ModernTreasury
74
79
  #
75
80
  # @param url [URI::Generic]
76
81
  # @param status [nil]
82
+ # @param headers [Hash{String=>String}, nil]
77
83
  # @param body [nil]
78
84
  # @param request [nil]
79
85
  # @param response [nil]
@@ -81,6 +87,7 @@ module ModernTreasury
81
87
  def initialize(
82
88
  url:,
83
89
  status: nil,
90
+ headers: nil,
84
91
  body: nil,
85
92
  request: nil,
86
93
  response: nil,
@@ -95,6 +102,7 @@ module ModernTreasury
95
102
  #
96
103
  # @param url [URI::Generic]
97
104
  # @param status [nil]
105
+ # @param headers [Hash{String=>String}, nil]
98
106
  # @param body [nil]
99
107
  # @param request [nil]
100
108
  # @param response [nil]
@@ -102,6 +110,7 @@ module ModernTreasury
102
110
  def initialize(
103
111
  url:,
104
112
  status: nil,
113
+ headers: nil,
105
114
  body: nil,
106
115
  request: nil,
107
116
  response: nil,
@@ -116,21 +125,24 @@ module ModernTreasury
116
125
  #
117
126
  # @param url [URI::Generic]
118
127
  # @param status [Integer]
128
+ # @param headers [Hash{String=>String}, nil]
119
129
  # @param body [Object, nil]
120
130
  # @param request [nil]
121
131
  # @param response [nil]
122
132
  # @param message [String, nil]
123
133
  #
124
134
  # @return [self]
125
- def self.for(url:, status:, body:, request:, response:, message: nil)
126
- kwargs = {
127
- url: url,
128
- status: status,
129
- body: body,
130
- request: request,
131
- response: response,
132
- message: message
133
- }
135
+ def self.for(url:, status:, headers:, body:, request:, response:, message: nil)
136
+ kwargs =
137
+ {
138
+ url: url,
139
+ status: status,
140
+ headers: headers,
141
+ body: body,
142
+ request: request,
143
+ response: response,
144
+ message: message
145
+ }
134
146
 
135
147
  case status
136
148
  in 400
@@ -162,15 +174,17 @@ module ModernTreasury
162
174
  #
163
175
  # @param url [URI::Generic]
164
176
  # @param status [Integer]
177
+ # @param headers [Hash{String=>String}, nil]
165
178
  # @param body [Object, nil]
166
179
  # @param request [nil]
167
180
  # @param response [nil]
168
181
  # @param message [String, nil]
169
- def initialize(url:, status:, body:, request:, response:, message: nil)
182
+ def initialize(url:, status:, headers:, body:, request:, response:, message: nil)
170
183
  message ||= {url: url.to_s, status: status, body: body}
171
184
  super(
172
185
  url: url,
173
186
  status: status,
187
+ headers: headers,
174
188
  body: body,
175
189
  request: request,
176
190
  response: response,
@@ -38,18 +38,21 @@ module ModernTreasury
38
38
  def to_yaml(*a) = read.to_yaml(*a)
39
39
 
40
40
  # @param content [Pathname, StringIO, IO, String]
41
- # @param filename [String, nil]
41
+ # @param filename [Pathname, String, nil]
42
42
  # @param content_type [String, nil]
43
43
  def initialize(content, filename: nil, content_type: nil)
44
- @content = content
44
+ @content_type = content_type
45
45
  @filename =
46
- case content
47
- in Pathname
48
- filename.nil? ? content.basename.to_path : ::File.basename(filename)
46
+ case [filename, (@content = content)]
47
+ in [String | Pathname, _]
48
+ ::File.basename(filename)
49
+ in [nil, Pathname]
50
+ content.basename.to_path
51
+ in [nil, IO]
52
+ content.to_path
49
53
  else
50
- filename.nil? ? nil : ::File.basename(filename)
54
+ filename
51
55
  end
52
- @content_type = content_type
53
56
  end
54
57
  end
55
58
  end
@@ -60,7 +60,7 @@ module ModernTreasury
60
60
  #
61
61
  # @param client [ModernTreasury::Internal::Transport::BaseClient]
62
62
  # @param req [Hash{Symbol=>Object}]
63
- # @param headers [Hash{String=>String}, Net::HTTPHeader]
63
+ # @param headers [Hash{String=>String}]
64
64
  # @param page_data [Hash{Symbol=>Object}]
65
65
  def initialize(client:, req:, headers:, page_data:)
66
66
  super
@@ -71,8 +71,8 @@ module ModernTreasury
71
71
  else
72
72
  end
73
73
 
74
- @per_page = ModernTreasury::Internal::Util.coerce_integer(headers["X-Per-Page"])
75
- @after_cursor = headers["X-After-Cursor"]&.to_s
74
+ @per_page = ModernTreasury::Internal::Util.coerce_integer(headers["x-per-page"])
75
+ @after_cursor = headers["x-after-cursor"]&.to_s
76
76
  end
77
77
 
78
78
  # @api private
@@ -47,7 +47,7 @@ module ModernTreasury
47
47
  # @api private
48
48
  #
49
49
  # @param status [Integer]
50
- # @param headers [Hash{String=>String}, Net::HTTPHeader]
50
+ # @param headers [Hash{String=>String}]
51
51
  #
52
52
  # @return [Boolean]
53
53
  def should_retry?(status, headers:)
@@ -85,7 +85,7 @@ module ModernTreasury
85
85
  #
86
86
  # @param status [Integer]
87
87
  #
88
- # @param response_headers [Hash{String=>String}, Net::HTTPHeader]
88
+ # @param response_headers [Hash{String=>String}]
89
89
  #
90
90
  # @return [Hash{Symbol=>Object}]
91
91
  def follow_redirect(request, status:, response_headers:)
@@ -378,6 +378,7 @@ module ModernTreasury
378
378
  rescue ModernTreasury::Errors::APIConnectionError => e
379
379
  status = e
380
380
  end
381
+ headers = ModernTreasury::Internal::Util.normalized_headers(response&.each_header&.to_h)
381
382
 
382
383
  case status
383
384
  in ..299
@@ -394,7 +395,7 @@ module ModernTreasury
394
395
  in 300..399
395
396
  self.class.reap_connection!(status, stream: stream)
396
397
 
397
- request = self.class.follow_redirect(request, status: status, response_headers: response)
398
+ request = self.class.follow_redirect(request, status: status, response_headers: headers)
398
399
  send_request(
399
400
  request,
400
401
  redirect_count: redirect_count + 1,
@@ -403,9 +404,9 @@ module ModernTreasury
403
404
  )
404
405
  in ModernTreasury::Errors::APIConnectionError if retry_count >= max_retries
405
406
  raise status
406
- in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers: response)
407
+ in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers: headers)
407
408
  decoded = Kernel.then do
408
- ModernTreasury::Internal::Util.decode_content(response, stream: stream, suppress_error: true)
409
+ ModernTreasury::Internal::Util.decode_content(headers, stream: stream, suppress_error: true)
409
410
  ensure
410
411
  self.class.reap_connection!(status, stream: stream)
411
412
  end
@@ -413,6 +414,7 @@ module ModernTreasury
413
414
  raise ModernTreasury::Errors::APIStatusError.for(
414
415
  url: url,
415
416
  status: status,
417
+ headers: headers,
416
418
  body: decoded,
417
419
  request: nil,
418
420
  response: response
@@ -489,19 +491,21 @@ module ModernTreasury
489
491
  send_retry_header: send_retry_header
490
492
  )
491
493
 
492
- decoded = ModernTreasury::Internal::Util.decode_content(response, stream: stream)
494
+ headers = ModernTreasury::Internal::Util.normalized_headers(response.each_header.to_h)
495
+ decoded = ModernTreasury::Internal::Util.decode_content(headers, stream: stream)
493
496
  case req
494
497
  in {stream: Class => st}
495
498
  st.new(
496
499
  model: model,
497
500
  url: url,
498
501
  status: status,
502
+ headers: headers,
499
503
  response: response,
500
504
  unwrap: unwrap,
501
505
  stream: decoded
502
506
  )
503
507
  in {page: Class => page}
504
- page.new(client: self, req: req, headers: response, page_data: decoded)
508
+ page.new(client: self, req: req, headers: headers, page_data: decoded)
505
509
  else
506
510
  unwrapped = ModernTreasury::Internal::Util.dig(decoded, unwrap)
507
511
  ModernTreasury::Internal::Type::Converter.coerce(model, unwrapped)
@@ -134,9 +134,9 @@ module ModernTreasury
134
134
 
135
135
  # rubocop:disable Metrics/BlockLength
136
136
  enum = Enumerator.new do |y|
137
- with_pool(url, deadline: deadline) do |conn|
138
- next if finished
137
+ next if finished
139
138
 
139
+ with_pool(url, deadline: deadline) do |conn|
140
140
  req, closing = self.class.build_request(request) do
141
141
  self.class.calibrate_socket_timeout(conn, deadline)
142
142
  end
@@ -149,7 +149,7 @@ module ModernTreasury
149
149
 
150
150
  self.class.calibrate_socket_timeout(conn, deadline)
151
151
  conn.request(req) do |rsp|
152
- y << [conn, req, rsp]
152
+ y << [req, rsp]
153
153
  break if finished
154
154
 
155
155
  rsp.read_body do |bytes|
@@ -160,6 +160,8 @@ module ModernTreasury
160
160
  end
161
161
  eof = true
162
162
  end
163
+ ensure
164
+ conn.finish if !eof && conn&.started?
163
165
  end
164
166
  rescue Timeout::Error
165
167
  raise ModernTreasury::Errors::APITimeoutError.new(url: url, request: req)
@@ -168,16 +170,11 @@ module ModernTreasury
168
170
  end
169
171
  # rubocop:enable Metrics/BlockLength
170
172
 
171
- conn, _, response = enum.next
173
+ _, response = enum.next
172
174
  body = ModernTreasury::Internal::Util.fused_enum(enum, external: true) do
173
175
  finished = true
174
- tap do
175
- enum.next
176
- rescue StopIteration
177
- nil
178
- end
176
+ loop { enum.next }
179
177
  ensure
180
- conn.finish if !eof && conn&.started?
181
178
  closing&.call
182
179
  end
183
180
  [Integer(response.code), response, body]
@@ -39,7 +39,7 @@ module ModernTreasury
39
39
  #
40
40
  # @param client [ModernTreasury::Internal::Transport::BaseClient]
41
41
  # @param req [Hash{Symbol=>Object}]
42
- # @param headers [Hash{String=>String}, Net::HTTPHeader]
42
+ # @param headers [Hash{String=>String}]
43
43
  # @param page_data [Object]
44
44
  def initialize(client:, req:, headers:, page_data:)
45
45
  @client = client
@@ -82,17 +82,20 @@ module ModernTreasury
82
82
  #
83
83
  # @return [Pathname, StringIO, IO, String, Object]
84
84
  def dump(value, state:)
85
- # rubocop:disable Lint/DuplicateBranch
86
85
  case value
86
+ in StringIO | String
87
+ # https://datatracker.ietf.org/doc/html/rfc7578#section-4.2
88
+ # while not required, a filename is recommended, and in practice many servers do expect this
89
+ ModernTreasury::FilePart.new(value, filename: "upload")
87
90
  in IO
88
91
  state[:can_retry] = false
92
+ value.to_path.nil? ? ModernTreasury::FilePart.new(value, filename: "upload") : value
89
93
  in ModernTreasury::FilePart if value.content.is_a?(IO)
90
94
  state[:can_retry] = false
95
+ value
91
96
  else
97
+ value
92
98
  end
93
- # rubocop:enable Lint/DuplicateBranch
94
-
95
- value
96
99
  end
97
100
 
98
101
  # @api private
@@ -473,10 +473,9 @@ module ModernTreasury
473
473
  # @return [Enumerable<String>]
474
474
  def writable_enum(&blk)
475
475
  Enumerator.new do |y|
476
- buf = String.new
477
476
  y.define_singleton_method(:write) do
478
- self << buf.replace(_1)
479
- buf.bytesize
477
+ self << _1.dup
478
+ _1.bytesize
480
479
  end
481
480
 
482
481
  blk.call(y)
@@ -566,7 +565,8 @@ module ModernTreasury
566
565
  #
567
566
  # @return [Array(String, Enumerable<String>)]
568
567
  private def encode_multipart_streaming(body)
569
- boundary = SecureRandom.urlsafe_base64(60)
568
+ # RFC 1521 Section 7.2.1 says we should have 70 char maximum for boundary length
569
+ boundary = SecureRandom.urlsafe_base64(46)
570
570
 
571
571
  closing = []
572
572
  strio = writable_enum do |y|
@@ -647,7 +647,7 @@ module ModernTreasury
647
647
  #
648
648
  # Assumes each chunk in stream has `Encoding::BINARY`.
649
649
  #
650
- # @param headers [Hash{String=>String}, Net::HTTPHeader]
650
+ # @param headers [Hash{String=>String}]
651
651
  # @param stream [Enumerable<String>]
652
652
  # @param suppress_error [Boolean]
653
653
  #
@@ -314,6 +314,13 @@ module ModernTreasury
314
314
  # @return [String, nil]
315
315
  optional :receiving_account_id, String
316
316
 
317
+ # @!attribute reconciliation_status
318
+ # One of `unreconciled`, `tentatively_reconciled` or `reconciled`.
319
+ #
320
+ # @return [Symbol, ModernTreasury::Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::ReconciliationStatus, nil]
321
+ optional :reconciliation_status,
322
+ enum: -> { ModernTreasury::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::ReconciliationStatus }
323
+
317
324
  # @!attribute remittance_information
318
325
  # For `ach`, this field will be passed through on an addenda record. For `wire`
319
326
  # payments the field will be passed through as the "Originator to Beneficiary
@@ -380,7 +387,7 @@ module ModernTreasury
380
387
  # @return [String, nil]
381
388
  optional :ultimate_receiving_party_name, String, nil?: true
382
389
 
383
- # @!method initialize(amount:, direction:, originating_account_id:, type:, accounting: nil, accounting_category_id: nil, accounting_ledger_class_id: nil, charge_bearer: nil, currency: nil, description: nil, effective_date: nil, expires_at: nil, fallback_type: nil, foreign_exchange_contract: nil, foreign_exchange_indicator: nil, ledger_transaction: nil, ledger_transaction_id: nil, line_items: nil, metadata: nil, nsf_protected: nil, originating_party_name: nil, priority: nil, process_after: nil, purpose: nil, receiving_account: nil, receiving_account_id: nil, remittance_information: nil, send_remittance_advice: nil, statement_descriptor: nil, subtype: nil, transaction_monitoring_enabled: nil, ultimate_originating_party_identifier: nil, ultimate_originating_party_name: nil, ultimate_receiving_party_identifier: nil, ultimate_receiving_party_name: nil)
390
+ # @!method initialize(amount:, direction:, originating_account_id:, type:, accounting: nil, accounting_category_id: nil, accounting_ledger_class_id: nil, charge_bearer: nil, currency: nil, description: nil, effective_date: nil, expires_at: nil, fallback_type: nil, foreign_exchange_contract: nil, foreign_exchange_indicator: nil, ledger_transaction: nil, ledger_transaction_id: nil, line_items: nil, metadata: nil, nsf_protected: nil, originating_party_name: nil, priority: nil, process_after: nil, purpose: nil, receiving_account: nil, receiving_account_id: nil, reconciliation_status: nil, remittance_information: nil, send_remittance_advice: nil, statement_descriptor: nil, subtype: nil, transaction_monitoring_enabled: nil, ultimate_originating_party_identifier: nil, ultimate_originating_party_name: nil, ultimate_receiving_party_identifier: nil, ultimate_receiving_party_name: nil)
384
391
  # Some parameter documentations has been truncated, see
385
392
  # {ModernTreasury::Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest}
386
393
  # for more details.
@@ -437,6 +444,8 @@ module ModernTreasury
437
444
  #
438
445
  # @param receiving_account_id [String] Either `receiving_account` or `receiving_account_id` must be present. When using
439
446
  #
447
+ # @param reconciliation_status [Symbol, ModernTreasury::Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::ReconciliationStatus] One of `unreconciled`, `tentatively_reconciled` or `reconciled`.
448
+ #
440
449
  # @param remittance_information [String, nil] For `ach`, this field will be passed through on an addenda record. For `wire` pa
441
450
  #
442
451
  # @param send_remittance_advice [Boolean, nil] Send an email to the counterparty when the payment order is sent to the bank. If
@@ -891,6 +900,20 @@ module ModernTreasury
891
900
  end
892
901
  end
893
902
  end
903
+
904
+ # One of `unreconciled`, `tentatively_reconciled` or `reconciled`.
905
+ #
906
+ # @see ModernTreasury::Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest#reconciliation_status
907
+ module ReconciliationStatus
908
+ extend ModernTreasury::Internal::Type::Enum
909
+
910
+ UNRECONCILED = :unreconciled
911
+ TENTATIVELY_RECONCILED = :tentatively_reconciled
912
+ RECONCILED = :reconciled
913
+
914
+ # @!method self.values
915
+ # @return [Array<Symbol>]
916
+ end
894
917
  end
895
918
 
896
919
  class ExpectedPaymentCreateRequest < ModernTreasury::Internal::Type::BaseModel
@@ -1503,6 +1526,13 @@ module ModernTreasury
1503
1526
  # @return [String, nil]
1504
1527
  optional :receiving_account_id, String
1505
1528
 
1529
+ # @!attribute reconciliation_status
1530
+ # One of `unreconciled`, `tentatively_reconciled` or `reconciled`.
1531
+ #
1532
+ # @return [Symbol, ModernTreasury::Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::ReconciliationStatus, nil]
1533
+ optional :reconciliation_status,
1534
+ enum: -> { ModernTreasury::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::ReconciliationStatus }
1535
+
1506
1536
  # @!attribute remittance_information
1507
1537
  # For `ach`, this field will be passed through on an addenda record. For `wire`
1508
1538
  # payments the field will be passed through as the "Originator to Beneficiary
@@ -1587,7 +1617,7 @@ module ModernTreasury
1587
1617
  # @return [String, nil]
1588
1618
  optional :ultimate_receiving_party_name, String, nil?: true
1589
1619
 
1590
- # @!method initialize(id: nil, accounting: nil, accounting_category_id: nil, accounting_ledger_class_id: nil, amount: nil, charge_bearer: nil, counterparty_id: nil, currency: nil, description: nil, direction: nil, effective_date: nil, expires_at: nil, fallback_type: nil, foreign_exchange_contract: nil, foreign_exchange_indicator: nil, line_items: nil, metadata: nil, nsf_protected: nil, originating_account_id: nil, originating_party_name: nil, priority: nil, process_after: nil, purpose: nil, receiving_account: nil, receiving_account_id: nil, remittance_information: nil, send_remittance_advice: nil, statement_descriptor: nil, status: nil, subtype: nil, type: nil, ultimate_originating_party_identifier: nil, ultimate_originating_party_name: nil, ultimate_receiving_party_identifier: nil, ultimate_receiving_party_name: nil)
1620
+ # @!method initialize(id: nil, accounting: nil, accounting_category_id: nil, accounting_ledger_class_id: nil, amount: nil, charge_bearer: nil, counterparty_id: nil, currency: nil, description: nil, direction: nil, effective_date: nil, expires_at: nil, fallback_type: nil, foreign_exchange_contract: nil, foreign_exchange_indicator: nil, line_items: nil, metadata: nil, nsf_protected: nil, originating_account_id: nil, originating_party_name: nil, priority: nil, process_after: nil, purpose: nil, receiving_account: nil, receiving_account_id: nil, reconciliation_status: nil, remittance_information: nil, send_remittance_advice: nil, statement_descriptor: nil, status: nil, subtype: nil, type: nil, ultimate_originating_party_identifier: nil, ultimate_originating_party_name: nil, ultimate_receiving_party_identifier: nil, ultimate_receiving_party_name: nil)
1591
1621
  # Some parameter documentations has been truncated, see
1592
1622
  # {ModernTreasury::Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID}
1593
1623
  # for more details.
@@ -1642,6 +1672,8 @@ module ModernTreasury
1642
1672
  #
1643
1673
  # @param receiving_account_id [String] Either `receiving_account` or `receiving_account_id` must be present. When using
1644
1674
  #
1675
+ # @param reconciliation_status [Symbol, ModernTreasury::Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::ReconciliationStatus] One of `unreconciled`, `tentatively_reconciled` or `reconciled`.
1676
+ #
1645
1677
  # @param remittance_information [String, nil] For `ach`, this field will be passed through on an addenda record. For `wire` pa
1646
1678
  #
1647
1679
  # @param send_remittance_advice [Boolean, nil] Send an email to the counterparty when the payment order is sent to the bank. If
@@ -2099,6 +2131,20 @@ module ModernTreasury
2099
2131
  end
2100
2132
  end
2101
2133
 
2134
+ # One of `unreconciled`, `tentatively_reconciled` or `reconciled`.
2135
+ #
2136
+ # @see ModernTreasury::Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID#reconciliation_status
2137
+ module ReconciliationStatus
2138
+ extend ModernTreasury::Internal::Type::Enum
2139
+
2140
+ UNRECONCILED = :unreconciled
2141
+ TENTATIVELY_RECONCILED = :tentatively_reconciled
2142
+ RECONCILED = :reconciled
2143
+
2144
+ # @!method self.values
2145
+ # @return [Array<Symbol>]
2146
+ end
2147
+
2102
2148
  # To cancel a payment order, use `cancelled`. To redraft a returned payment order,
2103
2149
  # use `approved`. To undo approval on a denied or approved payment order, use
2104
2150
  # `needs_approval`.
@@ -2112,6 +2158,7 @@ module ModernTreasury
2112
2158
  COMPLETED = :completed
2113
2159
  DENIED = :denied
2114
2160
  FAILED = :failed
2161
+ HELD = :held
2115
2162
  NEEDS_APPROVAL = :needs_approval
2116
2163
  PENDING = :pending
2117
2164
  PROCESSING = :processing
@@ -81,10 +81,12 @@ module ModernTreasury
81
81
  required :updated_at, Time
82
82
 
83
83
  # @!attribute verification_status
84
+ # @deprecated
85
+ #
84
86
  # The verification status of the counterparty.
85
87
  #
86
- # @return [Symbol, ModernTreasury::Models::Counterparty::VerificationStatus]
87
- required :verification_status, enum: -> { ModernTreasury::Counterparty::VerificationStatus }
88
+ # @return [String]
89
+ required :verification_status, String
88
90
 
89
91
  # @!method initialize(id:, accounts:, created_at:, discarded_at:, email:, external_id:, legal_entity_id:, live_mode:, metadata:, name:, object:, send_remittance_advice:, updated_at:, verification_status:)
90
92
  # Some parameter documentations has been truncated, see
@@ -116,7 +118,7 @@ module ModernTreasury
116
118
  #
117
119
  # @param updated_at [Time]
118
120
  #
119
- # @param verification_status [Symbol, ModernTreasury::Models::Counterparty::VerificationStatus] The verification status of the counterparty.
121
+ # @param verification_status [String] The verification status of the counterparty.
120
122
 
121
123
  class Account < ModernTreasury::Internal::Type::BaseModel
122
124
  # @!attribute id
@@ -308,21 +310,6 @@ module ModernTreasury
308
310
  # @return [Array<Symbol>]
309
311
  end
310
312
  end
311
-
312
- # The verification status of the counterparty.
313
- #
314
- # @see ModernTreasury::Models::Counterparty#verification_status
315
- module VerificationStatus
316
- extend ModernTreasury::Internal::Type::Enum
317
-
318
- DENIED = :denied
319
- NEEDS_APPROVAL = :needs_approval
320
- UNVERIFIED = :unverified
321
- VERIFIED = :verified
322
-
323
- # @!method self.values
324
- # @return [Array<Symbol>]
325
- end
326
313
  end
327
314
  end
328
315
  end
@@ -79,10 +79,12 @@ module ModernTreasury
79
79
  optional :taxpayer_identifier, String
80
80
 
81
81
  # @!attribute verification_status
82
+ # @deprecated
83
+ #
82
84
  # The verification status of the counterparty.
83
85
  #
84
- # @return [Symbol, ModernTreasury::Models::CounterpartyCreateParams::VerificationStatus, nil]
85
- optional :verification_status, enum: -> { ModernTreasury::CounterpartyCreateParams::VerificationStatus }
86
+ # @return [String, nil]
87
+ optional :verification_status, String
86
88
 
87
89
  # @!method initialize(name:, body_external_id: nil, accounting: nil, accounts: nil, email: nil, ledger_type: nil, legal_entity: nil, legal_entity_id: nil, metadata: nil, send_remittance_advice: nil, taxpayer_identifier: nil, verification_status: nil, request_options: {})
88
90
  # Some parameter documentations has been truncated, see
@@ -110,7 +112,7 @@ module ModernTreasury
110
112
  #
111
113
  # @param taxpayer_identifier [String] Either a valid SSN or EIN.
112
114
  #
113
- # @param verification_status [Symbol, ModernTreasury::Models::CounterpartyCreateParams::VerificationStatus] The verification status of the counterparty.
115
+ # @param verification_status [String] The verification status of the counterparty.
114
116
  #
115
117
  # @param request_options [ModernTreasury::RequestOptions, Hash{Symbol=>Object}]
116
118
 
@@ -764,19 +766,6 @@ module ModernTreasury
764
766
  # @return [Array<Symbol>]
765
767
  end
766
768
  end
767
-
768
- # The verification status of the counterparty.
769
- module VerificationStatus
770
- extend ModernTreasury::Internal::Type::Enum
771
-
772
- DENIED = :denied
773
- NEEDS_APPROVAL = :needs_approval
774
- UNVERIFIED = :unverified
775
- VERIFIED = :verified
776
-
777
- # @!method self.values
778
- # @return [Array<Symbol>]
779
- end
780
769
  end
781
770
  end
782
771
  end