Class: Lithic::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
- ENVIRONMENTS =
rubocop:disable Style/MutableConstant
{production: "https://api.lithic.com", sandbox: "https://sandbox.lithic.com"}
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: ENV["LITHIC_API_KEY"], webhook_secret: ENV["LITHIC_WEBHOOK_SECRET"], environment: nil, base_url: ENV["LITHIC_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.
Each environment maps to a different base URL:
‘“api.example.com/v2/”`. Defaults to `ENV`
180
181
182
183
184
185
186
187
188
189
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
|
# File 'lib/lithic/client.rb', line 180
def initialize(
api_key: ENV["LITHIC_API_KEY"],
webhook_secret: ENV["LITHIC_WEBHOOK_SECRET"],
environment: nil,
base_url: ENV["LITHIC_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 ||= Lithic::Client::ENVIRONMENTS.fetch(environment&.to_sym || :production) do
message = "environment must be one of #{Lithic::Client::ENVIRONMENTS.keys}, got #{environment}"
raise ArgumentError.new(message)
end
if api_key.nil?
raise ArgumentError.new("api_key is required, and can be set via environ: \"LITHIC_API_KEY\"")
end
= {}
= ENV["LITHIC_CUSTOM_HEADERS"]
unless .nil?
parsed = {}
.split("\n").each do |line|
colon = line.index(":")
unless colon.nil?
parsed[line[0...colon].strip] = line[(colon + 1)..].strip
end
end
= parsed.merge()
end
@api_key = api_key.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:
)
@accounts = Lithic::Resources::Accounts.new(client: self)
@account_holders = Lithic::Resources::AccountHolders.new(client: self)
@auth_rules = Lithic::Resources::AuthRules.new(client: self)
@transaction_monitoring = Lithic::Resources::TransactionMonitoring.new(client: self)
@auth_stream_enrollment = Lithic::Resources::AuthStreamEnrollment.new(client: self)
@tokenization_decisioning = Lithic::Resources::TokenizationDecisioning.new(client: self)
@tokenizations = Lithic::Resources::Tokenizations.new(client: self)
@cards = Lithic::Resources::Cards.new(client: self)
@card_authorizations = Lithic::Resources::CardAuthorizations.new(client: self)
@card_bulk_orders = Lithic::Resources::CardBulkOrders.new(client: self)
@balances = Lithic::Resources::Balances.new(client: self)
@disputes = Lithic::Resources::Disputes.new(client: self)
@disputes_v2 = Lithic::Resources::DisputesV2.new(client: self)
@events = Lithic::Resources::Events.new(client: self)
@transfers = Lithic::Resources::Transfers.new(client: self)
@financial_accounts = Lithic::Resources::FinancialAccounts.new(client: self)
@transactions = Lithic::Resources::Transactions.new(client: self)
@responder_endpoints = Lithic::Resources::ResponderEndpoints.new(client: self)
@external_bank_accounts = Lithic::Resources::ExternalBankAccounts.new(client: self)
@payments = Lithic::Resources::Payments.new(client: self)
@three_ds = Lithic::Resources::ThreeDS.new(client: self)
@reports = Lithic::Resources::Reports.new(client: self)
@card_programs = Lithic::Resources::CardPrograms.new(client: self)
@digital_card_art = Lithic::Resources::DigitalCardArt.new(client: self)
@book_transfers = Lithic::Resources::BookTransfers.new(client: self)
@credit_products = Lithic::Resources::CreditProducts.new(client: self)
@external_payments = Lithic::Resources::ExternalPayments.new(client: self)
@management_operations = Lithic::Resources::ManagementOperations.new(client: self)
@internal_transaction = Lithic::Resources::InternalTransaction.new(client: self)
@funding_events = Lithic::Resources::FundingEvents.new(client: self)
@fraud = Lithic::Resources::Fraud.new(client: self)
@network_programs = Lithic::Resources::NetworkPrograms.new(client: self)
@holds = Lithic::Resources::Holds.new(client: self)
@account_activity = Lithic::Resources::AccountActivity.new(client: self)
@transfer_limits = Lithic::Resources::TransferLimits.new(client: self)
@webhooks = Lithic::Resources::Webhooks.new(client: self)
end
|
Instance Attribute Details
129
130
131
|
# File 'lib/lithic/client.rb', line 129
def account_activity
@account_activity
end
|
33
34
35
|
# File 'lib/lithic/client.rb', line 33
def account_holders
@account_holders
end
|
30
31
32
|
# File 'lib/lithic/client.rb', line 30
def accounts
@accounts
end
|
#api_key ⇒ String
24
25
26
|
# File 'lib/lithic/client.rb', line 24
def api_key
@api_key
end
|
36
37
38
|
# File 'lib/lithic/client.rb', line 36
def auth_rules
@auth_rules
end
|
42
43
44
|
# File 'lib/lithic/client.rb', line 42
def auth_stream_enrollment
@auth_stream_enrollment
end
|
60
61
62
|
# File 'lib/lithic/client.rb', line 60
def balances
@balances
end
|
102
103
104
|
# File 'lib/lithic/client.rb', line 102
def book_transfers
@book_transfers
end
|
54
55
56
|
# File 'lib/lithic/client.rb', line 54
def card_authorizations
@card_authorizations
end
|
57
58
59
|
# File 'lib/lithic/client.rb', line 57
def card_bulk_orders
@card_bulk_orders
end
|
96
97
98
|
# File 'lib/lithic/client.rb', line 96
def card_programs
@card_programs
end
|
51
52
53
|
# File 'lib/lithic/client.rb', line 51
def cards
@cards
end
|
105
106
107
|
# File 'lib/lithic/client.rb', line 105
def credit_products
@credit_products
end
|
99
100
101
|
# File 'lib/lithic/client.rb', line 99
def digital_card_art
@digital_card_art
end
|
63
64
65
|
# File 'lib/lithic/client.rb', line 63
def disputes
@disputes
end
|
66
67
68
|
# File 'lib/lithic/client.rb', line 66
def disputes_v2
@disputes_v2
end
|
69
70
71
|
# File 'lib/lithic/client.rb', line 69
def events
@events
end
|
84
85
86
|
# File 'lib/lithic/client.rb', line 84
def external_bank_accounts
@external_bank_accounts
end
|
108
109
110
|
# File 'lib/lithic/client.rb', line 108
def external_payments
@external_payments
end
|
75
76
77
|
# File 'lib/lithic/client.rb', line 75
def financial_accounts
@financial_accounts
end
|
120
121
122
|
# File 'lib/lithic/client.rb', line 120
def fraud
@fraud
end
|
117
118
119
|
# File 'lib/lithic/client.rb', line 117
def funding_events
@funding_events
end
|
126
127
128
|
# File 'lib/lithic/client.rb', line 126
def holds
@holds
end
|
114
115
116
|
# File 'lib/lithic/client.rb', line 114
def internal_transaction
@internal_transaction
end
|
111
112
113
|
# File 'lib/lithic/client.rb', line 111
def management_operations
@management_operations
end
|
123
124
125
|
# File 'lib/lithic/client.rb', line 123
def network_programs
@network_programs
end
|
87
88
89
|
# File 'lib/lithic/client.rb', line 87
def payments
@payments
end
|
93
94
95
|
# File 'lib/lithic/client.rb', line 93
def reports
@reports
end
|
81
82
83
|
# File 'lib/lithic/client.rb', line 81
def responder_endpoints
@responder_endpoints
end
|
90
91
92
|
# File 'lib/lithic/client.rb', line 90
def three_ds
@three_ds
end
|
45
46
47
|
# File 'lib/lithic/client.rb', line 45
def tokenization_decisioning
@tokenization_decisioning
end
|
48
49
50
|
# File 'lib/lithic/client.rb', line 48
def tokenizations
@tokenizations
end
|
39
40
41
|
# File 'lib/lithic/client.rb', line 39
def transaction_monitoring
@transaction_monitoring
end
|
78
79
80
|
# File 'lib/lithic/client.rb', line 78
def transactions
@transactions
end
|
132
133
134
|
# File 'lib/lithic/client.rb', line 132
def transfer_limits
@transfer_limits
end
|
72
73
74
|
# File 'lib/lithic/client.rb', line 72
def transfers
@transfers
end
|
#webhook_secret ⇒ String?
27
28
29
|
# File 'lib/lithic/client.rb', line 27
def webhook_secret
@webhook_secret
end
|
135
136
137
|
# File 'lib/lithic/client.rb', line 135
def webhooks
@webhooks
end
|
Instance Method Details
146
147
148
|
# File 'lib/lithic/client.rb', line 146
def api_status(params = {})
request(method: :get, path: "v1/status", model: Lithic::APIStatus, options: params[:request_options])
end
|