straddle 1.0.0 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +65 -0
- data/README.md +84 -89
- data/SKILL.md +4 -2
- data/api.md +26 -26
- data/lib/straddle/client.rb +24 -7
- data/lib/straddle/errors.rb +40 -0
- data/lib/straddle/file_part.rb +13 -1
- data/lib/straddle/internal/transport/base_client.rb +186 -42
- data/lib/straddle/internal/transport/connection_pool.rb +160 -0
- data/lib/straddle/internal/transport/pooled_net_requester.rb +77 -10
- data/lib/straddle/internal/type/base_model.rb +69 -18
- data/lib/straddle/internal/type/base_page.rb +14 -0
- data/lib/straddle/internal/type/boolean.rb +3 -1
- data/lib/straddle/internal/type/converter.rb +13 -3
- data/lib/straddle/internal/type/enum.rb +9 -4
- data/lib/straddle/internal/type/file_input.rb +8 -2
- data/lib/straddle/internal/type/hash_of.rb +3 -1
- data/lib/straddle/internal/type/union.rb +21 -7
- data/lib/straddle/internal/type/unknown.rb +3 -1
- data/lib/straddle/internal/util.rb +273 -15
- data/lib/straddle/internal/webhook_verifier.rb +240 -0
- data/lib/straddle/internal.rb +5 -1
- data/lib/straddle/models/capability_request_create_params.rb +18 -18
- data/lib/straddle/models/paykey.rb +3 -2
- data/lib/straddle/models/paykey_created_v1_webhook_event.rb +7 -2
- data/lib/straddle/models/paykey_event_v1_webhook_event.rb +7 -2
- data/lib/straddle/models/payout.rb +14 -14
- data/lib/straddle/models/unmasked_payout.rb +14 -14
- data/lib/straddle/models/webhook_unwrap_params.rb +2 -0
- data/lib/straddle/models.rb +30 -31
- data/lib/straddle/request_options.rb +13 -5
- data/lib/straddle/resources/accounts.rb +11 -12
- data/lib/straddle/resources/bridge.rb +8 -4
- data/lib/straddle/resources/capability_requests.rb +4 -5
- data/lib/straddle/resources/charges.rb +18 -15
- data/lib/straddle/resources/customers/review.rb +5 -6
- data/lib/straddle/resources/customers.rb +34 -35
- data/lib/straddle/resources/funding_events.rb +20 -20
- data/lib/straddle/resources/linked_bank_accounts.rb +9 -11
- data/lib/straddle/resources/organizations.rb +6 -6
- data/lib/straddle/resources/paykeys/review.rb +5 -6
- data/lib/straddle/resources/paykeys.rb +34 -39
- data/lib/straddle/resources/payments.rb +8 -7
- data/lib/straddle/resources/payouts.rb +18 -15
- data/lib/straddle/resources/representatives.rb +7 -6
- data/lib/straddle/resources/webhooks.rb +63 -6
- data/lib/straddle/version.rb +1 -1
- data/lib/straddle.rb +5 -6
- data/rbi/straddle/client.rbi +13 -0
- data/rbi/straddle/errors.rbi +25 -27
- data/rbi/straddle/internal/transport/base_client.rbi +45 -54
- data/rbi/straddle/internal/transport/connection_pool.rbi +44 -0
- data/rbi/straddle/internal/transport/pooled_net_requester.rbi +15 -16
- data/rbi/straddle/internal/type/base_model.rbi +24 -38
- data/rbi/straddle/internal/type/base_page.rbi +5 -0
- data/rbi/straddle/internal/type/converter.rbi +9 -42
- data/rbi/straddle/internal/type/enum.rbi +1 -5
- data/rbi/straddle/internal/type/request_parameters.rbi +1 -3
- data/rbi/straddle/internal/type/union.rbi +2 -11
- data/rbi/straddle/internal/util.rbi +101 -115
- data/rbi/straddle/internal/webhook_verifier.rbi +86 -0
- data/rbi/straddle/internal.rbi +1 -2
- data/rbi/straddle/models/capability_request_create_params.rbi +18 -18
- data/rbi/straddle/models/paykey.rbi +4 -2
- data/rbi/straddle/models/paykey_created_v1_webhook_event.rbi +6 -2
- data/rbi/straddle/models/paykey_event_v1_webhook_event.rbi +6 -2
- data/rbi/straddle/models/payout.rbi +18 -18
- data/rbi/straddle/models/unmasked_payout.rbi +18 -18
- data/rbi/straddle/models/webhook_unwrap_params.rbi +2 -0
- data/rbi/straddle/models.rbi +2 -0
- data/rbi/straddle/request_options.rbi +4 -10
- data/rbi/straddle/resources/accounts.rbi +2 -1
- data/rbi/straddle/resources/bridge.rbi +8 -4
- data/rbi/straddle/resources/charges.rbi +4 -2
- data/rbi/straddle/resources/customers.rbi +7 -3
- data/rbi/straddle/resources/funding_events.rbi +5 -2
- data/rbi/straddle/resources/organizations.rbi +2 -1
- data/rbi/straddle/resources/paykeys.rbi +2 -1
- data/rbi/straddle/resources/payments.rbi +3 -1
- data/rbi/straddle/resources/payouts.rbi +4 -2
- data/rbi/straddle/resources/representatives.rbi +3 -1
- data/rbi/straddle/resources/webhooks.rbi +107 -2
- data/sig/straddle/client.rbs +4 -0
- data/sig/straddle/errors.rbs +13 -0
- data/sig/straddle/internal/transport/base_client.rbs +19 -1
- data/sig/straddle/internal/transport/connection_pool.rbs +19 -0
- data/sig/straddle/internal/transport/pooled_net_requester.rbs +11 -1
- data/sig/straddle/internal/type/base_model.rbs +4 -0
- data/sig/straddle/internal/type/base_page.rbs +2 -0
- data/sig/straddle/internal/util.rbs +29 -1
- data/sig/straddle/internal/webhook_verifier.rbs +53 -0
- data/sig/straddle/models/capability_request_create_params.rbs +24 -24
- data/sig/straddle/models/payout.rbs +12 -12
- data/sig/straddle/models/unmasked_payout.rbs +12 -12
- data/sig/straddle/models/webhook_unwrap_params.rbs +4 -0
- data/sig/straddle/models.rbs +2 -0
- data/sig/straddle/resources/webhooks.rbs +59 -1
- metadata +12 -60
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# The two error classes the `standardwebhooks` gem raised verification failures as, declared with the
|
|
4
|
+
# gem's own hierarchy so that whichever of the gem and this file loads second reopens them instead of
|
|
5
|
+
# conflicting. They come first because this SDK's verification error subclasses the second one, so code
|
|
6
|
+
# written against the gem (`rescue StandardWebhooks::WebhookVerificationError`, `is_a?`, `rescue_from`)
|
|
7
|
+
# keeps catching it whether or not the gem is installed.
|
|
8
|
+
module StandardWebhooks
|
|
9
|
+
class StandardWebhooksError < StandardError
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class WebhookVerificationError < StandardWebhooksError
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
module Straddle
|
|
17
|
+
module Errors
|
|
18
|
+
# Raised when a webhook delivery fails signature verification: a required header is missing, the
|
|
19
|
+
# timestamp is unreadable or outside the tolerance, no signature matches, or the helper is signed
|
|
20
|
+
# with an algorithm this SDK cannot verify, which refuses every delivery.
|
|
21
|
+
#
|
|
22
|
+
# A `StandardWebhooks::WebhookVerificationError`, as the `standardwebhooks` gem's own failures
|
|
23
|
+
# were, and deliberately not an `Errors::Error`: a handler rescuing this SDK's API errors is not
|
|
24
|
+
# meant to swallow a forged or stale delivery.
|
|
25
|
+
class WebhookVerificationError < ::StandardWebhooks::WebhookVerificationError
|
|
26
|
+
# @param message [String, nil]
|
|
27
|
+
def initialize(message = nil)
|
|
28
|
+
super
|
|
29
|
+
# The gem's `StandardWebhooksError#initialize` keeps the message in `@message` without calling
|
|
30
|
+
# `Exception#initialize`, so with the gem loaded `to_s`, `inspect` and string interpolation
|
|
31
|
+
# would report the class name instead. Setting it here keeps the message either way.
|
|
32
|
+
::Exception.instance_method(:initialize).bind_call(self, message)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
module Internal
|
|
38
|
+
# @api private
|
|
39
|
+
#
|
|
40
|
+
# Verifies Standard Webhooks signatures with the standard library alone: an HMAC (SHA-256 unless
|
|
41
|
+
# the helper's scheme names SHA-1 or SHA-512) over `"<id>.<timestamp>.<payload>"`, keyed with the
|
|
42
|
+
# base64-decoded secret, which the `webhook-signature` header carries as one or more
|
|
43
|
+
# space-separated `v1,<base64>` entries. The header names and the replay window come from the
|
|
44
|
+
# helper's scheme too; each generated helper passes the ones it differs from the defaults in.
|
|
45
|
+
#
|
|
46
|
+
# @see https://github.com/standard-webhooks/standard-webhooks/blob/main/spec/standard-webhooks.md
|
|
47
|
+
module WebhookVerifier
|
|
48
|
+
# Prefix the Standard Webhooks dashboards put on a signing secret; it is not part of the key.
|
|
49
|
+
SECRET_PREFIX = "whsec_"
|
|
50
|
+
|
|
51
|
+
# How far, in seconds, the `webhook-timestamp` may sit from now in either direction. The
|
|
52
|
+
# signature covers the timestamp, so this bounds how long a captured delivery can be replayed;
|
|
53
|
+
# the future side allows for a sender whose clock runs ahead.
|
|
54
|
+
TOLERANCE_SECONDS = 5 * 60
|
|
55
|
+
|
|
56
|
+
# The scheme a helper verifies with when it names none: Standard Webhooks' HMAC-SHA256.
|
|
57
|
+
DEFAULT_ALGORITHM = "hmac-sha256"
|
|
58
|
+
|
|
59
|
+
# The `OpenSSL::Digest` each HMAC scheme a config can name is computed with. A scheme missing
|
|
60
|
+
# here (`ed25519`, `rsa-sha256`) is one this runtime cannot check, and `verify!` refuses every
|
|
61
|
+
# delivery for it rather than accepting one unchecked.
|
|
62
|
+
HMAC_DIGESTS = {"hmac-sha1" => "SHA1", "hmac-sha256" => "SHA256", "hmac-sha512" => "SHA512"}.freeze
|
|
63
|
+
|
|
64
|
+
class << self
|
|
65
|
+
# @api private
|
|
66
|
+
#
|
|
67
|
+
# @param payload [String] the raw request body, exactly as received
|
|
68
|
+
# @param headers [Hash{String, Symbol=>String, Array<String>}] names match in any case; see
|
|
69
|
+
# {header_value}
|
|
70
|
+
# @param secret [String] the signing secret, with or without the `whsec_` prefix
|
|
71
|
+
# @param algorithm [String] the helper's configured scheme, as config spells it (`hmac-sha512`)
|
|
72
|
+
# @param id_header [String] the lowercase name of the header carrying the message id
|
|
73
|
+
# @param timestamp_header [String] the lowercase name of the header carrying the timestamp
|
|
74
|
+
# @param signature_header [String] the lowercase name of the header carrying the signatures
|
|
75
|
+
# @param tolerance [Integer] how far, in seconds, the timestamp may sit from now either way
|
|
76
|
+
# @param decoder [String, nil] the helper's decode-only method, named in the error an
|
|
77
|
+
# unsupported algorithm raises; `nil` when the helper generates none
|
|
78
|
+
#
|
|
79
|
+
# @raise [ArgumentError] when the secret decodes to no key bytes at all
|
|
80
|
+
# @raise [Straddle::Errors::WebhookVerificationError] also for an algorithm this runtime
|
|
81
|
+
# cannot check, whatever the delivery carries
|
|
82
|
+
# @return [void]
|
|
83
|
+
def verify!(
|
|
84
|
+
payload,
|
|
85
|
+
headers,
|
|
86
|
+
secret,
|
|
87
|
+
algorithm: DEFAULT_ALGORITHM,
|
|
88
|
+
id_header: "webhook-id",
|
|
89
|
+
timestamp_header: "webhook-timestamp",
|
|
90
|
+
signature_header: "webhook-signature",
|
|
91
|
+
tolerance: TOLERANCE_SECONDS,
|
|
92
|
+
decoder: nil
|
|
93
|
+
)
|
|
94
|
+
# Checked before anything else, the secret included: no delivery can verify under a scheme
|
|
95
|
+
# this runtime does not implement, so none is ever accepted, and the message says what to do.
|
|
96
|
+
digest = HMAC_DIGESTS[algorithm]
|
|
97
|
+
unless digest
|
|
98
|
+
# The decode-only method is configurable (and can be turned off), so the helper names it.
|
|
99
|
+
decode = decoder ? "decode the payload with #{decoder}" : "decode the payload yourself"
|
|
100
|
+
raise Straddle::Errors::WebhookVerificationError,
|
|
101
|
+
"Unsupported webhook signature algorithm #{algorithm}: this SDK cannot verify it; " \
|
|
102
|
+
"check the signature yourself, then #{decode}"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
key = decode_secret(secret)
|
|
106
|
+
|
|
107
|
+
msg_id = header_value(headers, id_header)
|
|
108
|
+
msg_timestamp = header_value(headers, timestamp_header)
|
|
109
|
+
msg_signature = header_value(headers, signature_header)
|
|
110
|
+
if !msg_id || !msg_timestamp || !msg_signature
|
|
111
|
+
raise Straddle::Errors::WebhookVerificationError, "Missing required headers"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
verify_timestamp!(msg_timestamp, tolerance)
|
|
115
|
+
|
|
116
|
+
# Every part is joined as binary (`.b`), byte for byte as received. The id and the body come
|
|
117
|
+
# from the sender, so their encodings need not agree: interpolating a UTF-8 id with non-ASCII
|
|
118
|
+
# characters beside a binary body (or the reverse) raises `Encoding::CompatibilityError`,
|
|
119
|
+
# where the delivery has to be refused as unsigned instead.
|
|
120
|
+
signed = [msg_id, msg_timestamp, payload].map { |part| part.to_s.b }.join(".")
|
|
121
|
+
expected = [OpenSSL::HMAC.digest(OpenSSL::Digest.new(digest), key, signed)].pack("m0")
|
|
122
|
+
# `split(" ")` splits on any run of whitespace, so a header folded with tabs or newlines
|
|
123
|
+
# still yields its entries. The explicit pattern matters: a bare `split` uses `$;` when the
|
|
124
|
+
# host process has set it. Entries for other versions are skipped rather than rejected,
|
|
125
|
+
# which is what lets a sender add a new scheme beside `v1`. The header is split as binary:
|
|
126
|
+
# a UTF-8 string holding an invalid byte sequence raises `ArgumentError` from `split`, so a
|
|
127
|
+
# garbled entry would otherwise escape as that error and hide a valid entry beside it, where
|
|
128
|
+
# it has to be one more signature that does not match.
|
|
129
|
+
entries = msg_signature.to_s.b.split(" ")
|
|
130
|
+
matched =
|
|
131
|
+
entries.any? do |entry|
|
|
132
|
+
version, signature = entry.split(",", 2)
|
|
133
|
+
version == "v1" && secure_compare(expected, signature)
|
|
134
|
+
end
|
|
135
|
+
return if matched
|
|
136
|
+
|
|
137
|
+
raise Straddle::Errors::WebhookVerificationError, "No matching signature found"
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# @api private
|
|
141
|
+
#
|
|
142
|
+
# HTTP header names are case-insensitive, and callers spell them differently: a hash built by
|
|
143
|
+
# hand or copied from a log is often title-cased (`Webhook-Id`), upper-cased, or keyed by
|
|
144
|
+
# Symbol. The exact lowercase String key wins when present; otherwise the first String or Symbol
|
|
145
|
+
# key matching in any case is used. A multi-valued header (an Array, as
|
|
146
|
+
# `Net::HTTPHeader#to_hash` returns them) yields its first value. A Rack `env` hash is not a
|
|
147
|
+
# header hash: its `HTTP_WEBHOOK_ID` keys do not match, so pass the request's headers instead.
|
|
148
|
+
#
|
|
149
|
+
# @param headers [Hash{String, Symbol=>String, Array<String>}]
|
|
150
|
+
# @param name [String] the lowercase header name
|
|
151
|
+
#
|
|
152
|
+
# @return [String, nil]
|
|
153
|
+
private def header_value(headers, name)
|
|
154
|
+
value = headers[name]
|
|
155
|
+
# An object that only answers `[]` (some framework header wrappers fold case there) has
|
|
156
|
+
# nothing to scan, so a miss stays a miss.
|
|
157
|
+
if value.nil? && headers.respond_to?(:each)
|
|
158
|
+
headers.each do |key, candidate|
|
|
159
|
+
next unless !candidate.nil? && (key.is_a?(String) || key.is_a?(Symbol))
|
|
160
|
+
# Folded as binary, so only ASCII letters change case: HTTP header names are ASCII, and
|
|
161
|
+
# `downcase` on a UTF-8 name holding an invalid byte sequence raises `ArgumentError`.
|
|
162
|
+
next unless key.to_s.b.downcase == name
|
|
163
|
+
|
|
164
|
+
value = candidate
|
|
165
|
+
break
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
value.is_a?(Array) ? value.first : value
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# @api private
|
|
172
|
+
#
|
|
173
|
+
# The secret is base64 after its optional `whsec_` prefix. It is decoded leniently, the way
|
|
174
|
+
# `Base64.decode64` does it, skipping characters outside the alphabet and tolerating missing
|
|
175
|
+
# padding, so every secret that verified before still does; strict decoding would turn a
|
|
176
|
+
# pasted secret with a stray newline into a crash.
|
|
177
|
+
#
|
|
178
|
+
# A secret that decodes to nothing (`""`, a bare `whsec_`, an unset variable read as an empty
|
|
179
|
+
# string) is refused rather than used: an HMAC keyed with no bytes is one anyone can compute,
|
|
180
|
+
# so every forged delivery would verify. A misconfiguration, so it is an `ArgumentError`, like
|
|
181
|
+
# the missing-key check in the helper that calls this, not a verification failure.
|
|
182
|
+
#
|
|
183
|
+
# @param secret [String]
|
|
184
|
+
#
|
|
185
|
+
# @raise [ArgumentError]
|
|
186
|
+
# @return [String]
|
|
187
|
+
private def decode_secret(secret)
|
|
188
|
+
key = secret.delete_prefix(SECRET_PREFIX).unpack1("m")
|
|
189
|
+
raise ArgumentError, "Webhook secret decodes to an empty key" if key.empty?
|
|
190
|
+
|
|
191
|
+
key
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# @api private
|
|
195
|
+
#
|
|
196
|
+
# `Integer()` accepts an optional sign, surrounding whitespace, `_` separators and a `0x`-style
|
|
197
|
+
# prefix, and rejects anything else, so the comparison below only ever sees a whole number of
|
|
198
|
+
# seconds. The signature is still computed over the header exactly as it was sent.
|
|
199
|
+
#
|
|
200
|
+
# @param msg_timestamp [String]
|
|
201
|
+
# @param tolerance [Integer] the replay window, in seconds, on each side of now
|
|
202
|
+
#
|
|
203
|
+
# @raise [Straddle::Errors::WebhookVerificationError]
|
|
204
|
+
private def verify_timestamp!(msg_timestamp, tolerance = TOLERANCE_SECONDS)
|
|
205
|
+
timestamp =
|
|
206
|
+
begin
|
|
207
|
+
Integer(msg_timestamp)
|
|
208
|
+
rescue StandardError
|
|
209
|
+
raise Straddle::Errors::WebhookVerificationError, "Invalid Signature Headers"
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
now = Time.now.to_i
|
|
213
|
+
if timestamp < now - tolerance
|
|
214
|
+
raise Straddle::Errors::WebhookVerificationError, "Message timestamp too old"
|
|
215
|
+
end
|
|
216
|
+
return unless timestamp > now + tolerance
|
|
217
|
+
|
|
218
|
+
raise Straddle::Errors::WebhookVerificationError, "Message timestamp too new"
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# @api private
|
|
222
|
+
#
|
|
223
|
+
# Compares in constant time, so how long a mismatch takes says nothing about how many leading
|
|
224
|
+
# bytes of a forged signature were right. `OpenSSL.fixed_length_secure_compare` raises on
|
|
225
|
+
# inputs of different lengths, so the lengths are checked first; that only reveals the length,
|
|
226
|
+
# which every valid signature shares.
|
|
227
|
+
#
|
|
228
|
+
# @param expected [String]
|
|
229
|
+
# @param signature [String, nil]
|
|
230
|
+
#
|
|
231
|
+
# @return [Boolean]
|
|
232
|
+
private def secure_compare(expected, signature)
|
|
233
|
+
return false unless signature.is_a?(String) && expected.bytesize == signature.bytesize
|
|
234
|
+
|
|
235
|
+
OpenSSL.fixed_length_secure_compare(expected, signature)
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
end
|
data/lib/straddle/internal.rb
CHANGED
|
@@ -4,7 +4,11 @@ module Straddle
|
|
|
4
4
|
module Internal
|
|
5
5
|
extend Straddle::Internal::Util::SorbetRuntimeSupport
|
|
6
6
|
|
|
7
|
-
OMIT =
|
|
7
|
+
OMIT =
|
|
8
|
+
Object
|
|
9
|
+
.new
|
|
10
|
+
.tap { _1.define_singleton_method(:inspect) { "#<#{Straddle::Internal}::OMIT>" } }
|
|
11
|
+
.freeze
|
|
8
12
|
|
|
9
13
|
define_sorbet_constant!(:AnyHash) { T.type_alias { T::Hash[Symbol, T.anything] } }
|
|
10
14
|
define_sorbet_constant!(:FileInput) do
|
|
@@ -106,8 +106,8 @@ module Straddle
|
|
|
106
106
|
# @!attribute daily_amount
|
|
107
107
|
# Daily charge amount limit in cents.
|
|
108
108
|
#
|
|
109
|
-
# @return [
|
|
110
|
-
required :daily_amount,
|
|
109
|
+
# @return [Integer]
|
|
110
|
+
required :daily_amount, Integer
|
|
111
111
|
|
|
112
112
|
# @!attribute enable
|
|
113
113
|
# Whether to enable or disable charges for the account.
|
|
@@ -118,14 +118,14 @@ module Straddle
|
|
|
118
118
|
# @!attribute max_amount
|
|
119
119
|
# Maximum amount in cents for one charge.
|
|
120
120
|
#
|
|
121
|
-
# @return [
|
|
122
|
-
required :max_amount,
|
|
121
|
+
# @return [Integer]
|
|
122
|
+
required :max_amount, Integer
|
|
123
123
|
|
|
124
124
|
# @!attribute monthly_amount
|
|
125
125
|
# Monthly charge amount limit in cents.
|
|
126
126
|
#
|
|
127
|
-
# @return [
|
|
128
|
-
required :monthly_amount,
|
|
127
|
+
# @return [Integer]
|
|
128
|
+
required :monthly_amount, Integer
|
|
129
129
|
|
|
130
130
|
# @!attribute monthly_count
|
|
131
131
|
# Maximum number of charges per calendar month.
|
|
@@ -136,13 +136,13 @@ module Straddle
|
|
|
136
136
|
# @!method initialize(daily_amount:, enable:, max_amount:, monthly_amount:, monthly_count:)
|
|
137
137
|
# Requested charge capability and limits.
|
|
138
138
|
#
|
|
139
|
-
# @param daily_amount [
|
|
139
|
+
# @param daily_amount [Integer] Daily charge amount limit in cents.
|
|
140
140
|
#
|
|
141
141
|
# @param enable [Boolean] Whether to enable or disable charges for the account.
|
|
142
142
|
#
|
|
143
|
-
# @param max_amount [
|
|
143
|
+
# @param max_amount [Integer] Maximum amount in cents for one charge.
|
|
144
144
|
#
|
|
145
|
-
# @param monthly_amount [
|
|
145
|
+
# @param monthly_amount [Integer] Monthly charge amount limit in cents.
|
|
146
146
|
#
|
|
147
147
|
# @param monthly_count [Integer] Maximum number of charges per calendar month.
|
|
148
148
|
end
|
|
@@ -177,8 +177,8 @@ module Straddle
|
|
|
177
177
|
# @!attribute daily_amount
|
|
178
178
|
# Daily payout amount limit in cents.
|
|
179
179
|
#
|
|
180
|
-
# @return [
|
|
181
|
-
required :daily_amount,
|
|
180
|
+
# @return [Integer]
|
|
181
|
+
required :daily_amount, Integer
|
|
182
182
|
|
|
183
183
|
# @!attribute enable
|
|
184
184
|
# Whether to enable or disable payouts for the account.
|
|
@@ -189,14 +189,14 @@ module Straddle
|
|
|
189
189
|
# @!attribute max_amount
|
|
190
190
|
# Maximum amount in cents for one payout.
|
|
191
191
|
#
|
|
192
|
-
# @return [
|
|
193
|
-
required :max_amount,
|
|
192
|
+
# @return [Integer]
|
|
193
|
+
required :max_amount, Integer
|
|
194
194
|
|
|
195
195
|
# @!attribute monthly_amount
|
|
196
196
|
# Monthly payout amount limit in cents.
|
|
197
197
|
#
|
|
198
|
-
# @return [
|
|
199
|
-
required :monthly_amount,
|
|
198
|
+
# @return [Integer]
|
|
199
|
+
required :monthly_amount, Integer
|
|
200
200
|
|
|
201
201
|
# @!attribute monthly_count
|
|
202
202
|
# Maximum number of payouts per calendar month.
|
|
@@ -207,13 +207,13 @@ module Straddle
|
|
|
207
207
|
# @!method initialize(daily_amount:, enable:, max_amount:, monthly_amount:, monthly_count:)
|
|
208
208
|
# Requested payout capability and limits.
|
|
209
209
|
#
|
|
210
|
-
# @param daily_amount [
|
|
210
|
+
# @param daily_amount [Integer] Daily payout amount limit in cents.
|
|
211
211
|
#
|
|
212
212
|
# @param enable [Boolean] Whether to enable or disable payouts for the account.
|
|
213
213
|
#
|
|
214
|
-
# @param max_amount [
|
|
214
|
+
# @param max_amount [Integer] Maximum amount in cents for one payout.
|
|
215
215
|
#
|
|
216
|
-
# @param monthly_amount [
|
|
216
|
+
# @param monthly_amount [Integer] Monthly payout amount limit in cents.
|
|
217
217
|
#
|
|
218
218
|
# @param monthly_count [Integer] Maximum number of payouts per calendar month.
|
|
219
219
|
end
|
|
@@ -27,7 +27,8 @@ module Straddle
|
|
|
27
27
|
required :label, String
|
|
28
28
|
|
|
29
29
|
# @!attribute paykey
|
|
30
|
-
#
|
|
30
|
+
# Paykey value. Paykey create responses return the full value for creating
|
|
31
|
+
# payments. Store it securely. Other responses return it masked.
|
|
31
32
|
#
|
|
32
33
|
# @return [String]
|
|
33
34
|
required :paykey, String
|
|
@@ -113,7 +114,7 @@ module Straddle
|
|
|
113
114
|
#
|
|
114
115
|
# @param label [String] Human-readable label for the paykey.
|
|
115
116
|
#
|
|
116
|
-
# @param paykey [String]
|
|
117
|
+
# @param paykey [String] Paykey value. Paykey create responses return the full value for creating payment
|
|
117
118
|
#
|
|
118
119
|
# @param source [Symbol, Straddle::Models::PaykeySource]
|
|
119
120
|
#
|
|
@@ -168,7 +168,9 @@ module Straddle
|
|
|
168
168
|
required :status, enum: -> { Straddle::PaykeyBalanceRefreshStatus }
|
|
169
169
|
|
|
170
170
|
# @!attribute account_balance
|
|
171
|
-
# Most recently retrieved account balance in dollars.
|
|
171
|
+
# Most recently retrieved account balance in dollars. Unlike REST paykey
|
|
172
|
+
# responses, which report `account_balance` in cents, this webhook field uses
|
|
173
|
+
# dollars.
|
|
172
174
|
#
|
|
173
175
|
# @return [Float, nil]
|
|
174
176
|
optional :account_balance, Float, nil?: true
|
|
@@ -180,9 +182,12 @@ module Straddle
|
|
|
180
182
|
optional :updated_at, Time, nil?: true
|
|
181
183
|
|
|
182
184
|
# @!method initialize(status:, account_balance: nil, updated_at: nil)
|
|
185
|
+
# Some parameter documentations has been truncated, see
|
|
186
|
+
# {Straddle::Models::PaykeyCreatedV1WebhookEvent::Data::Balance} for more details.
|
|
187
|
+
#
|
|
183
188
|
# @param status [Symbol, Straddle::Models::PaykeyBalanceRefreshStatus]
|
|
184
189
|
#
|
|
185
|
-
# @param account_balance [Float, nil] Most recently retrieved account balance in dollars.
|
|
190
|
+
# @param account_balance [Float, nil] Most recently retrieved account balance in dollars. Unlike REST paykey responses
|
|
186
191
|
#
|
|
187
192
|
# @param updated_at [Time, nil] Timestamp of the most recent account balance update.
|
|
188
193
|
end
|
|
@@ -168,7 +168,9 @@ module Straddle
|
|
|
168
168
|
required :status, enum: -> { Straddle::PaykeyBalanceRefreshStatus }
|
|
169
169
|
|
|
170
170
|
# @!attribute account_balance
|
|
171
|
-
# Most recently retrieved account balance in dollars.
|
|
171
|
+
# Most recently retrieved account balance in dollars. Unlike REST paykey
|
|
172
|
+
# responses, which report `account_balance` in cents, this webhook field uses
|
|
173
|
+
# dollars.
|
|
172
174
|
#
|
|
173
175
|
# @return [Float, nil]
|
|
174
176
|
optional :account_balance, Float, nil?: true
|
|
@@ -180,9 +182,12 @@ module Straddle
|
|
|
180
182
|
optional :updated_at, Time, nil?: true
|
|
181
183
|
|
|
182
184
|
# @!method initialize(status:, account_balance: nil, updated_at: nil)
|
|
185
|
+
# Some parameter documentations has been truncated, see
|
|
186
|
+
# {Straddle::Models::PaykeyEventV1WebhookEvent::Data::Balance} for more details.
|
|
187
|
+
#
|
|
183
188
|
# @param status [Symbol, Straddle::Models::PaykeyBalanceRefreshStatus]
|
|
184
189
|
#
|
|
185
|
-
# @param account_balance [Float, nil] Most recently retrieved account balance in dollars.
|
|
190
|
+
# @param account_balance [Float, nil] Most recently retrieved account balance in dollars. Unlike REST paykey responses
|
|
186
191
|
#
|
|
187
192
|
# @param updated_at [Time, nil] Timestamp of the most recent account balance update.
|
|
188
193
|
end
|
|
@@ -21,6 +21,12 @@ module Straddle
|
|
|
21
21
|
# @return [Straddle::Models::PayoutConfiguration]
|
|
22
22
|
required :config, -> { Straddle::PayoutConfiguration }
|
|
23
23
|
|
|
24
|
+
# @!attribute created_at
|
|
25
|
+
# Timestamp when this payout was created.
|
|
26
|
+
#
|
|
27
|
+
# @return [Time]
|
|
28
|
+
required :created_at, Time
|
|
29
|
+
|
|
24
30
|
# @!attribute currency
|
|
25
31
|
# Currency code. Only `USD` is supported.
|
|
26
32
|
#
|
|
@@ -106,11 +112,11 @@ module Straddle
|
|
|
106
112
|
# @return [Hash{Symbol=>String}]
|
|
107
113
|
required :trace_ids, Straddle::Internal::Type::HashOf[String]
|
|
108
114
|
|
|
109
|
-
# @!attribute
|
|
110
|
-
# Timestamp when this payout was
|
|
115
|
+
# @!attribute updated_at
|
|
116
|
+
# Timestamp when this payout was last updated.
|
|
111
117
|
#
|
|
112
|
-
# @return [Time
|
|
113
|
-
|
|
118
|
+
# @return [Time]
|
|
119
|
+
required :updated_at, Time
|
|
114
120
|
|
|
115
121
|
# @!attribute customer_details
|
|
116
122
|
# Information about the customer associated with the payout.
|
|
@@ -165,13 +171,7 @@ module Straddle
|
|
|
165
171
|
-> { Straddle::Internal::Type::ArrayOf[Straddle::RelatedPayment] },
|
|
166
172
|
nil?: true
|
|
167
173
|
|
|
168
|
-
# @!
|
|
169
|
-
# Timestamp when this payout was last updated.
|
|
170
|
-
#
|
|
171
|
-
# @return [Time, nil]
|
|
172
|
-
optional :updated_at, Time, nil?: true
|
|
173
|
-
|
|
174
|
-
# @!method initialize(id:, amount:, config:, currency:, description:, device:, external_id:, funding_ids:, has_resubmit:, is_refund:, is_resubmit:, paykey:, payment_date:, status:, status_details:, status_history:, trace_ids:, created_at: nil, customer_details: nil, documents: nil, effective_at: nil, metadata: nil, paykey_details: nil, payment_rail: nil, processed_at: nil, related_payments: nil, updated_at: nil)
|
|
174
|
+
# @!method initialize(id:, amount:, config:, created_at:, currency:, description:, device:, external_id:, funding_ids:, has_resubmit:, is_refund:, is_resubmit:, paykey:, payment_date:, status:, status_details:, status_history:, trace_ids:, updated_at:, customer_details: nil, documents: nil, effective_at: nil, metadata: nil, paykey_details: nil, payment_rail: nil, processed_at: nil, related_payments: nil)
|
|
175
175
|
# Some parameter documentations has been truncated, see {Straddle::Models::Payout}
|
|
176
176
|
# for more details.
|
|
177
177
|
#
|
|
@@ -181,6 +181,8 @@ module Straddle
|
|
|
181
181
|
#
|
|
182
182
|
# @param config [Straddle::Models::PayoutConfiguration] Configuration for the payout.
|
|
183
183
|
#
|
|
184
|
+
# @param created_at [Time] Timestamp when this payout was created.
|
|
185
|
+
#
|
|
184
186
|
# @param currency [String] Currency code. Only `USD` is supported.
|
|
185
187
|
#
|
|
186
188
|
# @param description [String, nil] A human-readable description of the payout.
|
|
@@ -209,7 +211,7 @@ module Straddle
|
|
|
209
211
|
#
|
|
210
212
|
# @param trace_ids [Hash{Symbol=>String}] Trace identifiers from the payment network. Keys depend on the payment rail.
|
|
211
213
|
#
|
|
212
|
-
# @param
|
|
214
|
+
# @param updated_at [Time] Timestamp when this payout was last updated.
|
|
213
215
|
#
|
|
214
216
|
# @param customer_details [Straddle::Models::CustomerDetails] Information about the customer associated with the payout.
|
|
215
217
|
#
|
|
@@ -226,8 +228,6 @@ module Straddle
|
|
|
226
228
|
# @param processed_at [Time, nil] Timestamp when this payout was submitted to the payment network. Null until proc
|
|
227
229
|
#
|
|
228
230
|
# @param related_payments [Array<Straddle::Models::RelatedPayment>, nil] Related payments and their relationship to this payout.
|
|
229
|
-
#
|
|
230
|
-
# @param updated_at [Time, nil] Timestamp when this payout was last updated.
|
|
231
231
|
end
|
|
232
232
|
end
|
|
233
233
|
end
|
|
@@ -20,6 +20,12 @@ module Straddle
|
|
|
20
20
|
# @return [Straddle::Models::PayoutConfiguration]
|
|
21
21
|
required :config, -> { Straddle::PayoutConfiguration }
|
|
22
22
|
|
|
23
|
+
# @!attribute created_at
|
|
24
|
+
# Timestamp when this payout was created.
|
|
25
|
+
#
|
|
26
|
+
# @return [Time]
|
|
27
|
+
required :created_at, Time
|
|
28
|
+
|
|
23
29
|
# @!attribute currency
|
|
24
30
|
# Currency code. Only `USD` is supported.
|
|
25
31
|
#
|
|
@@ -103,11 +109,11 @@ module Straddle
|
|
|
103
109
|
# @return [Hash{Symbol=>String}]
|
|
104
110
|
required :trace_ids, Straddle::Internal::Type::HashOf[String]
|
|
105
111
|
|
|
106
|
-
# @!attribute
|
|
107
|
-
# Timestamp when this payout was
|
|
112
|
+
# @!attribute updated_at
|
|
113
|
+
# Timestamp when this payout was last updated.
|
|
108
114
|
#
|
|
109
|
-
# @return [Time
|
|
110
|
-
|
|
115
|
+
# @return [Time]
|
|
116
|
+
required :updated_at, Time
|
|
111
117
|
|
|
112
118
|
# @!attribute customer_details
|
|
113
119
|
# Information about the customer associated with the charge or payout.
|
|
@@ -161,13 +167,7 @@ module Straddle
|
|
|
161
167
|
-> { Straddle::Internal::Type::ArrayOf[Straddle::RelatedPayment] },
|
|
162
168
|
nil?: true
|
|
163
169
|
|
|
164
|
-
# @!
|
|
165
|
-
# Timestamp when this payout was last updated.
|
|
166
|
-
#
|
|
167
|
-
# @return [Time, nil]
|
|
168
|
-
optional :updated_at, Time, nil?: true
|
|
169
|
-
|
|
170
|
-
# @!method initialize(id:, amount:, config:, currency:, description:, device:, external_id:, funding_ids:, has_resubmit:, is_refund:, is_resubmit:, paykey:, payment_date:, status:, status_details:, status_history:, trace_ids:, created_at: nil, customer_details: nil, documents: nil, effective_at: nil, metadata: nil, paykey_details: nil, payment_rail: nil, processed_at: nil, related_payments: nil, updated_at: nil)
|
|
170
|
+
# @!method initialize(id:, amount:, config:, created_at:, currency:, description:, device:, external_id:, funding_ids:, has_resubmit:, is_refund:, is_resubmit:, paykey:, payment_date:, status:, status_details:, status_history:, trace_ids:, updated_at:, customer_details: nil, documents: nil, effective_at: nil, metadata: nil, paykey_details: nil, payment_rail: nil, processed_at: nil, related_payments: nil)
|
|
171
171
|
# Some parameter documentations has been truncated, see
|
|
172
172
|
# {Straddle::Models::UnmaskedPayout} for more details.
|
|
173
173
|
#
|
|
@@ -177,6 +177,8 @@ module Straddle
|
|
|
177
177
|
#
|
|
178
178
|
# @param config [Straddle::Models::PayoutConfiguration]
|
|
179
179
|
#
|
|
180
|
+
# @param created_at [Time] Timestamp when this payout was created.
|
|
181
|
+
#
|
|
180
182
|
# @param currency [String] Currency code. Only `USD` is supported.
|
|
181
183
|
#
|
|
182
184
|
# @param description [String, nil] A human-readable description of the payout.
|
|
@@ -205,7 +207,7 @@ module Straddle
|
|
|
205
207
|
#
|
|
206
208
|
# @param trace_ids [Hash{Symbol=>String}] Trace identifiers from the payment network. Keys depend on the payment rail.
|
|
207
209
|
#
|
|
208
|
-
# @param
|
|
210
|
+
# @param updated_at [Time] Timestamp when this payout was last updated.
|
|
209
211
|
#
|
|
210
212
|
# @param customer_details [Straddle::Models::CustomerDetails] Information about the customer associated with the charge or payout.
|
|
211
213
|
#
|
|
@@ -222,8 +224,6 @@ module Straddle
|
|
|
222
224
|
# @param processed_at [Time, nil] Timestamp when this payout was submitted to the payment network. Null until proc
|
|
223
225
|
#
|
|
224
226
|
# @param related_payments [Array<Straddle::Models::RelatedPayment>, nil] Related payments and their relationship to this payout.
|
|
225
|
-
#
|
|
226
|
-
# @param updated_at [Time, nil] Timestamp when this payout was last updated.
|
|
227
227
|
end
|
|
228
228
|
end
|
|
229
229
|
end
|
data/lib/straddle/models.rb
CHANGED
|
@@ -5,42 +5,39 @@ module Straddle
|
|
|
5
5
|
cls.define_sorbet_constant!(:OrHash) { T.type_alias { T.any(cls, Straddle::Internal::AnyHash) } }
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
Straddle::Internal::Util
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
mod.define_sorbet_constant!(:OrSymbol) { T.type_alias { T.any(Symbol, String) } }
|
|
27
|
-
else
|
|
28
|
-
end
|
|
8
|
+
Straddle::Internal::Util.walk_namespaces(Straddle::Models).each do |mod|
|
|
9
|
+
case mod
|
|
10
|
+
in Straddle::Internal::Type::Enum | Straddle::Internal::Type::Union
|
|
11
|
+
mod.constants.each do |name|
|
|
12
|
+
case mod.const_get(name)
|
|
13
|
+
in true | false
|
|
14
|
+
mod.define_sorbet_constant!(:TaggedBoolean) { T.type_alias { T::Boolean } }
|
|
15
|
+
mod.define_sorbet_constant!(:OrBoolean) { T.type_alias { T::Boolean } }
|
|
16
|
+
in Integer
|
|
17
|
+
mod.define_sorbet_constant!(:TaggedInteger) { T.type_alias { Integer } }
|
|
18
|
+
mod.define_sorbet_constant!(:OrInteger) { T.type_alias { Integer } }
|
|
19
|
+
in Float
|
|
20
|
+
mod.define_sorbet_constant!(:TaggedFloat) { T.type_alias { Float } }
|
|
21
|
+
mod.define_sorbet_constant!(:OrFloat) { T.type_alias { Float } }
|
|
22
|
+
in Symbol
|
|
23
|
+
mod.define_sorbet_constant!(:TaggedSymbol) { T.type_alias { Symbol } }
|
|
24
|
+
mod.define_sorbet_constant!(:OrSymbol) { T.type_alias { T.any(Symbol, String) } }
|
|
25
|
+
else
|
|
29
26
|
end
|
|
30
|
-
else
|
|
31
27
|
end
|
|
28
|
+
else
|
|
32
29
|
end
|
|
30
|
+
end
|
|
33
31
|
|
|
34
|
-
Straddle::Internal::Util
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
next if mod.sorbet_constant_defined?(const)
|
|
32
|
+
Straddle::Internal::Util.walk_namespaces(Straddle::Models)
|
|
33
|
+
.lazy
|
|
34
|
+
.grep(Straddle::Internal::Type::Union)
|
|
35
|
+
.each do |mod|
|
|
36
|
+
const = :Variants
|
|
37
|
+
next if mod.sorbet_constant_defined?(const)
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
mod.define_sorbet_constant!(const) { T.type_alias { mod.to_sorbet_type } }
|
|
40
|
+
end
|
|
44
41
|
|
|
45
42
|
Account = Straddle::Models::Account
|
|
46
43
|
|
|
@@ -482,5 +479,7 @@ module Straddle
|
|
|
482
479
|
|
|
483
480
|
UserEventV1WebhookEvent = Straddle::Models::UserEventV1WebhookEvent
|
|
484
481
|
|
|
482
|
+
WebhookParsedParams = Straddle::Models::WebhookParsedParams
|
|
483
|
+
|
|
485
484
|
WebhookUnwrapParams = Straddle::Models::WebhookUnwrapParams
|
|
486
485
|
end
|