Class: Lithic::Client

Inherits:
Internal::Transport::BaseClient show all
Defined in:
lib/lithic/client.rb

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"}

Constants inherited from Internal::Transport::BaseClient

Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS

Instance Attribute Summary collapse

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

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(api_key: ENV["LITHIC_API_KEY"], 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`

Parameters:

  • api_key (String, nil) (defaults to: ENV["LITHIC_API_KEY"])

    Defaults to ‘ENV`

  • environment (:production, :sandbox, nil) (defaults to: nil)

    Specifies the environment to use for the API.

  • base_url (String, nil) (defaults to: ENV["LITHIC_BASE_URL"])

    Override the default base URL for the API, e.g.,

  • max_retries (Integer) (defaults to: self.class::DEFAULT_MAX_RETRIES)

    Max number of retries to attempt after a failed retryable request.

  • timeout (Float) (defaults to: self.class::DEFAULT_TIMEOUT_IN_SECONDS)
  • initial_retry_delay (Float) (defaults to: self.class::DEFAULT_INITIAL_RETRY_DELAY)
  • max_retry_delay (Float) (defaults to: self.class::DEFAULT_MAX_RETRY_DELAY)


166
167
168
169
170
171
172
173
174
175
176
177
178
179
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
# File 'lib/lithic/client.rb', line 166

def initialize(
  api_key: ENV["LITHIC_API_KEY"],
  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

  headers = {
    "x-lithic-pagination" => "cursor"
  }

  @api_key = api_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,
    headers: headers
  )

  @accounts = Lithic::Resources::Accounts.new(client: self)
  @account_holders = Lithic::Resources::AccountHolders.new(client: self)
  @auth_rules = Lithic::Resources::AuthRules.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_bulk_orders = Lithic::Resources::CardBulkOrders.new(client: self)
  @balances = Lithic::Resources::Balances.new(client: self)
  @aggregate_balances = Lithic::Resources::AggregateBalances.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)
  @account_activity = Lithic::Resources::AccountActivity.new(client: self)
  @webhooks = Lithic::Resources::Webhooks.new(client: self)
end

Instance Attribute Details

#account_activityLithic::Resources::AccountActivity (readonly)



120
121
122
# File 'lib/lithic/client.rb', line 120

def 
  @account_activity
end

#account_holdersLithic::Resources::AccountHolders (readonly)



30
31
32
# File 'lib/lithic/client.rb', line 30

def 
  @account_holders
end

#accountsLithic::Resources::Accounts (readonly)



27
28
29
# File 'lib/lithic/client.rb', line 27

def accounts
  @accounts
end

#aggregate_balancesLithic::Resources::AggregateBalances (readonly)



54
55
56
# File 'lib/lithic/client.rb', line 54

def aggregate_balances
  @aggregate_balances
end

#api_keyString (readonly)

Returns:

  • (String)


24
25
26
# File 'lib/lithic/client.rb', line 24

def api_key
  @api_key
end

#auth_rulesLithic::Resources::AuthRules (readonly)



33
34
35
# File 'lib/lithic/client.rb', line 33

def auth_rules
  @auth_rules
end

#auth_stream_enrollmentLithic::Resources::AuthStreamEnrollment (readonly)



36
37
38
# File 'lib/lithic/client.rb', line 36

def auth_stream_enrollment
  @auth_stream_enrollment
end

#balancesLithic::Resources::Balances (readonly)



51
52
53
# File 'lib/lithic/client.rb', line 51

def balances
  @balances
end

#book_transfersLithic::Resources::BookTransfers (readonly)



96
97
98
# File 'lib/lithic/client.rb', line 96

def book_transfers
  @book_transfers
end

#card_bulk_ordersLithic::Resources::CardBulkOrders (readonly)



48
49
50
# File 'lib/lithic/client.rb', line 48

def card_bulk_orders
  @card_bulk_orders
end

#card_programsLithic::Resources::CardPrograms (readonly)



90
91
92
# File 'lib/lithic/client.rb', line 90

def card_programs
  @card_programs
end

#cardsLithic::Resources::Cards (readonly)



45
46
47
# File 'lib/lithic/client.rb', line 45

def cards
  @cards
end

#credit_productsLithic::Resources::CreditProducts (readonly)



99
100
101
# File 'lib/lithic/client.rb', line 99

def credit_products
  @credit_products
end

#digital_card_artLithic::Resources::DigitalCardArt (readonly)



93
94
95
# File 'lib/lithic/client.rb', line 93

def digital_card_art
  @digital_card_art
end

#disputesLithic::Resources::Disputes (readonly)



57
58
59
# File 'lib/lithic/client.rb', line 57

def disputes
  @disputes
end

#disputes_v2Lithic::Resources::DisputesV2 (readonly)



60
61
62
# File 'lib/lithic/client.rb', line 60

def disputes_v2
  @disputes_v2
end

#eventsLithic::Resources::Events (readonly)



63
64
65
# File 'lib/lithic/client.rb', line 63

def events
  @events
end

#external_bank_accountsLithic::Resources::ExternalBankAccounts (readonly)



78
79
80
# File 'lib/lithic/client.rb', line 78

def external_bank_accounts
  @external_bank_accounts
end

#external_paymentsLithic::Resources::ExternalPayments (readonly)



102
103
104
# File 'lib/lithic/client.rb', line 102

def external_payments
  @external_payments
end

#financial_accountsLithic::Resources::FinancialAccounts (readonly)



69
70
71
# File 'lib/lithic/client.rb', line 69

def financial_accounts
  @financial_accounts
end

#fraudLithic::Resources::Fraud (readonly)



114
115
116
# File 'lib/lithic/client.rb', line 114

def fraud
  @fraud
end

#funding_eventsLithic::Resources::FundingEvents (readonly)



111
112
113
# File 'lib/lithic/client.rb', line 111

def funding_events
  @funding_events
end

#internal_transactionLithic::Resources::InternalTransaction (readonly)



108
109
110
# File 'lib/lithic/client.rb', line 108

def internal_transaction
  @internal_transaction
end

#management_operationsLithic::Resources::ManagementOperations (readonly)



105
106
107
# File 'lib/lithic/client.rb', line 105

def management_operations
  @management_operations
end

#network_programsLithic::Resources::NetworkPrograms (readonly)



117
118
119
# File 'lib/lithic/client.rb', line 117

def network_programs
  @network_programs
end

#paymentsLithic::Resources::Payments (readonly)



81
82
83
# File 'lib/lithic/client.rb', line 81

def payments
  @payments
end

#reportsLithic::Resources::Reports (readonly)



87
88
89
# File 'lib/lithic/client.rb', line 87

def reports
  @reports
end

#responder_endpointsLithic::Resources::ResponderEndpoints (readonly)



75
76
77
# File 'lib/lithic/client.rb', line 75

def responder_endpoints
  @responder_endpoints
end

#three_dsLithic::Resources::ThreeDS (readonly)



84
85
86
# File 'lib/lithic/client.rb', line 84

def three_ds
  @three_ds
end

#tokenization_decisioningLithic::Resources::TokenizationDecisioning (readonly)



39
40
41
# File 'lib/lithic/client.rb', line 39

def tokenization_decisioning
  @tokenization_decisioning
end

#tokenizationsLithic::Resources::Tokenizations (readonly)



42
43
44
# File 'lib/lithic/client.rb', line 42

def tokenizations
  @tokenizations
end

#transactionsLithic::Resources::Transactions (readonly)



72
73
74
# File 'lib/lithic/client.rb', line 72

def transactions
  @transactions
end

#transfersLithic::Resources::Transfers (readonly)



66
67
68
# File 'lib/lithic/client.rb', line 66

def transfers
  @transfers
end

#webhooksLithic::Resources::Webhooks (readonly)



123
124
125
# File 'lib/lithic/client.rb', line 123

def webhooks
  @webhooks
end

Instance Method Details

#api_status(request_options: {}) ⇒ Lithic::Models::APIStatus

Status of api

Parameters:

Returns:

See Also:



134
135
136
# File 'lib/lithic/client.rb', line 134

def api_status(params = {})
  request(method: :get, path: "v1/status", model: Lithic::APIStatus, options: params[:request_options])
end