Class: ModernTreasury::Client
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
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary
collapse
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(api_key: , organization_id: , webhook_key: , 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, idempotency_header: "Idempotency-Key") ⇒ Client
Creates and returns a new client for interacting with the API.
‘“api.example.com/v2/”`. Defaults to `ENV`
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
# File 'lib/modern_treasury/client.rb', line 190
def initialize(
api_key: ENV["MODERN_TREASURY_API_KEY"],
organization_id: ENV["MODERN_TREASURY_ORGANIZATION_ID"],
webhook_key: ENV["MODERN_TREASURY_WEBHOOK_KEY"],
base_url: ENV["MODERN_TREASURY_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,
idempotency_header: "Idempotency-Key"
)
base_url ||= "https://app.moderntreasury.com"
if api_key.nil?
raise ArgumentError.new("api_key is required, and can be set via environ: \"MODERN_TREASURY_API_KEY\"")
end
if organization_id.nil?
raise ArgumentError.new("organization_id is required, and can be set via environ: \"MODERN_TREASURY_ORGANIZATION_ID\"")
end
@api_key = api_key.to_s
@organization_id = organization_id.to_s
@webhook_key = webhook_key&.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,
idempotency_header:
)
@connections = ModernTreasury::Resources::Connections.new(client: self)
@counterparties = ModernTreasury::Resources::Counterparties.new(client: self)
@events = ModernTreasury::Resources::Events.new(client: self)
@expected_payments = ModernTreasury::Resources::ExpectedPayments.new(client: self)
@external_accounts = ModernTreasury::Resources::ExternalAccounts.new(client: self)
@incoming_payment_details = ModernTreasury::Resources::IncomingPaymentDetails.new(client: self)
@invoices = ModernTreasury::Resources::Invoices.new(client: self)
@documents = ModernTreasury::Resources::Documents.new(client: self)
@account_collection_flows = ModernTreasury::Resources::AccountCollectionFlows.new(client: self)
@account_details = ModernTreasury::Resources::AccountDetails.new(client: self)
@routing_details = ModernTreasury::Resources::RoutingDetails.new(client: self)
@internal_accounts = ModernTreasury::Resources::InternalAccounts.new(client: self)
@ledgers = ModernTreasury::Resources::Ledgers.new(client: self)
@ledger_account_categories = ModernTreasury::Resources::LedgerAccountCategories.new(client: self)
@ledger_accounts = ModernTreasury::Resources::LedgerAccounts.new(client: self)
@ledger_account_balance_monitors =
ModernTreasury::Resources::LedgerAccountBalanceMonitors.new(client: self)
@ledger_account_statements = ModernTreasury::Resources::LedgerAccountStatements.new(client: self)
@ledger_entries = ModernTreasury::Resources::LedgerEntries.new(client: self)
@ledger_transactions = ModernTreasury::Resources::LedgerTransactions.new(client: self)
@line_items = ModernTreasury::Resources::LineItems.new(client: self)
@payment_flows = ModernTreasury::Resources::PaymentFlows.new(client: self)
@payment_orders = ModernTreasury::Resources::PaymentOrders.new(client: self)
@payment_references = ModernTreasury::Resources::PaymentReferences.new(client: self)
@returns = ModernTreasury::Resources::Returns.new(client: self)
@transactions = ModernTreasury::Resources::Transactions.new(client: self)
@validations = ModernTreasury::Resources::Validations.new(client: self)
@virtual_accounts = ModernTreasury::Resources::VirtualAccounts.new(client: self)
@bulk_requests = ModernTreasury::Resources::BulkRequests.new(client: self)
@bulk_results = ModernTreasury::Resources::BulkResults.new(client: self)
@ledger_account_settlements = ModernTreasury::Resources::LedgerAccountSettlements.new(client: self)
@foreign_exchange_quotes = ModernTreasury::Resources::ForeignExchangeQuotes.new(client: self)
@connection_legal_entities = ModernTreasury::Resources::ConnectionLegalEntities.new(client: self)
@legal_entities = ModernTreasury::Resources::LegalEntities.new(client: self)
@legal_entity_associations = ModernTreasury::Resources::LegalEntityAssociations.new(client: self)
@payment_actions = ModernTreasury::Resources::PaymentActions.new(client: self)
@journal_entries = ModernTreasury::Resources::JournalEntries.new(client: self)
@journal_reports = ModernTreasury::Resources::JournalReports.new(client: self)
@holds = ModernTreasury::Resources::Holds.new(client: self)
end
|
Instance Attribute Details
52
53
54
|
# File 'lib/modern_treasury/client.rb', line 52
def account_collection_flows
@account_collection_flows
end
|
55
56
57
|
# File 'lib/modern_treasury/client.rb', line 55
def account_details
@account_details
end
|
#api_key ⇒ String
19
20
21
|
# File 'lib/modern_treasury/client.rb', line 19
def api_key
@api_key
end
|
109
110
111
|
# File 'lib/modern_treasury/client.rb', line 109
def bulk_requests
@bulk_requests
end
|
112
113
114
|
# File 'lib/modern_treasury/client.rb', line 112
def bulk_results
@bulk_results
end
|
121
122
123
|
# File 'lib/modern_treasury/client.rb', line 121
def connection_legal_entities
@connection_legal_entities
end
|
28
29
30
|
# File 'lib/modern_treasury/client.rb', line 28
def connections
@connections
end
|
31
32
33
|
# File 'lib/modern_treasury/client.rb', line 31
def counterparties
@counterparties
end
|
49
50
51
|
# File 'lib/modern_treasury/client.rb', line 49
def documents
@documents
end
|
34
35
36
|
# File 'lib/modern_treasury/client.rb', line 34
def events
@events
end
|
37
38
39
|
# File 'lib/modern_treasury/client.rb', line 37
def expected_payments
@expected_payments
end
|
40
41
42
|
# File 'lib/modern_treasury/client.rb', line 40
def external_accounts
@external_accounts
end
|
118
119
120
|
# File 'lib/modern_treasury/client.rb', line 118
def foreign_exchange_quotes
@foreign_exchange_quotes
end
|
139
140
141
|
# File 'lib/modern_treasury/client.rb', line 139
def holds
@holds
end
|
43
44
45
|
# File 'lib/modern_treasury/client.rb', line 43
def incoming_payment_details
@incoming_payment_details
end
|
61
62
63
|
# File 'lib/modern_treasury/client.rb', line 61
def internal_accounts
@internal_accounts
end
|
46
47
48
|
# File 'lib/modern_treasury/client.rb', line 46
def invoices
@invoices
end
|
133
134
135
|
# File 'lib/modern_treasury/client.rb', line 133
def journal_entries
@journal_entries
end
|
136
137
138
|
# File 'lib/modern_treasury/client.rb', line 136
def journal_reports
@journal_reports
end
|
73
74
75
|
# File 'lib/modern_treasury/client.rb', line 73
def ledger_account_balance_monitors
@ledger_account_balance_monitors
end
|
67
68
69
|
# File 'lib/modern_treasury/client.rb', line 67
def ledger_account_categories
@ledger_account_categories
end
|
115
116
117
|
# File 'lib/modern_treasury/client.rb', line 115
def ledger_account_settlements
@ledger_account_settlements
end
|
76
77
78
|
# File 'lib/modern_treasury/client.rb', line 76
def ledger_account_statements
@ledger_account_statements
end
|
70
71
72
|
# File 'lib/modern_treasury/client.rb', line 70
def ledger_accounts
@ledger_accounts
end
|
79
80
81
|
# File 'lib/modern_treasury/client.rb', line 79
def ledger_entries
@ledger_entries
end
|
82
83
84
|
# File 'lib/modern_treasury/client.rb', line 82
def ledger_transactions
@ledger_transactions
end
|
64
65
66
|
# File 'lib/modern_treasury/client.rb', line 64
def ledgers
@ledgers
end
|
124
125
126
|
# File 'lib/modern_treasury/client.rb', line 124
def legal_entities
@legal_entities
end
|
127
128
129
|
# File 'lib/modern_treasury/client.rb', line 127
def legal_entity_associations
@legal_entity_associations
end
|
85
86
87
|
# File 'lib/modern_treasury/client.rb', line 85
def line_items
@line_items
end
|
#organization_id ⇒ String
22
23
24
|
# File 'lib/modern_treasury/client.rb', line 22
def organization_id
@organization_id
end
|
130
131
132
|
# File 'lib/modern_treasury/client.rb', line 130
def payment_actions
@payment_actions
end
|
88
89
90
|
# File 'lib/modern_treasury/client.rb', line 88
def payment_flows
@payment_flows
end
|
91
92
93
|
# File 'lib/modern_treasury/client.rb', line 91
def payment_orders
@payment_orders
end
|
94
95
96
|
# File 'lib/modern_treasury/client.rb', line 94
def payment_references
@payment_references
end
|
97
98
99
|
# File 'lib/modern_treasury/client.rb', line 97
def returns
@returns
end
|
58
59
60
|
# File 'lib/modern_treasury/client.rb', line 58
def routing_details
@routing_details
end
|
100
101
102
|
# File 'lib/modern_treasury/client.rb', line 100
def transactions
@transactions
end
|
103
104
105
|
# File 'lib/modern_treasury/client.rb', line 103
def validations
@validations
end
|
106
107
108
|
# File 'lib/modern_treasury/client.rb', line 106
def virtual_accounts
@virtual_accounts
end
|
#webhook_key ⇒ String?
25
26
27
|
# File 'lib/modern_treasury/client.rb', line 25
def webhook_key
@webhook_key
end
|
Instance Method Details
A test endpoint often used to confirm credentials and headers are being passed in correctly.
151
152
153
154
155
156
157
158
|
# File 'lib/modern_treasury/client.rb', line 151
def ping(params = {})
request(
method: :get,
path: "api/ping",
model: ModernTreasury::PingResponse,
options: params[:request_options]
)
end
|