straddle 0.1.1 → 0.2.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 (193) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -0
  3. data/README.md +2 -2
  4. data/SECURITY.md +1 -1
  5. data/lib/straddle/client.rb +3 -3
  6. data/lib/straddle/errors.rb +25 -11
  7. data/lib/straddle/file_part.rb +10 -7
  8. data/lib/straddle/internal/page_number_schema.rb +1 -1
  9. data/lib/straddle/internal/transport/base_client.rb +12 -8
  10. data/lib/straddle/internal/transport/pooled_net_requester.rb +8 -19
  11. data/lib/straddle/internal/type/array_of.rb +1 -0
  12. data/lib/straddle/internal/type/base_model.rb +4 -9
  13. data/lib/straddle/internal/type/base_page.rb +1 -1
  14. data/lib/straddle/internal/type/converter.rb +27 -0
  15. data/lib/straddle/internal/type/file_input.rb +7 -4
  16. data/lib/straddle/internal/type/hash_of.rb +1 -0
  17. data/lib/straddle/internal/type/union.rb +9 -7
  18. data/lib/straddle/internal/util.rb +4 -3
  19. data/lib/straddle/models/bridge/link_bank_account_params.rb +9 -5
  20. data/lib/straddle/models/bridge/link_create_paykey_params.rb +9 -5
  21. data/lib/straddle/models/bridge/link_create_tan_params.rb +9 -5
  22. data/lib/straddle/models/bridge/link_plaid_params.rb +8 -1
  23. data/lib/straddle/models/bridge_initialize_params.rb +8 -1
  24. data/lib/straddle/models/charge_cancel_params.rb +8 -1
  25. data/lib/straddle/models/charge_create_params.rb +8 -1
  26. data/lib/straddle/models/charge_hold_params.rb +8 -1
  27. data/lib/straddle/models/charge_release_params.rb +8 -1
  28. data/lib/straddle/models/charge_update_params.rb +8 -1
  29. data/lib/straddle/models/customer_create_params.rb +8 -1
  30. data/lib/straddle/models/customer_delete_params.rb +7 -1
  31. data/lib/straddle/models/customer_refresh_review_params.rb +7 -1
  32. data/lib/straddle/models/customer_unmasked_v1.rb +1 -4
  33. data/lib/straddle/models/customer_update_params.rb +8 -1
  34. data/lib/straddle/models/customers/customer_review_v1.rb +15 -50
  35. data/lib/straddle/models/customers/review_decision_params.rb +8 -1
  36. data/lib/straddle/models/embed/account_create_params.rb +8 -1
  37. data/lib/straddle/models/embed/account_onboard_params.rb +7 -1
  38. data/lib/straddle/models/embed/account_paged_v1.rb +3 -12
  39. data/lib/straddle/models/embed/account_simulate_params.rb +7 -1
  40. data/lib/straddle/models/embed/account_update_params.rb +8 -1
  41. data/lib/straddle/models/embed/account_v1.rb +2 -8
  42. data/lib/straddle/models/embed/accounts/capability_request_create_params.rb +8 -1
  43. data/lib/straddle/models/embed/accounts/capability_request_paged_v1.rb +3 -11
  44. data/lib/straddle/models/embed/linked_bank_account_cancel_params.rb +34 -0
  45. data/lib/straddle/models/embed/linked_bank_account_create_params.rb +51 -4
  46. data/lib/straddle/models/embed/linked_bank_account_paged_v1.rb +33 -13
  47. data/lib/straddle/models/embed/linked_bank_account_unmask_v1.rb +3 -8
  48. data/lib/straddle/models/embed/linked_bank_account_update_params.rb +8 -1
  49. data/lib/straddle/models/embed/linked_bank_account_v1.rb +30 -1
  50. data/lib/straddle/models/embed/organization_create_params.rb +8 -1
  51. data/lib/straddle/models/embed/representative.rb +10 -1
  52. data/lib/straddle/models/embed/representative_create_params.rb +17 -1
  53. data/lib/straddle/models/embed/representative_paged.rb +10 -1
  54. data/lib/straddle/models/embed/representative_update_params.rb +17 -1
  55. data/lib/straddle/models/paykey_cancel_params.rb +7 -1
  56. data/lib/straddle/models/paykey_review_params.rb +54 -0
  57. data/lib/straddle/models/payout_cancel_params.rb +8 -1
  58. data/lib/straddle/models/payout_create_params.rb +8 -1
  59. data/lib/straddle/models/payout_hold_params.rb +8 -1
  60. data/lib/straddle/models/payout_release_params.rb +8 -1
  61. data/lib/straddle/models/payout_update_params.rb +8 -1
  62. data/lib/straddle/models.rb +2 -0
  63. data/lib/straddle/resources/bridge/link.rb +16 -4
  64. data/lib/straddle/resources/bridge.rb +4 -1
  65. data/lib/straddle/resources/charges.rb +20 -5
  66. data/lib/straddle/resources/customers/review.rb +4 -1
  67. data/lib/straddle/resources/customers.rb +16 -4
  68. data/lib/straddle/resources/embed/accounts/capability_requests.rb +5 -2
  69. data/lib/straddle/resources/embed/accounts.rb +19 -7
  70. data/lib/straddle/resources/embed/linked_bank_accounts.rb +51 -5
  71. data/lib/straddle/resources/embed/organizations.rb +5 -2
  72. data/lib/straddle/resources/embed/representatives.rb +14 -4
  73. data/lib/straddle/resources/paykeys.rb +47 -1
  74. data/lib/straddle/resources/payouts.rb +20 -5
  75. data/lib/straddle/version.rb +1 -1
  76. data/lib/straddle.rb +2 -0
  77. data/rbi/straddle/client.rbi +4 -4
  78. data/rbi/straddle/errors.rbi +31 -4
  79. data/rbi/straddle/file_part.rbi +1 -1
  80. data/rbi/straddle/internal/transport/base_client.rbi +5 -6
  81. data/rbi/straddle/internal/type/base_page.rbi +1 -1
  82. data/rbi/straddle/internal/type/converter.rbi +54 -0
  83. data/rbi/straddle/internal/type/union.rbi +9 -2
  84. data/rbi/straddle/internal/util.rbi +1 -1
  85. data/rbi/straddle/models/bridge/link_bank_account_params.rbi +9 -0
  86. data/rbi/straddle/models/bridge/link_create_paykey_params.rbi +9 -0
  87. data/rbi/straddle/models/bridge/link_create_tan_params.rbi +9 -0
  88. data/rbi/straddle/models/bridge/link_plaid_params.rbi +9 -0
  89. data/rbi/straddle/models/bridge_initialize_params.rbi +9 -0
  90. data/rbi/straddle/models/charge_cancel_params.rbi +9 -0
  91. data/rbi/straddle/models/charge_create_params.rbi +9 -0
  92. data/rbi/straddle/models/charge_hold_params.rbi +9 -0
  93. data/rbi/straddle/models/charge_release_params.rbi +9 -0
  94. data/rbi/straddle/models/charge_update_params.rbi +9 -0
  95. data/rbi/straddle/models/customer_create_params.rbi +9 -0
  96. data/rbi/straddle/models/customer_delete_params.rbi +9 -0
  97. data/rbi/straddle/models/customer_refresh_review_params.rbi +9 -0
  98. data/rbi/straddle/models/customer_update_params.rbi +9 -0
  99. data/rbi/straddle/models/customers/review_decision_params.rbi +9 -0
  100. data/rbi/straddle/models/embed/account_create_params.rbi +9 -0
  101. data/rbi/straddle/models/embed/account_onboard_params.rbi +9 -0
  102. data/rbi/straddle/models/embed/account_simulate_params.rbi +9 -0
  103. data/rbi/straddle/models/embed/account_update_params.rbi +9 -0
  104. data/rbi/straddle/models/embed/accounts/capability_request_create_params.rbi +9 -0
  105. data/rbi/straddle/models/embed/linked_bank_account_cancel_params.rbi +67 -0
  106. data/rbi/straddle/models/embed/linked_bank_account_create_params.rbi +95 -3
  107. data/rbi/straddle/models/embed/linked_bank_account_paged_v1.rbi +72 -0
  108. data/rbi/straddle/models/embed/linked_bank_account_unmask_v1.rbi +5 -0
  109. data/rbi/straddle/models/embed/linked_bank_account_update_params.rbi +9 -0
  110. data/rbi/straddle/models/embed/linked_bank_account_v1.rbi +72 -0
  111. data/rbi/straddle/models/embed/organization_create_params.rbi +9 -0
  112. data/rbi/straddle/models/embed/representative.rbi +10 -0
  113. data/rbi/straddle/models/embed/representative_create_params.rbi +19 -0
  114. data/rbi/straddle/models/embed/representative_paged.rbi +10 -0
  115. data/rbi/straddle/models/embed/representative_update_params.rbi +19 -0
  116. data/rbi/straddle/models/paykey_cancel_params.rbi +9 -0
  117. data/rbi/straddle/models/paykey_review_params.rbi +98 -0
  118. data/rbi/straddle/models/payout_cancel_params.rbi +9 -0
  119. data/rbi/straddle/models/payout_create_params.rbi +9 -0
  120. data/rbi/straddle/models/payout_hold_params.rbi +9 -0
  121. data/rbi/straddle/models/payout_release_params.rbi +9 -0
  122. data/rbi/straddle/models/payout_update_params.rbi +9 -0
  123. data/rbi/straddle/models.rbi +2 -0
  124. data/rbi/straddle/resources/bridge/link.rbi +12 -0
  125. data/rbi/straddle/resources/bridge.rbi +3 -0
  126. data/rbi/straddle/resources/charges.rbi +15 -0
  127. data/rbi/straddle/resources/customers/review.rbi +3 -0
  128. data/rbi/straddle/resources/customers.rbi +12 -0
  129. data/rbi/straddle/resources/embed/accounts/capability_requests.rbi +3 -0
  130. data/rbi/straddle/resources/embed/accounts.rbi +12 -0
  131. data/rbi/straddle/resources/embed/linked_bank_accounts.rbi +46 -1
  132. data/rbi/straddle/resources/embed/organizations.rbi +3 -0
  133. data/rbi/straddle/resources/embed/representatives.rbi +14 -0
  134. data/rbi/straddle/resources/paykeys.rbi +34 -0
  135. data/rbi/straddle/resources/payouts.rbi +15 -0
  136. data/sig/straddle/client.rbs +2 -2
  137. data/sig/straddle/errors.rbs +7 -0
  138. data/sig/straddle/file_part.rbs +1 -1
  139. data/sig/straddle/internal/transport/base_client.rbs +1 -1
  140. data/sig/straddle/internal/type/converter.rbs +17 -0
  141. data/sig/straddle/internal/type/union.rbs +2 -2
  142. data/sig/straddle/models/bridge/link_bank_account_params.rbs +7 -0
  143. data/sig/straddle/models/bridge/link_create_paykey_params.rbs +7 -0
  144. data/sig/straddle/models/bridge/link_create_tan_params.rbs +7 -0
  145. data/sig/straddle/models/bridge/link_plaid_params.rbs +7 -0
  146. data/sig/straddle/models/bridge_initialize_params.rbs +7 -0
  147. data/sig/straddle/models/charge_cancel_params.rbs +7 -0
  148. data/sig/straddle/models/charge_create_params.rbs +7 -0
  149. data/sig/straddle/models/charge_hold_params.rbs +7 -0
  150. data/sig/straddle/models/charge_release_params.rbs +7 -0
  151. data/sig/straddle/models/charge_update_params.rbs +7 -0
  152. data/sig/straddle/models/customer_create_params.rbs +7 -0
  153. data/sig/straddle/models/customer_delete_params.rbs +7 -0
  154. data/sig/straddle/models/customer_refresh_review_params.rbs +7 -0
  155. data/sig/straddle/models/customer_update_params.rbs +7 -0
  156. data/sig/straddle/models/customers/review_decision_params.rbs +7 -0
  157. data/sig/straddle/models/embed/account_create_params.rbs +7 -0
  158. data/sig/straddle/models/embed/account_onboard_params.rbs +7 -0
  159. data/sig/straddle/models/embed/account_simulate_params.rbs +7 -0
  160. data/sig/straddle/models/embed/account_update_params.rbs +7 -0
  161. data/sig/straddle/models/embed/accounts/capability_request_create_params.rbs +7 -0
  162. data/sig/straddle/models/embed/linked_bank_account_cancel_params.rbs +40 -0
  163. data/sig/straddle/models/embed/linked_bank_account_create_params.rbs +38 -4
  164. data/sig/straddle/models/embed/linked_bank_account_paged_v1.rbs +25 -1
  165. data/sig/straddle/models/embed/linked_bank_account_unmask_v1.rbs +3 -1
  166. data/sig/straddle/models/embed/linked_bank_account_update_params.rbs +7 -0
  167. data/sig/straddle/models/embed/linked_bank_account_v1.rbs +25 -1
  168. data/sig/straddle/models/embed/organization_create_params.rbs +7 -0
  169. data/sig/straddle/models/embed/representative.rbs +5 -0
  170. data/sig/straddle/models/embed/representative_create_params.rbs +12 -0
  171. data/sig/straddle/models/embed/representative_paged.rbs +5 -0
  172. data/sig/straddle/models/embed/representative_update_params.rbs +12 -0
  173. data/sig/straddle/models/paykey_cancel_params.rbs +7 -0
  174. data/sig/straddle/models/paykey_review_params.rbs +65 -0
  175. data/sig/straddle/models/payout_cancel_params.rbs +7 -0
  176. data/sig/straddle/models/payout_create_params.rbs +7 -0
  177. data/sig/straddle/models/payout_hold_params.rbs +7 -0
  178. data/sig/straddle/models/payout_release_params.rbs +7 -0
  179. data/sig/straddle/models/payout_update_params.rbs +7 -0
  180. data/sig/straddle/models.rbs +2 -0
  181. data/sig/straddle/resources/bridge/link.rbs +4 -0
  182. data/sig/straddle/resources/bridge.rbs +1 -0
  183. data/sig/straddle/resources/charges.rbs +5 -0
  184. data/sig/straddle/resources/customers/review.rbs +1 -0
  185. data/sig/straddle/resources/customers.rbs +4 -0
  186. data/sig/straddle/resources/embed/accounts/capability_requests.rbs +1 -0
  187. data/sig/straddle/resources/embed/accounts.rbs +4 -0
  188. data/sig/straddle/resources/embed/linked_bank_accounts.rbs +14 -1
  189. data/sig/straddle/resources/embed/organizations.rbs +1 -0
  190. data/sig/straddle/resources/embed/representatives.rbs +4 -0
  191. data/sig/straddle/resources/paykeys.rbs +11 -0
  192. data/sig/straddle/resources/payouts.rbs +5 -0
  193. metadata +9 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 070d9a859dd569658ee931097b2a5fd7c34ebe7f58bbac87972c170c2af5cd5e
4
- data.tar.gz: be5103223c6a35ed17e6456a17a67c4c084c2dd71b7814ad89682697280881d1
3
+ metadata.gz: bd6a208e41cae35818c5b73da6eea68f300efe8558ca6e148ce0b6564a89a9ea
4
+ data.tar.gz: 8c4db4234dfd2f4991d261c31dfd6cc98baefafb3b42b137858abc054477f128
5
5
  SHA512:
6
- metadata.gz: 66da28451c8bce1bf74dfa3e58e3ff9fb1736cb9d1610307da3083b49b68090328a5cbaaa3642fe479acc27052922116e53a1412de4bec8568a654ecbe82b8c8
7
- data.tar.gz: ebe0b559f5be6ff461a3cfa062d2edb87d8d3b3bed19c21d7e96ed64f54e8a25ce603eec76fcf46b5dcce9a4e7525577e7377ecf1b15b6c9e5b88615cec5297c
6
+ metadata.gz: 1439876ed4778c79dd1088bed876cf236f441c616f4b67e229e1e2854b0535b02a0db5f1fa0ab6190b0ae8e1f268ae8a7d330ef6c3e5c84ae4bc6fdf4707185a
7
+ data.tar.gz: 29c6b8fc541b1a42da83ebbfb372bb6a2fd6aabb6b2803277f11c40fd4c2933afed19e11ecfc87b37590ccd444e031ec58780f95c4d2ed5a1bdfd44b9ef3a55c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0 (2025-10-08)
4
+
5
+ Full Changelog: [v0.1.1...v0.2.0](https://github.com/straddleio/straddle-ruby/compare/v0.1.1...v0.2.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** manual updates ([057927a](https://github.com/straddleio/straddle-ruby/commit/057927a455631a850c4284ebcfbc4f1bfa7dc5eb))
10
+ * **api:** manual updates ([98aa85e](https://github.com/straddleio/straddle-ruby/commit/98aa85e3b01e330403942184fd986af93253640a))
11
+ * **docs:** Preliminary update to SDK Spec ([dc61e54](https://github.com/straddleio/straddle-ruby/commit/dc61e54a7964ace2e73c99c1844e1c8afd3b6d24))
12
+ * **docs:** Preliminary update to SDK Spec ([a2fbd33](https://github.com/straddleio/straddle-ruby/commit/a2fbd33c6636f827e0edd35f26815b32a24296e6))
13
+ * **docs:** Preliminary update to SDK Spec ([0cde0b4](https://github.com/straddleio/straddle-ruby/commit/0cde0b45a6ac30cd2086eb804f43849bffc734dd))
14
+ * **docs:** Preliminary update to SDK Spec ([20b1183](https://github.com/straddleio/straddle-ruby/commit/20b11834366af2928a97030f939a70c706d50469))
15
+ * **docs:** Release Updates to SDK based on Open API Spec (Final) ([9442214](https://github.com/straddleio/straddle-ruby/commit/94422145d27bf6974a7955eb678ec2bc9c0bb4ef))
16
+ * expose response headers for both streams and errors ([a06e5bb](https://github.com/straddleio/straddle-ruby/commit/a06e5bb80cf4d4a49f515d4bff66d6fa11adeae1))
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * always send `filename=...` for multipart requests where a file is expected ([d8dcb1b](https://github.com/straddleio/straddle-ruby/commit/d8dcb1b00300a03983cbd67a72af18020822c5c3))
22
+ * **api:** update default API URLs and metadata ([b23e97e](https://github.com/straddleio/straddle-ruby/commit/b23e97ea5c1b0698df3f7f21735a7e0fcf8b6e5a))
23
+ * bump sorbet version and fix new type errors from the breaking change ([c57c7c9](https://github.com/straddleio/straddle-ruby/commit/c57c7c920a948012f18f8e047eb11f9832ce1cb6))
24
+ * coroutine leaks from connection pool ([f2e61b1](https://github.com/straddleio/straddle-ruby/commit/f2e61b1a8cfc85996d03712b753e306368196203))
25
+ * **internal:** ensure sorbet test always runs serially ([9f7f88a](https://github.com/straddleio/straddle-ruby/commit/9f7f88a59fdc8b2723aec681757d170505561202))
26
+ * shorten multipart boundary sep to less than RFC specificed max length ([ffd8ef5](https://github.com/straddleio/straddle-ruby/commit/ffd8ef5e84376bd3bdbdff9d1b6e2c27083cb2aa))
27
+
28
+
29
+ ### Performance Improvements
30
+
31
+ * faster code formatting ([8e88904](https://github.com/straddleio/straddle-ruby/commit/8e88904d37df47c41da9b68cc8d9933137f648a0))
32
+
33
+
34
+ ### Chores
35
+
36
+ * add json schema comment for rubocop.yml ([0bde048](https://github.com/straddleio/straddle-ruby/commit/0bde0487e0cea64712cf1cac96aba024a16ad5f7))
37
+ * allow fast-format to use bsd sed as well ([95b82e0](https://github.com/straddleio/straddle-ruby/commit/95b82e01dcbfa391aa8d4879f448c574efd39ed2))
38
+ * collect metadata from type DSL ([715a864](https://github.com/straddleio/straddle-ruby/commit/715a864f14ceda15395fb9b9d49f1acc2f338d51))
39
+ * do not install brew dependencies in ./scripts/bootstrap by default ([546b45e](https://github.com/straddleio/straddle-ruby/commit/546b45e0c2a548264407a012fbce0f0197954784))
40
+ * **internal:** codegen related update ([645f5e3](https://github.com/straddleio/straddle-ruby/commit/645f5e3f2d3061c2259c98666745224f04652391))
41
+ * **internal:** increase visibility of internal helper method ([ef8bbee](https://github.com/straddleio/straddle-ruby/commit/ef8bbee699b474dcdb6ea184f35af6c07d4bc0b4))
42
+ * **internal:** update comment in script ([caa575f](https://github.com/straddleio/straddle-ruby/commit/caa575ff8c113eb04eb86d35cdbb559c994cb5f8))
43
+ * update @stainless-api/prism-cli to v5.15.0 ([c881442](https://github.com/straddleio/straddle-ruby/commit/c8814421f86dd430870abc78b29685cca4a7535d))
44
+ * update contribute.md ([1da1122](https://github.com/straddleio/straddle-ruby/commit/1da11228a4e40ad0e4b2a5a750a343f312d5fe16))
45
+
3
46
  ## 0.1.1 (2025-07-08)
4
47
 
5
48
  Full Changelog: [v0.1.0-alpha.1...v0.1.1](https://github.com/straddleio/straddle-ruby/compare/v0.1.0-alpha.1...v0.1.1)
data/README.md CHANGED
@@ -8,7 +8,7 @@ It is generated with [Stainless](https://www.stainless.com/).
8
8
 
9
9
  Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/straddle).
10
10
 
11
- The REST API documentation can be found on [docs.straddle.io](https://docs.straddle.io).
11
+ The REST API documentation can be found on [docs.straddle.com](https://docs.straddle.com).
12
12
 
13
13
  ## Installation
14
14
 
@@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
17
17
  <!-- x-release-please-start-version -->
18
18
 
19
19
  ```ruby
20
- gem "straddle", "~> 0.1.1"
20
+ gem "straddle", "~> 0.2.0"
21
21
  ```
22
22
 
23
23
  <!-- x-release-please-end -->
data/SECURITY.md CHANGED
@@ -20,7 +20,7 @@ or products provided by Straddle, please follow the respective company's securit
20
20
 
21
21
  ### Straddle Terms and Policies
22
22
 
23
- Please contact help@straddle.io for any questions or concerns regarding the security of our services.
23
+ Please contact help@straddle.com for any questions or concerns regarding the security of our services.
24
24
 
25
25
  ---
26
26
 
@@ -17,7 +17,7 @@ module Straddle
17
17
 
18
18
  # rubocop:disable Style/MutableConstant
19
19
  # @type [Hash{Symbol=>String}]
20
- ENVIRONMENTS = {sandbox: "https://sandbox.straddle.io", production: "https://production.straddle.io"}
20
+ ENVIRONMENTS = {sandbox: "https://sandbox.straddle.com", production: "https://production.straddle.com"}
21
21
  # rubocop:enable Style/MutableConstant
22
22
 
23
23
  # Use your Straddle API Key in the Authorization header as Bearer <token> to
@@ -70,8 +70,8 @@ module Straddle
70
70
  #
71
71
  # Each environment maps to a different base URL:
72
72
  #
73
- # - `sandbox` corresponds to `https://sandbox.straddle.io`
74
- # - `production` corresponds to `https://production.straddle.io`
73
+ # - `sandbox` corresponds to `https://sandbox.straddle.com`
74
+ # - `production` corresponds to `https://production.straddle.com`
75
75
  #
76
76
  # @param base_url [String, nil] Override the default base URL for the API, e.g.,
77
77
  # `"https://api.example.com/v2/"`. Defaults to `ENV["STRADDLE_BASE_URL"]`
@@ -40,6 +40,9 @@ module Straddle
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 Straddle
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 Straddle
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 Straddle
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 Straddle
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 Straddle
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 Straddle
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 Straddle
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 Straddle
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
@@ -69,7 +69,7 @@ module Straddle
69
69
  #
70
70
  # @param client [Straddle::Internal::Transport::BaseClient]
71
71
  # @param req [Hash{Symbol=>Object}]
72
- # @param headers [Hash{String=>String}, Net::HTTPHeader]
72
+ # @param headers [Hash{String=>String}]
73
73
  # @param page_data [Hash{Symbol=>Object}]
74
74
  def initialize(client:, req:, headers:, page_data:)
75
75
  super
@@ -47,7 +47,7 @@ module Straddle
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 Straddle
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:)
@@ -365,7 +365,7 @@ module Straddle
365
365
  #
366
366
  # @raise [Straddle::Errors::APIError]
367
367
  # @return [Array(Integer, Net::HTTPResponse, Enumerable<String>)]
368
- private def send_request(request, redirect_count:, retry_count:, send_retry_header:)
368
+ def send_request(request, redirect_count:, retry_count:, send_retry_header:)
369
369
  url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout)
370
370
  input = {**request.except(:timeout), deadline: Straddle::Internal::Util.monotonic_secs + timeout}
371
371
 
@@ -378,6 +378,7 @@ module Straddle
378
378
  rescue Straddle::Errors::APIConnectionError => e
379
379
  status = e
380
380
  end
381
+ headers = Straddle::Internal::Util.normalized_headers(response&.each_header&.to_h)
381
382
 
382
383
  case status
383
384
  in ..299
@@ -390,7 +391,7 @@ module Straddle
390
391
  in 300..399
391
392
  self.class.reap_connection!(status, stream: stream)
392
393
 
393
- request = self.class.follow_redirect(request, status: status, response_headers: response)
394
+ request = self.class.follow_redirect(request, status: status, response_headers: headers)
394
395
  send_request(
395
396
  request,
396
397
  redirect_count: redirect_count + 1,
@@ -399,9 +400,9 @@ module Straddle
399
400
  )
400
401
  in Straddle::Errors::APIConnectionError if retry_count >= max_retries
401
402
  raise status
402
- in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers: response)
403
+ in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers: headers)
403
404
  decoded = Kernel.then do
404
- Straddle::Internal::Util.decode_content(response, stream: stream, suppress_error: true)
405
+ Straddle::Internal::Util.decode_content(headers, stream: stream, suppress_error: true)
405
406
  ensure
406
407
  self.class.reap_connection!(status, stream: stream)
407
408
  end
@@ -409,6 +410,7 @@ module Straddle
409
410
  raise Straddle::Errors::APIStatusError.for(
410
411
  url: url,
411
412
  status: status,
413
+ headers: headers,
412
414
  body: decoded,
413
415
  request: nil,
414
416
  response: response
@@ -485,19 +487,21 @@ module Straddle
485
487
  send_retry_header: send_retry_header
486
488
  )
487
489
 
488
- decoded = Straddle::Internal::Util.decode_content(response, stream: stream)
490
+ headers = Straddle::Internal::Util.normalized_headers(response.each_header.to_h)
491
+ decoded = Straddle::Internal::Util.decode_content(headers, stream: stream)
489
492
  case req
490
493
  in {stream: Class => st}
491
494
  st.new(
492
495
  model: model,
493
496
  url: url,
494
497
  status: status,
498
+ headers: headers,
495
499
  response: response,
496
500
  unwrap: unwrap,
497
501
  stream: decoded
498
502
  )
499
503
  in {page: Class => page}
500
- page.new(client: self, req: req, headers: response, page_data: decoded)
504
+ page.new(client: self, req: req, headers: headers, page_data: decoded)
501
505
  else
502
506
  unwrapped = Straddle::Internal::Util.dig(decoded, unwrap)
503
507
  Straddle::Internal::Type::Converter.coerce(model, unwrapped)
@@ -134,9 +134,9 @@ module Straddle
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 Straddle
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 Straddle
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 Straddle::Errors::APITimeoutError.new(url: url, request: req)
@@ -168,16 +170,11 @@ module Straddle
168
170
  end
169
171
  # rubocop:enable Metrics/BlockLength
170
172
 
171
- conn, _, response = enum.next
173
+ _, response = enum.next
172
174
  body = Straddle::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]
@@ -193,15 +190,7 @@ module Straddle
193
190
  end
194
191
 
195
192
  define_sorbet_constant!(:Request) do
196
- T.type_alias do
197
- {
198
- method: Symbol,
199
- url: URI::Generic,
200
- headers: T::Hash[String, String],
201
- body: T.anything,
202
- deadline: Float
203
- }
204
- end
193
+ T.type_alias { {method: Symbol, url: URI::Generic, headers: T::Hash[String, String], body: T.anything, deadline: Float} }
205
194
  end
206
195
  end
207
196
  end
@@ -148,6 +148,7 @@ module Straddle
148
148
  # @option spec [Boolean] :"nil?"
149
149
  def initialize(type_info, spec = {})
150
150
  @item_type_fn = Straddle::Internal::Type::Converter.type_info(type_info || spec)
151
+ @meta = Straddle::Internal::Type::Converter.meta_info(type_info, spec)
151
152
  @nilable = spec.fetch(:nil?, false)
152
153
  end
153
154
 
@@ -52,6 +52,7 @@ module Straddle
52
52
  #
53
53
  # @option spec [Boolean] :"nil?"
54
54
  private def add_field(name_sym, required:, type_info:, spec:)
55
+ meta = Straddle::Internal::Type::Converter.meta_info(type_info, spec)
55
56
  type_fn, info =
56
57
  case type_info
57
58
  in Proc | Straddle::Internal::Type::Converter | Class
@@ -63,14 +64,7 @@ module Straddle
63
64
  setter = :"#{name_sym}="
64
65
  api_name = info.fetch(:api_name, name_sym)
65
66
  nilable = info.fetch(:nil?, false)
66
- const = if required && !nilable
67
- info.fetch(
68
- :const,
69
- Straddle::Internal::OMIT
70
- )
71
- else
72
- Straddle::Internal::OMIT
73
- end
67
+ const = required && !nilable ? info.fetch(:const, Straddle::Internal::OMIT) : Straddle::Internal::OMIT
74
68
 
75
69
  [name_sym, setter].each { undef_method(_1) } if known_fields.key?(name_sym)
76
70
 
@@ -81,7 +75,8 @@ module Straddle
81
75
  required: required,
82
76
  nilable: nilable,
83
77
  const: const,
84
- type_fn: type_fn
78
+ type_fn: type_fn,
79
+ meta: meta
85
80
  }
86
81
 
87
82
  define_method(setter) do |value|
@@ -39,7 +39,7 @@ module Straddle
39
39
  #
40
40
  # @param client [Straddle::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
@@ -98,6 +98,33 @@ module Straddle
98
98
  end
99
99
  end
100
100
 
101
+ # @api private
102
+ #
103
+ # @param type_info [Hash{Symbol=>Object}, Proc, Straddle::Internal::Type::Converter, Class] .
104
+ #
105
+ # @option type_info [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
106
+ #
107
+ # @option type_info [Proc] :enum
108
+ #
109
+ # @option type_info [Proc] :union
110
+ #
111
+ # @option type_info [Boolean] :"nil?"
112
+ #
113
+ # @param spec [Hash{Symbol=>Object}, Proc, Straddle::Internal::Type::Converter, Class] .
114
+ #
115
+ # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
116
+ #
117
+ # @option spec [Proc] :enum
118
+ #
119
+ # @option spec [Proc] :union
120
+ #
121
+ # @option spec [Boolean] :"nil?"
122
+ #
123
+ # @return [Hash{Symbol=>Object}]
124
+ def meta_info(type_info, spec)
125
+ [spec, type_info].grep(Hash).first.to_h.except(:const, :enum, :union, :nil?)
126
+ end
127
+
101
128
  # @api private
102
129
  #
103
130
  # @param translate_names [Boolean]
@@ -82,17 +82,20 @@ module Straddle
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
+ Straddle::FilePart.new(value, filename: "upload")
87
90
  in IO
88
91
  state[:can_retry] = false
92
+ value.to_path.nil? ? Straddle::FilePart.new(value, filename: "upload") : value
89
93
  in Straddle::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
@@ -168,6 +168,7 @@ module Straddle
168
168
  # @option spec [Boolean] :"nil?"
169
169
  def initialize(type_info, spec = {})
170
170
  @item_type_fn = Straddle::Internal::Type::Converter.type_info(type_info || spec)
171
+ @meta = Straddle::Internal::Type::Converter.meta_info(type_info, spec)
171
172
  @nilable = spec.fetch(:nil?, false)
172
173
  end
173
174
 
@@ -12,20 +12,20 @@ module Straddle
12
12
  #
13
13
  # All of the specified variant info for this union.
14
14
  #
15
- # @return [Array<Array(Symbol, Proc)>]
15
+ # @return [Array<Array(Symbol, Proc, Hash{Symbol=>Object})>]
16
16
  private def known_variants = (@known_variants ||= [])
17
17
 
18
18
  # @api private
19
19
  #
20
- # @return [Array<Array(Symbol, Object)>]
20
+ # @return [Array<Array(Symbol, Object, Hash{Symbol=>Object})>]
21
21
  protected def derefed_variants
22
- known_variants.map { |key, variant_fn| [key, variant_fn.call] }
22
+ known_variants.map { |key, variant_fn, meta| [key, variant_fn.call, meta] }
23
23
  end
24
24
 
25
25
  # All of the specified variants for this union.
26
26
  #
27
27
  # @return [Array<Object>]
28
- def variants = derefed_variants.map(&:last)
28
+ def variants = derefed_variants.map { _2 }
29
29
 
30
30
  # @api private
31
31
  #
@@ -51,12 +51,13 @@ module Straddle
51
51
  #
52
52
  # @option spec [Boolean] :"nil?"
53
53
  private def variant(key, spec = nil)
54
+ meta = Straddle::Internal::Type::Converter.meta_info(nil, spec)
54
55
  variant_info =
55
56
  case key
56
57
  in Symbol
57
- [key, Straddle::Internal::Type::Converter.type_info(spec)]
58
+ [key, Straddle::Internal::Type::Converter.type_info(spec), meta]
58
59
  in Proc | Straddle::Internal::Type::Converter | Class | Hash
59
- [nil, Straddle::Internal::Type::Converter.type_info(key)]
60
+ [nil, Straddle::Internal::Type::Converter.type_info(key), meta]
60
61
  end
61
62
 
62
63
  known_variants << variant_info
@@ -79,7 +80,8 @@ module Straddle
79
80
  return nil if key == Straddle::Internal::OMIT
80
81
 
81
82
  key = key.to_sym if key.is_a?(String)
82
- known_variants.find { |k,| k == key }&.last&.call
83
+ _, found = known_variants.find { |k,| k == key }
84
+ found&.call
83
85
  else
84
86
  nil
85
87
  end
@@ -244,7 +244,7 @@ module Straddle
244
244
  #
245
245
  # @return [String]
246
246
  def uri_origin(uri)
247
- "#{uri.scheme}://#{uri.host}#{uri.port == uri.default_port ? '' : ":#{uri.port}"}"
247
+ "#{uri.scheme}://#{uri.host}#{":#{uri.port}" unless uri.port == uri.default_port}"
248
248
  end
249
249
 
250
250
  # @api private
@@ -566,7 +566,8 @@ module Straddle
566
566
  #
567
567
  # @return [Array(String, Enumerable<String>)]
568
568
  private def encode_multipart_streaming(body)
569
- boundary = SecureRandom.urlsafe_base64(60)
569
+ # RFC 1521 Section 7.2.1 says we should have 70 char maximum for boundary length
570
+ boundary = SecureRandom.urlsafe_base64(46)
570
571
 
571
572
  closing = []
572
573
  strio = writable_enum do |y|
@@ -647,7 +648,7 @@ module Straddle
647
648
  #
648
649
  # Assumes each chunk in stream has `Encoding::BINARY`.
649
650
  #
650
- # @param headers [Hash{String=>String}, Net::HTTPHeader]
651
+ # @param headers [Hash{String=>String}]
651
652
  # @param stream [Enumerable<String>]
652
653
  # @param suppress_error [Boolean]
653
654
  #
@@ -48,6 +48,11 @@ module Straddle
48
48
  # @return [String, nil]
49
49
  optional :correlation_id, String
50
50
 
51
+ # @!attribute idempotency_key
52
+ #
53
+ # @return [String, nil]
54
+ optional :idempotency_key, String
55
+
51
56
  # @!attribute request_id
52
57
  #
53
58
  # @return [String, nil]
@@ -58,7 +63,7 @@ module Straddle
58
63
  # @return [String, nil]
59
64
  optional :straddle_account_id, String
60
65
 
61
- # @!method initialize(account_number:, account_type:, customer_id:, routing_number:, config: nil, metadata: nil, correlation_id: nil, request_id: nil, straddle_account_id: nil, request_options: {})
66
+ # @!method initialize(account_number:, account_type:, customer_id:, routing_number:, config: nil, metadata: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {})
62
67
  # Some parameter documentations has been truncated, see
63
68
  # {Straddle::Models::Bridge::LinkBankAccountParams} for more details.
64
69
  #
@@ -76,6 +81,8 @@ module Straddle
76
81
  #
77
82
  # @param correlation_id [String]
78
83
  #
84
+ # @param idempotency_key [String]
85
+ #
79
86
  # @param request_id [String]
80
87
  #
81
88
  # @param straddle_account_id [String]
@@ -96,10 +103,7 @@ module Straddle
96
103
  # @!attribute sandbox_outcome
97
104
  #
98
105
  # @return [Symbol, Straddle::Models::Bridge::LinkBankAccountParams::Config::SandboxOutcome, nil]
99
- optional :sandbox_outcome,
100
- enum: -> {
101
- Straddle::Bridge::LinkBankAccountParams::Config::SandboxOutcome
102
- }
106
+ optional :sandbox_outcome, enum: -> { Straddle::Bridge::LinkBankAccountParams::Config::SandboxOutcome }
103
107
 
104
108
  # @!method initialize(sandbox_outcome: nil)
105
109
  # @param sandbox_outcome [Symbol, Straddle::Models::Bridge::LinkBankAccountParams::Config::SandboxOutcome]