Class: Straddle::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- Straddle::Client
- Defined in:
- lib/straddle/client.rb,
sig/straddle/client.rbs
Constant Summary collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS, Internal::Transport::BaseClient::Straddle
Instance Attribute Summary collapse
-
#account_settings ⇒ Straddle::Resources::AccountSettings
readonly
Account settings define payment limits, capabilities, statement details, and policy controls for an account.
-
#accounts ⇒ Straddle::Resources::Accounts
readonly
Accounts represent businesses that use Straddle through a platform.
-
#bearer ⇒ String
readonly
Send the API key as a bearer token in the
Authorizationheader. -
#bridge ⇒ Straddle::Resources::Bridge
readonly
Bridge connects customer bank accounts and creates paykeys from supported provider tokens or bank account details.
-
#capability_requests ⇒ Straddle::Resources::CapabilityRequests
readonly
Capability requests change the payment, customer, and consent types available to an account.
-
#charges ⇒ Straddle::Resources::Charges
readonly
Charges debit a customer's bank account through a paykey.
-
#customers ⇒ Straddle::Resources::Customers
readonly
Customers are individuals or businesses that send or receive payments through your integration.
-
#funding_events ⇒ Straddle::Resources::FundingEvents
readonly
Funding events group charge and payout activity into transfers between Straddle and your linked bank account.
-
#linked_bank_accounts ⇒ Straddle::Resources::LinkedBankAccounts
readonly
Linked bank accounts connect external bank accounts to an account or platform for charges, payouts, or billing.
-
#organizations ⇒ Straddle::Resources::Organizations
readonly
Organizations group related Straddle accounts.
-
#paykeys ⇒ Straddle::Resources::Paykeys
readonly
A paykey links a verified customer to a bank account without exposing bank account details.
-
#payments ⇒ Straddle::Resources::Payments
readonly
Payments provide a combined view of charges and payouts.
-
#payouts ⇒ Straddle::Resources::Payouts
readonly
Payouts send money to a customer's bank account through a paykey.
-
#representatives ⇒ Straddle::Resources::Representatives
readonly
Representatives are people associated with a business account for ownership, control, or authorization purposes.
-
#webhook_secret ⇒ String?
readonly
Secret used to verify incoming webhook signatures.
- #webhooks ⇒ Straddle::Resources::Webhooks readonly
Attributes inherited from Internal::Transport::BaseClient
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary collapse
-
#initialize(bearer: ENV["BEARER"], webhook_secret: ENV["STRADDLE_WEBHOOK_SECRET"], base_url: ENV["STRADDLE_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
constructor
Creates and returns a new client for interacting with the API.
Methods inherited from Internal::Transport::BaseClient
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(bearer: ENV["BEARER"], webhook_secret: ENV["STRADDLE_WEBHOOK_SECRET"], base_url: ENV["STRADDLE_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
ENV["BEARER"]
ENV["STRADDLE_WEBHOOK_SECRET"]
"https://api.example.com/v2/". Defaults to ENV["STRADDLE_BASE_URL"]
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/straddle/client.rb', line 114 def initialize( bearer: ENV["BEARER"], webhook_secret: ENV["STRADDLE_WEBHOOK_SECRET"], base_url: ENV["STRADDLE_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY ) base_url ||= "https://sandbox.straddle.com" raise ArgumentError.new("bearer is required, and can be set via environ: \"BEARER\"") if bearer.nil? headers = {} custom_headers_env = ENV["STRADDLE_CUSTOM_HEADERS"] unless custom_headers_env.nil? parsed = {} custom_headers_env .split("\n") .each do |line| colon = line.index(":") parsed[line[0...colon].strip] = line[(colon + 1)..].strip unless colon.nil? end headers = parsed.merge(headers) end @bearer = bearer.to_s @webhook_secret = webhook_secret&.to_s super( base_url: base_url, timeout: timeout, max_retries: max_retries, initial_retry_delay: initial_retry_delay, max_retry_delay: max_retry_delay, headers: headers ) @accounts = Straddle::Resources::Accounts.new(client: self) @capability_requests = Straddle::Resources::CapabilityRequests.new(client: self) @linked_bank_accounts = Straddle::Resources::LinkedBankAccounts.new(client: self) @organizations = Straddle::Resources::Organizations.new(client: self) @representatives = Straddle::Resources::Representatives.new(client: self) @bridge = Straddle::Resources::Bridge.new(client: self) @customers = Straddle::Resources::Customers.new(client: self) @paykeys = Straddle::Resources::Paykeys.new(client: self) @charges = Straddle::Resources::Charges.new(client: self) @funding_events = Straddle::Resources::FundingEvents.new(client: self) @payments = Straddle::Resources::Payments.new(client: self) @payouts = Straddle::Resources::Payouts.new(client: self) @account_settings = Straddle::Resources::AccountSettings.new(client: self) @webhooks = Straddle::Resources::Webhooks.new(client: self) end |
Instance Attribute Details
#account_settings ⇒ Straddle::Resources::AccountSettings (readonly)
Account settings define payment limits, capabilities, statement details, and policy controls for an account.
84 85 86 |
# File 'lib/straddle/client.rb', line 84 def account_settings @account_settings end |
#accounts ⇒ Straddle::Resources::Accounts (readonly)
Accounts represent businesses that use Straddle through a platform.
28 29 30 |
# File 'lib/straddle/client.rb', line 28 def accounts @accounts end |
#bearer ⇒ String (readonly)
Send the API key as a bearer token in the Authorization header.
20 21 22 |
# File 'lib/straddle/client.rb', line 20 def bearer @bearer end |
#bridge ⇒ Straddle::Resources::Bridge (readonly)
Bridge connects customer bank accounts and creates paykeys from supported provider tokens or bank account details.
52 53 54 |
# File 'lib/straddle/client.rb', line 52 def bridge @bridge end |
#capability_requests ⇒ Straddle::Resources::CapabilityRequests (readonly)
Capability requests change the payment, customer, and consent types available to an account.
33 34 35 |
# File 'lib/straddle/client.rb', line 33 def capability_requests @capability_requests end |
#charges ⇒ Straddle::Resources::Charges (readonly)
Charges debit a customer's bank account through a paykey.
66 67 68 |
# File 'lib/straddle/client.rb', line 66 def charges @charges end |
#customers ⇒ Straddle::Resources::Customers (readonly)
Customers are individuals or businesses that send or receive payments through your integration.
57 58 59 |
# File 'lib/straddle/client.rb', line 57 def customers @customers end |
#funding_events ⇒ Straddle::Resources::FundingEvents (readonly)
Funding events group charge and payout activity into transfers between Straddle and your linked bank account.
71 72 73 |
# File 'lib/straddle/client.rb', line 71 def funding_events @funding_events end |
#linked_bank_accounts ⇒ Straddle::Resources::LinkedBankAccounts (readonly)
Linked bank accounts connect external bank accounts to an account or platform for charges, payouts, or billing.
38 39 40 |
# File 'lib/straddle/client.rb', line 38 def linked_bank_accounts @linked_bank_accounts end |
#organizations ⇒ Straddle::Resources::Organizations (readonly)
Organizations group related Straddle accounts.
42 43 44 |
# File 'lib/straddle/client.rb', line 42 def organizations @organizations end |
#paykeys ⇒ Straddle::Resources::Paykeys (readonly)
A paykey links a verified customer to a bank account without exposing bank account details. Use a paykey to create charges and payouts.
62 63 64 |
# File 'lib/straddle/client.rb', line 62 def paykeys @paykeys end |
#payments ⇒ Straddle::Resources::Payments (readonly)
Payments provide a combined view of charges and payouts.
75 76 77 |
# File 'lib/straddle/client.rb', line 75 def payments @payments end |
#payouts ⇒ Straddle::Resources::Payouts (readonly)
Payouts send money to a customer's bank account through a paykey.
79 80 81 |
# File 'lib/straddle/client.rb', line 79 def payouts @payouts end |
#representatives ⇒ Straddle::Resources::Representatives (readonly)
Representatives are people associated with a business account for ownership, control, or authorization purposes.
47 48 49 |
# File 'lib/straddle/client.rb', line 47 def representatives @representatives end |
#webhook_secret ⇒ String? (readonly)
Secret used to verify incoming webhook signatures.
24 25 26 |
# File 'lib/straddle/client.rb', line 24 def webhook_secret @webhook_secret end |
#webhooks ⇒ Straddle::Resources::Webhooks (readonly)
87 88 89 |
# File 'lib/straddle/client.rb', line 87 def webhooks @webhooks end |