straddle 1.0.4 → 1.1.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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/README.md +84 -89
  4. data/SKILL.md +4 -2
  5. data/api.md +23 -23
  6. data/lib/straddle/client.rb +24 -7
  7. data/lib/straddle/errors.rb +40 -0
  8. data/lib/straddle/file_part.rb +13 -1
  9. data/lib/straddle/internal/transport/base_client.rb +186 -42
  10. data/lib/straddle/internal/transport/connection_pool.rb +160 -0
  11. data/lib/straddle/internal/transport/pooled_net_requester.rb +77 -10
  12. data/lib/straddle/internal/type/base_model.rb +69 -18
  13. data/lib/straddle/internal/type/base_page.rb +14 -0
  14. data/lib/straddle/internal/type/boolean.rb +3 -1
  15. data/lib/straddle/internal/type/converter.rb +13 -3
  16. data/lib/straddle/internal/type/enum.rb +9 -4
  17. data/lib/straddle/internal/type/file_input.rb +8 -2
  18. data/lib/straddle/internal/type/hash_of.rb +3 -1
  19. data/lib/straddle/internal/type/union.rb +21 -7
  20. data/lib/straddle/internal/type/unknown.rb +3 -1
  21. data/lib/straddle/internal/util.rb +273 -15
  22. data/lib/straddle/internal/webhook_verifier.rb +240 -0
  23. data/lib/straddle/internal.rb +5 -1
  24. data/lib/straddle/models/capability_request_create_params.rb +18 -18
  25. data/lib/straddle/models/paykey.rb +3 -2
  26. data/lib/straddle/models/paykey_created_v1_webhook_event.rb +7 -2
  27. data/lib/straddle/models/paykey_event_v1_webhook_event.rb +7 -2
  28. data/lib/straddle/models/webhook_unwrap_params.rb +2 -0
  29. data/lib/straddle/models.rb +30 -31
  30. data/lib/straddle/request_options.rb +13 -5
  31. data/lib/straddle/resources/accounts.rb +11 -12
  32. data/lib/straddle/resources/bridge.rb +8 -4
  33. data/lib/straddle/resources/capability_requests.rb +4 -5
  34. data/lib/straddle/resources/charges.rb +18 -15
  35. data/lib/straddle/resources/customers/review.rb +5 -6
  36. data/lib/straddle/resources/customers.rb +34 -35
  37. data/lib/straddle/resources/funding_events.rb +20 -20
  38. data/lib/straddle/resources/linked_bank_accounts.rb +9 -11
  39. data/lib/straddle/resources/organizations.rb +6 -6
  40. data/lib/straddle/resources/paykeys/review.rb +5 -6
  41. data/lib/straddle/resources/paykeys.rb +34 -39
  42. data/lib/straddle/resources/payments.rb +8 -7
  43. data/lib/straddle/resources/payouts.rb +18 -15
  44. data/lib/straddle/resources/representatives.rb +7 -6
  45. data/lib/straddle/resources/webhooks.rb +63 -6
  46. data/lib/straddle/version.rb +1 -1
  47. data/lib/straddle.rb +5 -6
  48. data/rbi/straddle/client.rbi +13 -0
  49. data/rbi/straddle/errors.rbi +25 -27
  50. data/rbi/straddle/internal/transport/base_client.rbi +45 -54
  51. data/rbi/straddle/internal/transport/connection_pool.rbi +44 -0
  52. data/rbi/straddle/internal/transport/pooled_net_requester.rbi +15 -16
  53. data/rbi/straddle/internal/type/base_model.rbi +24 -38
  54. data/rbi/straddle/internal/type/base_page.rbi +5 -0
  55. data/rbi/straddle/internal/type/converter.rbi +9 -42
  56. data/rbi/straddle/internal/type/enum.rbi +1 -5
  57. data/rbi/straddle/internal/type/request_parameters.rbi +1 -3
  58. data/rbi/straddle/internal/type/union.rbi +2 -11
  59. data/rbi/straddle/internal/util.rbi +101 -115
  60. data/rbi/straddle/internal/webhook_verifier.rbi +86 -0
  61. data/rbi/straddle/internal.rbi +1 -2
  62. data/rbi/straddle/models/capability_request_create_params.rbi +18 -18
  63. data/rbi/straddle/models/paykey.rbi +4 -2
  64. data/rbi/straddle/models/paykey_created_v1_webhook_event.rbi +6 -2
  65. data/rbi/straddle/models/paykey_event_v1_webhook_event.rbi +6 -2
  66. data/rbi/straddle/models/webhook_unwrap_params.rbi +2 -0
  67. data/rbi/straddle/models.rbi +2 -0
  68. data/rbi/straddle/request_options.rbi +4 -10
  69. data/rbi/straddle/resources/accounts.rbi +2 -1
  70. data/rbi/straddle/resources/bridge.rbi +8 -4
  71. data/rbi/straddle/resources/charges.rbi +4 -2
  72. data/rbi/straddle/resources/customers.rbi +7 -3
  73. data/rbi/straddle/resources/funding_events.rbi +5 -2
  74. data/rbi/straddle/resources/organizations.rbi +2 -1
  75. data/rbi/straddle/resources/paykeys.rbi +2 -1
  76. data/rbi/straddle/resources/payments.rbi +3 -1
  77. data/rbi/straddle/resources/payouts.rbi +4 -2
  78. data/rbi/straddle/resources/representatives.rbi +3 -1
  79. data/rbi/straddle/resources/webhooks.rbi +107 -2
  80. data/sig/straddle/client.rbs +4 -0
  81. data/sig/straddle/errors.rbs +13 -0
  82. data/sig/straddle/internal/transport/base_client.rbs +19 -1
  83. data/sig/straddle/internal/transport/connection_pool.rbs +19 -0
  84. data/sig/straddle/internal/transport/pooled_net_requester.rbs +11 -1
  85. data/sig/straddle/internal/type/base_model.rbs +4 -0
  86. data/sig/straddle/internal/type/base_page.rbs +2 -0
  87. data/sig/straddle/internal/util.rbs +29 -1
  88. data/sig/straddle/internal/webhook_verifier.rbs +53 -0
  89. data/sig/straddle/models/capability_request_create_params.rbs +24 -24
  90. data/sig/straddle/models/webhook_unwrap_params.rbs +4 -0
  91. data/sig/straddle/models.rbs +2 -0
  92. data/sig/straddle/resources/webhooks.rbs +59 -1
  93. metadata +12 -60
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0d766e4186d873ec4b23ab0d11899bbb6a6b57f716cb6de6c6a2880cc35634e
4
- data.tar.gz: bb1917c2ac8c584b159c2470d1c8d8deadd9fdcc3dbdc9caa6e1298bacfa2817
3
+ metadata.gz: 49abc41ebdbc39dc0f988c7ec00558822314094a0646e2c95ff1fb2c3b732c6f
4
+ data.tar.gz: de9f810d86c62037878e982e90487c17f78a246986aa80ef247dc85d15f912c3
5
5
  SHA512:
6
- metadata.gz: c0dd3d2076bde96c8a21a9cfbae698617bb5a3b569eaa825d2d563d56b7675ac47c3896d56f4e50fd37650629c0c801fc6638ddec66abe50a8b3b013b76aff9d
7
- data.tar.gz: db128c7886902ae7708cdde578f21f973a2f50ec28d1fdeab4b96065ba82e72ff95c942889215c3517ea0ce91fb2511f23e60e49f589c7e48ba77671acd11586
6
+ metadata.gz: 92016778a4dbedcd3e49ef6c3c417cc58f683023e8cbfa84c530d0118133625f7de48434ccf9953503235517ec9e1a532abfd01f2e7803286018bd1f4d1a4dbf
7
+ data.tar.gz: 49aca88e185a4352e4d9e8e6d4bab696f98034e7b9cd4b99979223d262a7eb6861ac6f81697b3b37b468b8e84a05137023f425f0e384f280ad0dbff7bfadb2a3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.1.0](https://github.com/straddle-build/straddle-ruby/compare/v1.0.4...v1.1.0) (2026-12-01)
4
+
5
+
6
+ ### Features
7
+
8
+ * **api:** add types-classes `(top-level):WebhookParsedParams` ([d37998b](https://github.com/straddle-build/straddle-ruby/commit/d37998b82801525fea56f3c478ba41b19ac5b1e3))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **Client:** [EG-1003] send a valid User-Agent ([f49a1cf](https://github.com/straddle-build/straddle-ruby/commit/f49a1cf57846c7305b22b821667356de6e1d3450))
14
+ * **Client:** [EG-1003] send a valid User-Agent ([9c3d427](https://github.com/straddle-build/straddle-ruby/commit/9c3d427524917bfce8e05d4c58f32c9468f74d23))
15
+
16
+
17
+ ### Chores
18
+
19
+ * temporarily align conflicting files for Scalar 0.47.0 / API 1.0.6 regeneration ([4c4f3bc](https://github.com/straddle-build/straddle-ruby/commit/4c4f3bc705e0e6dc67afc89693f923d4f73480f0))
20
+
21
+
22
+ ### Documentation
23
+
24
+ * refresh Ruby SDK quickstart and examples ([#4](https://github.com/straddle-build/straddle-ruby/issues/4)) ([ea6875a](https://github.com/straddle-build/straddle-ruby/commit/ea6875a7413774b108ad2d092d740b95a8e142d8))
25
+ * restore Ruby README quickstart after 1.0.6 sync ([5e6629b](https://github.com/straddle-build/straddle-ruby/commit/5e6629bbd99e8bb5523c4ac737a15742c0949bdf))
26
+
3
27
  ## [1.0.4](https://github.com/straddle-build/straddle-ruby/compare/v1.0.0...v1.0.4) (2026-09-13)
4
28
 
5
29
 
data/README.md CHANGED
@@ -1,148 +1,143 @@
1
- # Straddle API
1
+ # Straddle Ruby SDK
2
2
 
3
- This library provides convenient access to the Straddle API from Ruby.
3
+ Use Straddle's Pay by Bank and Embed APIs from Ruby. The SDK provides typed models, authentication, retries, and request configuration.
4
4
 
5
- The full API of this library can be found in [api.md](./api.md).
5
+ ## Install
6
6
 
7
- <br />
7
+ Use Ruby 3.2 or later. Add the gem to your application's `Gemfile`:
8
8
 
9
- ## Contents
10
-
11
- - [Installation](#installation)
12
- - [Usage](#usage)
13
- - [API Reference](./api.md)
14
- - [Authentication](#authentication)
15
- - [Errors](#errors)
16
- - [Client Options](#client-options)
17
- - [Request Options](#request-options)
18
- - [Retries and Timeouts](#retries-and-timeouts)
19
- - [Helpers](#helpers)
20
- - [Requirements](#requirements)
21
-
22
- <br />
23
-
24
- ## Installation
9
+ ```ruby
10
+ gem "straddle", "~> 1.1.0" # x-release-please-version
11
+ ```
25
12
 
26
- Add the gem to your application's `Gemfile`:
13
+ Install your bundle:
27
14
 
28
- ```ruby
29
- gem "straddle", "~> 1.0.4" # x-release-please-version
15
+ ```sh
16
+ bundle install
30
17
  ```
31
18
 
32
- Or install it directly:
19
+ For a standalone script, install the gem directly:
33
20
 
34
21
  ```sh
35
22
  gem install straddle
36
23
  ```
37
24
 
38
- <br />
25
+ The RubyGems package is [`straddle`](https://rubygems.org/gems/straddle). Its source lives in `straddle-build/straddle-ruby`.
39
26
 
40
- ## Usage
27
+ ## Make your first request
28
+
29
+ Create a sandbox API key in the [Straddle Dashboard](https://dashboard.straddle.com), then set it in your environment. See [API authentication](https://docs.straddle.com/api-reference/authentication) for the setup steps.
30
+
31
+ ```sh
32
+ export STRADDLE_API_KEY="YOUR_SANDBOX_API_KEY"
33
+ ```
34
+
35
+ Save the following example as `quickstart.rb`. It requests the first page of customers from the sandbox:
41
36
 
42
37
  ```ruby
43
38
  require "straddle"
44
39
 
45
40
  client = Straddle::Client.new(
46
- bearer: ENV["BEARER"], # defaults to the BEARER env var
41
+ bearer: ENV.fetch("STRADDLE_API_KEY"),
42
+ base_url: "https://sandbox.straddle.com"
47
43
  )
48
44
 
49
- response = client.accounts.retrieve("7c9e6679-7425-40de-944b-e07fc1f90ae7")
45
+ page = client.customers.list(page_number: 1, page_size: 10)
46
+ puts "Customers on this page: #{page.data.length}"
47
+ ```
48
+
49
+ For a SaaS platform key, add `straddle_account_id: "YOUR_EMBEDDED_ACCOUNT_ID"` to the `list` arguments before running the example. This selects the embedded account whose customers you want to read. Direct accounts and marketplaces list customers without that header. See [platform account scoping](https://docs.straddle.com/guides/embed/api-headers).
50
50
 
51
- puts response.inspect
51
+ Run the example from your application:
52
+
53
+ ```sh
54
+ bundle exec ruby quickstart.rb
52
55
  ```
53
56
 
54
- The examples in the following sections assume a `client` configured as shown above.
57
+ If you installed the gem directly, use `ruby quickstart.rb`.
55
58
 
56
- See the [API reference](./api.md) for every available operation.
59
+ A successful request prints the number of customers on the page. `Customers on this page: 0` is valid for an empty account. Customer records are in `page.data`; pagination and request metadata are in `page.meta`.
57
60
 
58
- <br />
61
+ The remaining examples use this `client`.
59
62
 
60
- ## Authentication
63
+ ## Configure authentication and environments
61
64
 
62
- Pass credentials to the generated client constructor. Environment variables are read automatically when supported by the target runtime.
65
+ The example passes `STRADDLE_API_KEY` explicitly as `bearer`. If you omit `bearer`, the client reads `BEARER`.
63
66
 
64
- | Option | Type | Default | Description |
65
- | --- | --- | --- | --- |
66
- | `bearer` | `String \| nil` | - | Send the API key as a bearer token in the `Authorization` header. Defaults to BEARER. |
67
+ Set `base_url` explicitly to select an environment. If you omit it, the client reads `STRADDLE_BASE_URL`, then defaults to `https://sandbox.straddle.com`. Production uses `https://production.straddle.com` and a production API key. See [environments](https://docs.straddle.com/api-reference/environments).
67
68
 
68
- Declared schemes:
69
+ ## Read additional pages
69
70
 
70
- - `Bearer` bearer token
71
+ List methods return one response page. Choose the next `page_number` using `page.meta.total_pages`, and keep your filters and account scope the same between requests:
71
72
 
72
- <br />
73
+ ```ruby
74
+ next_page = client.customers.list(page_number: 2, page_size: 10)
75
+ ```
73
76
 
74
- ## Errors
77
+ Models expose response fields as attributes. Methods accept a plain hash or the corresponding parameter model. The gem also includes Sorbet `.rbi` and Steep `.rbs` signatures. See the [method reference](./api.md) for filters and response types.
75
78
 
76
- Non-success responses throw generated API errors. Error objects expose status, headers, response body, and request metadata where the target runtime supports it.
79
+ ## Handle errors
80
+
81
+ Catch `Straddle::Errors::APIError` to inspect the status, headers, and body of a failed request. Connection errors also inherit from this class and have no HTTP status.
77
82
 
78
83
  ```ruby
79
84
  begin
80
- response = client.accounts.retrieve("7c9e6679-7425-40de-944b-e07fc1f90ae7")
81
-
82
- puts response.inspect
85
+ page = client.customers.list(page_size: 10)
83
86
  rescue Straddle::Errors::APIError => error
84
- puts "#{error.status}: #{error.message}"
87
+ warn "#{error.status}: #{error.message}"
85
88
  raise
86
89
  end
87
90
  ```
88
91
 
89
- Documented error statuses: `400`, `401`, `403`, `404`, `422`, `500`.
92
+ For a `401`, check that the key matches the selected environment. For a `403`, check the key's permissions and account scope. See [API errors](https://docs.straddle.com/api-reference/errors) for response details.
90
93
 
91
- <br />
94
+ ## Set retries and timeouts
92
95
 
93
- ## Client Options
96
+ The client retries connection errors, `408`, `409`, `429`, and `5xx` responses twice by default. It uses exponential backoff and honors supported `Retry-After` values. The default timeout is 60 seconds; retries can extend the total request duration.
94
97
 
95
- Configure the generated client by setting any of these options when you create it.
98
+ Set `max_retries` and `timeout` in the constructor, or pass `request_options` for an individual request:
96
99
 
97
100
  ```ruby
98
- require "straddle"
99
-
100
- client = Straddle::Client.new(
101
- timeout: 60.0,
102
- max_retries: 2,
101
+ page = client.customers.list(
102
+ page_size: 10,
103
+ request_options: {max_retries: 0, timeout: 30.0}
103
104
  )
104
105
  ```
105
106
 
106
- | Option | Type | Default | Description |
107
- | --- | --- | --- | --- |
108
- | `bearer` | `String \| nil` | `ENV["BEARER"]` | Send the API key as a bearer token in the `Authorization` header. |
109
- | `webhook_secret` | `String \| nil` | `ENV["STRADDLE_WEBHOOK_SECRET"]` | Secret used to verify incoming webhook signatures. |
110
- | `base_url` | `String \| nil` | `ENV["STRADDLE_BASE_URL"]` | Override the default API base URL. |
111
- | `max_retries` | `Integer` | `2` | Max number of retries to attempt after a failed retryable request. |
112
- | `timeout` | `Float` | `60.0` | Seconds to wait for a response before timing out. |
113
- | `initial_retry_delay` | `Float` | `0.5` | Seconds to wait before the first retry; later retries back off exponentially. |
114
- | `max_retry_delay` | `Float` | `8.0` | Upper bound, in seconds, on the delay between retries. |
115
-
116
- <br />
117
-
118
- ## Request Options
119
-
120
- | Option | Type | Default | Description |
121
- | --- | --- | --- | --- |
122
- | `idempotency_key` | `String` | - | Idempotency key for one request, sent when the SDK configures an idempotency header. |
123
- | `extra_query` | `Hash` | - | Additional query parameters for one request. |
124
- | `extra_headers` | `Hash` | - | Additional headers for one request. |
125
- | `extra_body` | `Hash` | - | Additional body fields for one request. |
126
- | `max_retries` | `Integer` | - | Override retry count for one request. |
127
- | `timeout` | `Float` | - | Override timeout for one request. |
128
-
129
- <br />
107
+ For write operations that accept an idempotency key, pass the operation's `idempotency_key` argument. Reuse that value when retrying the same operation. See [idempotency](https://docs.straddle.com/api-reference/idempotency).
130
108
 
131
- ## Retries and Timeouts
109
+ ## Client and request options
132
110
 
133
- Generated clients support request timeouts and retry temporary failures such as network errors, 408, 409, 429, and 5xx responses. Retry delays honor `Retry-After` headers when present. Tune the retry and timeout client options shown above, or override them per request.
111
+ Set these options in the client constructor.
134
112
 
135
- <br />
113
+ | Option | Purpose | Default |
114
+ | --- | --- | --- |
115
+ | `bearer` | API key | `BEARER` |
116
+ | `base_url` | API base URL | `STRADDLE_BASE_URL`, then sandbox |
117
+ | `webhook_secret` | Secret for webhook signature verification | `STRADDLE_WEBHOOK_SECRET` |
118
+ | `max_retries` | Retry count | `2` |
119
+ | `timeout` | Timeout in seconds | `60.0` |
120
+ | `initial_retry_delay` | Initial retry delay in seconds | `0.5` |
121
+ | `max_retry_delay` | Maximum backoff delay in seconds | `8.0` |
136
122
 
137
- ## Helpers
123
+ Pass these values inside a method's `request_options` hash.
138
124
 
139
- - Every model is a `BaseModel`: pass a plain hash or a model instance, and read decoded values back as attributes.
140
- - The gem ships `rbi/` and `sig/` trees, so Sorbet and Steep type-check calls into the SDK.
125
+ | Option | Purpose |
126
+ | --- | --- |
127
+ | `extra_query` | Add query parameters |
128
+ | `extra_headers` | Add headers |
129
+ | `extra_body` | Add body fields |
130
+ | `max_retries` | Override the retry count |
131
+ | `timeout` | Override the timeout in seconds |
141
132
 
142
- <br />
133
+ ## Reference and support
143
134
 
144
- ## Requirements
135
+ Use the following resources as you build your integration:
145
136
 
146
- - Ruby >= 3.2
137
+ - [SDK method reference](./api.md) and [operation signatures](./reference.md).
138
+ - [Straddle guides](https://docs.straddle.com): payment flows, sandbox testing, and API concepts.
139
+ - [GitHub issues](https://github.com/straddle-build/straddle-ruby/issues): SDK bugs and feature requests.
140
+ - [Local development](./CONTRIBUTING.md) and [versioning](./VERSIONING.md): submit customizations against `scalar-next` so Scalar carries them through regeneration.
141
+ - [Security policy](./SECURITY.md) and [Apache 2.0 license](./LICENSE).
147
142
 
148
- Powered by Scalar.
143
+ Straddle generates this SDK with Scalar and maintains repository customizations through the workflow in `VERSIONING.md`.
data/SKILL.md CHANGED
@@ -12,7 +12,7 @@ Generated Ruby client for Straddle API, published as `straddle`. Use the generat
12
12
  Add the gem to your application's `Gemfile`:
13
13
 
14
14
  ```ruby
15
- gem "straddle", "~> 1.0.4" # x-release-please-version
15
+ gem "straddle", "~> 1.1.0" # x-release-please-version
16
16
  ```
17
17
 
18
18
  Or install it directly:
@@ -62,6 +62,8 @@ begin
62
62
  puts response.inspect
63
63
  rescue Straddle::Errors::APIError => error
64
64
  puts "#{error.status}: #{error.message}"
65
+ puts error.request_id if error.request_id
66
+ puts error.problem_details if error.problem_details
65
67
  raise
66
68
  end
67
69
  ```
@@ -72,5 +74,5 @@ end
72
74
 
73
75
  ## Reference files
74
76
 
75
- - [README.md](./README.md) — full feature tour: client options, request options, retries and timeouts.
77
+ - [README.md](./README.md) — full feature tour: client options, request options, retries and timeouts, webhooks, file uploads, enums, undocumented requests.
76
78
  - [api.md](./api.md) — complete catalogue of every operation with request and response types.
data/api.md CHANGED
@@ -106,7 +106,7 @@ Accounts represent businesses that use Straddle through a platform.
106
106
 
107
107
  ### Get an account
108
108
 
109
- Returns the account with the specified ID.
109
+ Returns the account with the specified `account_id`. Includes the account's status, business profile, capabilities, settings, and access level.
110
110
 
111
111
  | Direction | Type |
112
112
  | --- | --- |
@@ -129,7 +129,7 @@ Updates an account's business profile, metadata, and external ID, then returns t
129
129
  | Response | [`AccountResponse`](././lib/straddle/models/account_response.rb) |
130
130
 
131
131
  ```ruby
132
- response = client.accounts.update("7c9e6679-7425-40de-944b-e07fc1f90ae7", { business_profile: StringIO.new("smoke-test"), external_id: "", metadata: { } })
132
+ response = client.accounts.update("7c9e6679-7425-40de-944b-e07fc1f90ae7", { business_profile: { "name" => "", "website" => "https://example.com" }, external_id: "", metadata: { } })
133
133
 
134
134
  puts response.inspect
135
135
  ```
@@ -144,7 +144,7 @@ Creates a business account in the specified organization and returns the account
144
144
  | Response | [`AccountResponse`](././lib/straddle/models/account_response.rb) |
145
145
 
146
146
  ```ruby
147
- response = client.accounts.create({ access_level: "standard", account_type: "business", business_profile: StringIO.new("smoke-test"), organization_id: "7c9e6679-7425-40de-944b-e07fc1f90ae7", external_id: "", metadata: { } })
147
+ response = client.accounts.create({ access_level: "standard", account_type: "business", business_profile: { "name" => "", "website" => "https://example.com" }, organization_id: "7c9e6679-7425-40de-944b-e07fc1f90ae7", external_id: "", metadata: { } })
148
148
 
149
149
  puts response.inspect
150
150
  ```
@@ -358,7 +358,7 @@ puts response.inspect
358
358
 
359
359
  ### Get an organization
360
360
 
361
- Returns the organization with the specified ID.
361
+ Returns the organization with the specified `organization_id`. Includes the organization's name, `external_id`, metadata, and timestamps.
362
362
 
363
363
  | Direction | Type |
364
364
  | --- | --- |
@@ -422,7 +422,7 @@ puts response.inspect
422
422
 
423
423
  ### Get a representative
424
424
 
425
- Returns the representative with the specified ID.
425
+ Returns the representative with the specified `representative_id`. Includes personal details, verification status, and ownership or control relationship flags.
426
426
 
427
427
  | Direction | Type |
428
428
  | --- | --- |
@@ -456,7 +456,7 @@ Bridge connects customer bank accounts and creates paykeys from supported provid
456
456
 
457
457
  ### Create a paykey from bank account details
458
458
 
459
- Creates a paykey from a routing number, account number, and account type.
459
+ Creates a paykey directly from a customer's `routing_number`, `account_number`, and `account_type`. Returns the new paykey with its status and bank details.
460
460
 
461
461
  | Direction | Type |
462
462
  | --- | --- |
@@ -471,7 +471,7 @@ puts response.inspect
471
471
 
472
472
  ### Create a paykey from a Plaid token
473
473
 
474
- Creates a paykey from a Plaid processor token.
474
+ Creates a paykey from a customer's `plaid_token`. Returns the created paykey with its status, institution name, and bank details.
475
475
 
476
476
  | Direction | Type |
477
477
  | --- | --- |
@@ -486,7 +486,7 @@ puts response.inspect
486
486
 
487
487
  ### Create a Bridge widget session token
488
488
 
489
- Creates a session token for the Bridge widget.
489
+ Creates a `bridge_token` for a customer to initialize the Bridge widget. Use this token to connect bank accounts and create paykeys.
490
490
 
491
491
  | Direction | Type |
492
492
  | --- | --- |
@@ -501,7 +501,7 @@ puts response.inspect
501
501
 
502
502
  ### Create a paykey from a Quiltt token
503
503
 
504
- Creates a paykey from a Quiltt processor token.
504
+ Creates a paykey from a customer's `quiltt_token`. Returns the created paykey with its unmasked `paykey` value, status, and bank details.
505
505
 
506
506
  | Direction | Type |
507
507
  | --- | --- |
@@ -520,7 +520,7 @@ Customers are individuals or businesses that send or receive payments through yo
520
520
 
521
521
  ### Get a customer
522
522
 
523
- Returns a customer by `id`.
523
+ Returns a customer by its unique `id`. Includes the customer's profile, verification status, compliance profile, and metadata.
524
524
 
525
525
  | Direction | Type |
526
526
  | --- | --- |
@@ -535,7 +535,7 @@ puts response.inspect
535
535
 
536
536
  ### Update a customer
537
537
 
538
- Updates an existing customer's profile, status, and metadata.
538
+ Updates an existing customer's profile, status, compliance profile, and metadata. Returns the updated customer record.
539
539
 
540
540
  | Direction | Type |
541
541
  | --- | --- |
@@ -543,7 +543,7 @@ Updates an existing customer's profile, status, and metadata.
543
543
  | Response | [`CustomerResponse`](././lib/straddle/models/customer_response.rb) |
544
544
 
545
545
  ```ruby
546
- response = client.customers.update("7c9e6679-7425-40de-944b-e07fc1f90ae7", { device: { "ip_address" => "192.168.1.1" }, email: "user@example.com", name: "", phone: "", status: "verified", address: { "address1" => "123 Main St", "city" => "Anytown", "state" => "CA", "zip" => "12345" }, compliance_profile: StringIO.new("smoke-test"), external_id: "", metadata: { } })
546
+ response = client.customers.update("7c9e6679-7425-40de-944b-e07fc1f90ae7", { device: { "ip_address" => "192.168.1.1" }, email: "user@example.com", name: "", phone: "", status: "verified", address: { "address1" => "123 Main St", "city" => "Anytown", "state" => "CA", "zip" => "12345" }, compliance_profile: { "ssn" => "123-45-6789", "dob" => "1969-04-20" }, external_id: "", metadata: { } })
547
547
 
548
548
  puts response.inspect
549
549
  ```
@@ -580,7 +580,7 @@ puts response.inspect
580
580
 
581
581
  ### Create a customer
582
582
 
583
- Creates a customer and starts identity, fraud, and risk assessments.
583
+ Creates a customer record and starts identity, fraud, and risk assessments. Returns the created customer with its status, profile details, compliance profile, and configuration.
584
584
 
585
585
  | Direction | Type |
586
586
  | --- | --- |
@@ -588,7 +588,7 @@ Creates a customer and starts identity, fraud, and risk assessments.
588
588
  | Response | [`CustomerResponse`](././lib/straddle/models/customer_response.rb) |
589
589
 
590
590
  ```ruby
591
- response = client.customers.create({ device: { "ip_address" => "192.168.1.1" }, email: "ron.swanson@pawnee.com", name: "Ron Swanson", phone: "+12128675309", type: "individual", address: { "address1" => "123 Main St", "city" => "Anytown", "state" => "CA", "zip" => "12345" }, compliance_profile: StringIO.new("smoke-test"), config: { }, external_id: "customer_123", metadata: { } })
591
+ response = client.customers.create({ device: { "ip_address" => "192.168.1.1" }, email: "ron.swanson@pawnee.com", name: "Ron Swanson", phone: "+12128675309", type: "individual", address: { "address1" => "123 Main St", "city" => "Anytown", "state" => "CA", "zip" => "12345" }, compliance_profile: { "ssn" => "123-45-6789", "dob" => "1969-04-20" }, config: { }, external_id: "customer_123", metadata: { } })
592
592
 
593
593
  puts response.inspect
594
594
  ```
@@ -723,7 +723,7 @@ puts response.inspect
723
723
 
724
724
  ### Cancel a paykey
725
725
 
726
- Cancels a paykey so it cannot be used for new payments.
726
+ Cancels a paykey by `id` so it cannot be used for new payments. Accepts an optional cancellation `reason` and returns the updated paykey.
727
727
 
728
728
  | Direction | Type |
729
729
  | --- | --- |
@@ -821,7 +821,7 @@ Charges debit a customer's bank account through a paykey.
821
821
 
822
822
  ### Get a charge
823
823
 
824
- Returns a charge by its unique identifier.
824
+ Returns a charge by its unique `id`. Includes payment amount, status history, customer and paykey details, funding IDs, and trace IDs.
825
825
 
826
826
  | Direction | Type |
827
827
  | --- | --- |
@@ -911,7 +911,7 @@ puts response.inspect
911
911
 
912
912
  ### Get an unmasked charge
913
913
 
914
- Return a charge with its sensitive fields unmasked.
914
+ Returns a charge by `id` with sensitive fields unmasked, including the full `paykey` value. Includes payment status history, funding IDs, and trace IDs.
915
915
 
916
916
  | Direction | Type |
917
917
  | --- | --- |
@@ -975,7 +975,7 @@ Funding events group charge and payout activity into transfers between Straddle
975
975
 
976
976
  ### List funding events
977
977
 
978
- Returns a paginated list of funding events that match the specified filters.
978
+ Returns a paginated list of funding event summaries matching the specified filters. Supports filtering by direction, event type, status, trace ID, and creation dates.
979
979
 
980
980
  | Direction | Type |
981
981
  | --- | --- |
@@ -983,7 +983,7 @@ Returns a paginated list of funding events that match the specified filters.
983
983
  | Response | [`FundingEventSummaryList`](././lib/straddle/models/funding_event_summary_list.rb) |
984
984
 
985
985
  ```ruby
986
- response = client.funding_events.list({ page_number: 1, page_size: 100, sort_order: "asc" })
986
+ response = client.funding_events.list({ page_number: 1, page_size: 100, sort_by: "id", sort_order: "asc" })
987
987
 
988
988
  puts response.inspect
989
989
  ```
@@ -1020,7 +1020,7 @@ puts response.inspect
1020
1020
 
1021
1021
  ### List funding event payments
1022
1022
 
1023
- Returns a paginated list of payments included in the funding event.
1023
+ Returns a paginated list of payments included in the specified funding event `id`. Includes each payment's type, status, amounts, and trace IDs.
1024
1024
 
1025
1025
  | Direction | Type |
1026
1026
  | --- | --- |
@@ -1039,7 +1039,7 @@ Payments provide a combined view of charges and payouts.
1039
1039
 
1040
1040
  ### List payments
1041
1041
 
1042
- Returns a paged list of charges and payouts that match the filters.
1042
+ Returns a paginated list of charges and payouts matching the specified filters. Supports filtering by payment type, status, customer, paykey, amount range, and dates.
1043
1043
 
1044
1044
  | Direction | Type |
1045
1045
  | --- | --- |
@@ -1058,7 +1058,7 @@ Payouts send money to a customer's bank account through a paykey.
1058
1058
 
1059
1059
  ### Get a payout
1060
1060
 
1061
- Returns a payout by its unique identifier.
1061
+ Returns a payout by its unique `id`. Includes payment amount, status history, customer and paykey details, funding IDs, and trace IDs.
1062
1062
 
1063
1063
  | Direction | Type |
1064
1064
  | --- | --- |
@@ -1148,7 +1148,7 @@ puts response.inspect
1148
1148
 
1149
1149
  ### Get an unmasked payout
1150
1150
 
1151
- Return a payout with its sensitive fields unmasked.
1151
+ Returns a payout by `id` with sensitive fields unmasked, including the full `paykey` value. Includes payment status history, funding IDs, and trace IDs.
1152
1152
 
1153
1153
  | Direction | Type |
1154
1154
  | --- | --- |
@@ -23,6 +23,15 @@ module Straddle
23
23
  # @return [String, nil]
24
24
  attr_reader :webhook_secret
25
25
 
26
+ # @api private
27
+ #
28
+ # The `webhook_secret` passed to the constructor, or `nil` when it was left to
29
+ # default to `ENV["STRADDLE_WEBHOOK_SECRET"]`. The webhook helpers read that
30
+ # variable again on every call, so only a value passed here outranks it.
31
+ #
32
+ # @return [String, nil]
33
+ attr_reader :explicit_webhook_secret
34
+
26
35
  # Accounts represent businesses that use Straddle through a platform.
27
36
  # @return [Straddle::Resources::Accounts]
28
37
  attr_reader :accounts
@@ -93,6 +102,11 @@ module Straddle
93
102
  {"authorization" => "Bearer #{@bearer}"}
94
103
  end
95
104
 
105
+ # @api private
106
+ #
107
+ # @return [Array<String>]
108
+ private def auth_header_keys = ["authorization"]
109
+
96
110
  # Creates and returns a new client for interacting with the API.
97
111
  #
98
112
  # @param bearer [String, nil] Send the API key as a bearer token in the `Authorization` header. Defaults to
@@ -113,7 +127,7 @@ module Straddle
113
127
  # @param max_retry_delay [Float]
114
128
  def initialize(
115
129
  bearer: ENV["BEARER"],
116
- webhook_secret: ENV["STRADDLE_WEBHOOK_SECRET"],
130
+ webhook_secret: (webhook_secret_from_env = ENV["STRADDLE_WEBHOOK_SECRET"]),
117
131
  base_url: ENV["STRADDLE_BASE_URL"],
118
132
  max_retries: self.class::DEFAULT_MAX_RETRIES,
119
133
  timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
@@ -122,23 +136,26 @@ module Straddle
122
136
  )
123
137
  base_url ||= "https://sandbox.straddle.com"
124
138
 
125
- raise ArgumentError.new("bearer is required, and can be set via environ: \"BEARER\"") if bearer.nil?
139
+ if bearer.nil?
140
+ raise ArgumentError.new("bearer is required, and can be set via environ: \"BEARER\"")
141
+ end
126
142
 
127
143
  headers = {}
128
144
  custom_headers_env = ENV["STRADDLE_CUSTOM_HEADERS"]
129
145
  unless custom_headers_env.nil?
130
146
  parsed = {}
131
- custom_headers_env
132
- .split("\n")
133
- .each do |line|
134
- colon = line.index(":")
135
- parsed[line[0...colon].strip] = line[(colon + 1)..].strip unless colon.nil?
147
+ custom_headers_env.split("\n").each do |line|
148
+ colon = line.index(":")
149
+ unless colon.nil?
150
+ parsed[line[0...colon].strip] = line[(colon + 1)..].strip
136
151
  end
152
+ end
137
153
  headers = parsed.merge(headers)
138
154
  end
139
155
 
140
156
  @bearer = bearer.to_s
141
157
  @webhook_secret = webhook_secret&.to_s
158
+ @explicit_webhook_secret = webhook_secret_from_env.nil? ? @webhook_secret : nil
142
159
 
143
160
  super(
144
161
  base_url: base_url,
@@ -46,6 +46,28 @@ module Straddle
46
46
  # @return [Object, nil]
47
47
  attr_accessor :body
48
48
 
49
+ # Request identifier exposed by common API response headers, matched case-insensitively.
50
+ # @return [String, nil]
51
+ def request_id
52
+ response_header("x-request-id") || response_header("request-id") ||
53
+ response_header("x-correlation-id")
54
+ end
55
+
56
+ # Parsed RFC 7807 body for application/problem+json responses, preserving extension fields.
57
+ # Non-object bodies and other media types are not treated as Problem Details.
58
+ # @return [Hash{String, Symbol=>Object}, nil]
59
+ def problem_details
60
+ media_type = response_header("content-type").to_s.split(";", 2).first.to_s.strip.downcase
61
+ @body if media_type == "application/problem+json" && @body.is_a?(Hash)
62
+ end
63
+
64
+ # Header maps supplied directly by callers need not use the transport's lowercase spelling.
65
+ # @param name [String]
66
+ # @return [String, nil]
67
+ private def response_header(name)
68
+ @headers&.find { |key, _| key.to_s.downcase == name }&.last
69
+ end
70
+
49
71
  # @api private
50
72
  #
51
73
  # @param url [URI::Generic]
@@ -223,5 +245,23 @@ module Straddle
223
245
  class InternalServerError < Straddle::Errors::APIStatusError
224
246
  HTTP_STATUS = (500..)
225
247
  end
248
+
249
+ # Raised by SDKs that verify webhook signatures through the `standardwebhooks` gem when that gem
250
+ # is not installed. This SDK verifies them with the standard library and never raises it; the
251
+ # class is declared so code that rescues or names it keeps working.
252
+ class MissingDependencyError < Straddle::Errors::Error
253
+ # @api private
254
+ #
255
+ # @param gem_name [String]
256
+ # @param feature [String]
257
+ def initialize(gem_name:, feature:)
258
+ message = [
259
+ "The '#{gem_name}' gem is required to use #{feature}.",
260
+ "Install it with: gem install #{gem_name}",
261
+ "Or add it to your Gemfile: gem '#{gem_name}'"
262
+ ].join("\n")
263
+ super(message)
264
+ end
265
+ end
226
266
  end
227
267
  end
@@ -37,10 +37,22 @@ module Straddle
37
37
  # @return [String]
38
38
  def to_yaml(*a) = read.to_yaml(*a)
39
39
 
40
+ # The filename sent for a part is only ever a basename: an open `File` knows the full local path
41
+ # it was opened from, which is the caller's business and not the server's.
42
+ #
43
+ # The content type is written into the part's headers as given, so one carrying a control
44
+ # character (a CR or LF would start a header line of its own) is refused here, before any request.
45
+ #
40
46
  # @param content [Pathname, StringIO, IO, String]
41
47
  # @param filename [Pathname, String, nil]
42
48
  # @param content_type [String, nil]
49
+ #
50
+ # @raise [ArgumentError] when `content_type` contains a control character
43
51
  def initialize(content, filename: nil, content_type: nil)
52
+ if content_type&.to_s&.match?(/[\x00-\x1F\x7F]/)
53
+ raise ArgumentError.new("The content type #{content_type.inspect} contains a control character.")
54
+ end
55
+
44
56
  @content_type = content_type
45
57
  @filename =
46
58
  case [filename, (@content = content)]
@@ -49,7 +61,7 @@ module Straddle
49
61
  in [nil, Pathname]
50
62
  content.basename.to_path
51
63
  in [nil, IO]
52
- content.to_path
64
+ content.respond_to?(:to_path) ? ::File.basename(content.to_path) : nil
53
65
  else
54
66
  filename
55
67
  end