Class: ModernTreasury::Client
- Inherits:
-
Object
- Object
- ModernTreasury::Client
- Includes:
- CoreLibrary
- Defined in:
- lib/modern_treasury/client.rb
Overview
modern_treasury client class.
Instance Attribute Summary collapse
-
#auth_managers ⇒ Object
readonly
Returns the value of attribute auth_managers.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
-
.from_env(**overrides) ⇒ Object
Creates a client directly from environment variables.
Instance Method Summary collapse
-
#account_collection_flow ⇒ AccountCollectionFlowApi
Access to account_collection_flow controller.
-
#account_detail ⇒ AccountDetailApi
Access to account_detail controller.
-
#balance_report ⇒ BalanceReportApi
Access to balance_report controller.
-
#connection ⇒ ConnectionApi
Access to connection controller.
-
#counterparty ⇒ CounterpartyApi
Access to counterparty controller.
-
#document ⇒ DocumentApi
Access to document controller.
-
#event ⇒ EventApi
Access to event controller.
-
#expected_payment ⇒ ExpectedPaymentApi
Access to expected_payment controller.
-
#external_account ⇒ ExternalAccountApi
Access to external_account controller.
-
#incoming_payment_detail ⇒ IncomingPaymentDetailApi
Access to incoming_payment_detail controller.
-
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 30, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: Environment::PRODUCTION, basic_auth_credentials: nil, config: nil) ⇒ Client
constructor
A new instance of Client.
-
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
-
#internal_account ⇒ InternalAccountApi
Access to internal_account controller.
-
#invoice ⇒ InvoiceApi
Access to invoice controller.
-
#invoice_line_item ⇒ InvoiceLineItemApi
Access to invoice_line_item controller.
-
#ledger ⇒ LedgerApi
Access to ledger controller.
-
#ledger_account ⇒ LedgerAccountApi
Access to ledger_account controller.
-
#ledger_account_category ⇒ LedgerAccountCategoryApi
Access to ledger_account_category controller.
-
#ledger_account_payout ⇒ LedgerAccountPayoutApi
Access to ledger_account_payout controller.
-
#ledger_account_statement ⇒ LedgerAccountStatementApi
Access to ledger_account_statement controller.
-
#ledger_entry ⇒ LedgerEntryApi
Access to ledger_entry controller.
-
#ledger_event_handler ⇒ LedgerEventHandlerApi
Access to ledger_event_handler controller.
-
#ledger_transaction ⇒ LedgerTransactionApi
Access to ledger_transaction controller.
-
#ledgerable_event ⇒ LedgerableEventApi
Access to ledgerable_event controller.
-
#line_item ⇒ LineItemApi
Access to line_item controller.
-
#mreturn ⇒ ReturnApi
Access to mreturn controller.
-
#paper_item ⇒ PaperItemApi
Access to paper_item controller.
-
#payment_flow ⇒ PaymentFlowApi
Access to payment_flow controller.
-
#payment_order ⇒ PaymentOrderApi
Access to payment_order controller.
-
#payment_reference ⇒ PaymentReferenceApi
Access to payment_reference controller.
-
#ping ⇒ PingApi
Access to ping controller.
-
#reversal ⇒ ReversalApi
Access to reversal controller.
-
#routing_detail ⇒ RoutingDetailApi
Access to routing_detail controller.
-
#transaction ⇒ TransactionApi
Access to transaction controller.
-
#transaction_line_item ⇒ TransactionLineItemApi
Access to transaction_line_item controller.
- #user_agent_detail ⇒ Object
-
#validation ⇒ ValidationApi
Access to validation controller.
-
#virtual_account ⇒ VirtualAccountApi
Access to virtual_account controller.
Constructor Details
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 30, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: Environment::PRODUCTION, basic_auth_credentials: nil, config: nil) ⇒ Client
Returns a new instance of Client.
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 |
# File 'lib/modern_treasury/client.rb', line 226 def initialize( connection: nil, adapter: :net_http_persistent, timeout: 30, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put], http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: Environment::PRODUCTION, basic_auth_credentials: nil, config: nil ) @config = if config.nil? Configuration.new( connection: connection, adapter: adapter, timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, retry_statuses: retry_statuses, retry_methods: retry_methods, http_callback: http_callback, proxy_settings: proxy_settings, logging_configuration: logging_configuration, environment: environment, basic_auth_credentials: basic_auth_credentials ) else config end user_agent_params = BaseApi.user_agent_parameters @global_configuration = GlobalConfiguration.new(client_configuration: @config) .base_uri_executor(@config.method(:get_base_uri)) .global_errors(BaseApi::GLOBAL_ERRORS) .user_agent(BaseApi.user_agent, agent_parameters: user_agent_params) initialize_auth_managers(@global_configuration) @global_configuration = @global_configuration.auth_managers(@auth_managers) end |
Instance Attribute Details
#auth_managers ⇒ Object (readonly)
Returns the value of attribute auth_managers.
10 11 12 |
# File 'lib/modern_treasury/client.rb', line 10 def auth_managers @auth_managers end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/modern_treasury/client.rb', line 10 def config @config end |
Class Method Details
.from_env(**overrides) ⇒ Object
Creates a client directly from environment variables.
271 272 273 274 275 |
# File 'lib/modern_treasury/client.rb', line 271 def self.from_env(**overrides) default_config = Configuration.build_default_config_from_env new_config = default_config.clone_with(**overrides) new(config: new_config) end |
Instance Method Details
#account_collection_flow ⇒ AccountCollectionFlowApi
Access to account_collection_flow controller.
216 217 218 |
# File 'lib/modern_treasury/client.rb', line 216 def account_collection_flow @account_collection_flow ||= AccountCollectionFlowApi.new @global_configuration end |
#account_detail ⇒ AccountDetailApi
Access to account_detail controller.
18 19 20 |
# File 'lib/modern_treasury/client.rb', line 18 def account_detail @account_detail ||= AccountDetailApi.new @global_configuration end |
#balance_report ⇒ BalanceReportApi
Access to balance_report controller.
24 25 26 |
# File 'lib/modern_treasury/client.rb', line 24 def balance_report @balance_report ||= BalanceReportApi.new @global_configuration end |
#connection ⇒ ConnectionApi
Access to connection controller.
30 31 32 |
# File 'lib/modern_treasury/client.rb', line 30 def connection @connection ||= ConnectionApi.new @global_configuration end |
#counterparty ⇒ CounterpartyApi
Access to counterparty controller.
36 37 38 |
# File 'lib/modern_treasury/client.rb', line 36 def counterparty @counterparty ||= CounterpartyApi.new @global_configuration end |
#document ⇒ DocumentApi
Access to document controller.
42 43 44 |
# File 'lib/modern_treasury/client.rb', line 42 def document @document ||= DocumentApi.new @global_configuration end |
#event ⇒ EventApi
Access to event controller.
48 49 50 |
# File 'lib/modern_treasury/client.rb', line 48 def event @event ||= EventApi.new @global_configuration end |
#expected_payment ⇒ ExpectedPaymentApi
Access to expected_payment controller.
54 55 56 |
# File 'lib/modern_treasury/client.rb', line 54 def expected_payment @expected_payment ||= ExpectedPaymentApi.new @global_configuration end |
#external_account ⇒ ExternalAccountApi
Access to external_account controller.
60 61 62 |
# File 'lib/modern_treasury/client.rb', line 60 def external_account @external_account ||= ExternalAccountApi.new @global_configuration end |
#incoming_payment_detail ⇒ IncomingPaymentDetailApi
Access to incoming_payment_detail controller.
66 67 68 |
# File 'lib/modern_treasury/client.rb', line 66 def incoming_payment_detail @incoming_payment_detail ||= IncomingPaymentDetailApi.new @global_configuration end |
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
263 264 265 266 267 268 |
# File 'lib/modern_treasury/client.rb', line 263 def initialize_auth_managers(global_config) @auth_managers = {} http_client_config = global_config.client_configuration %w[basic_auth].each { |auth| @auth_managers[auth] = nil } @auth_managers['basic_auth'] = BasicAuth.new(http_client_config.basic_auth_credentials) end |
#internal_account ⇒ InternalAccountApi
Access to internal_account controller.
72 73 74 |
# File 'lib/modern_treasury/client.rb', line 72 def internal_account @internal_account ||= InternalAccountApi.new @global_configuration end |
#invoice ⇒ InvoiceApi
Access to invoice controller.
84 85 86 |
# File 'lib/modern_treasury/client.rb', line 84 def invoice @invoice ||= InvoiceApi.new @global_configuration end |
#invoice_line_item ⇒ InvoiceLineItemApi
Access to invoice_line_item controller.
78 79 80 |
# File 'lib/modern_treasury/client.rb', line 78 def invoice_line_item @invoice_line_item ||= InvoiceLineItemApi.new @global_configuration end |
#ledger ⇒ LedgerApi
Access to ledger controller.
138 139 140 |
# File 'lib/modern_treasury/client.rb', line 138 def ledger @ledger ||= LedgerApi.new @global_configuration end |
#ledger_account ⇒ LedgerAccountApi
Access to ledger_account controller.
108 109 110 |
# File 'lib/modern_treasury/client.rb', line 108 def ledger_account @ledger_account ||= LedgerAccountApi.new @global_configuration end |
#ledger_account_category ⇒ LedgerAccountCategoryApi
Access to ledger_account_category controller.
90 91 92 |
# File 'lib/modern_treasury/client.rb', line 90 def ledger_account_category @ledger_account_category ||= LedgerAccountCategoryApi.new @global_configuration end |
#ledger_account_payout ⇒ LedgerAccountPayoutApi
Access to ledger_account_payout controller.
96 97 98 |
# File 'lib/modern_treasury/client.rb', line 96 def ledger_account_payout @ledger_account_payout ||= LedgerAccountPayoutApi.new @global_configuration end |
#ledger_account_statement ⇒ LedgerAccountStatementApi
Access to ledger_account_statement controller.
102 103 104 |
# File 'lib/modern_treasury/client.rb', line 102 def ledger_account_statement @ledger_account_statement ||= LedgerAccountStatementApi.new @global_configuration end |
#ledger_entry ⇒ LedgerEntryApi
Access to ledger_entry controller.
114 115 116 |
# File 'lib/modern_treasury/client.rb', line 114 def ledger_entry @ledger_entry ||= LedgerEntryApi.new @global_configuration end |
#ledger_event_handler ⇒ LedgerEventHandlerApi
Access to ledger_event_handler controller.
120 121 122 |
# File 'lib/modern_treasury/client.rb', line 120 def ledger_event_handler @ledger_event_handler ||= LedgerEventHandlerApi.new @global_configuration end |
#ledger_transaction ⇒ LedgerTransactionApi
Access to ledger_transaction controller.
126 127 128 |
# File 'lib/modern_treasury/client.rb', line 126 def ledger_transaction @ledger_transaction ||= LedgerTransactionApi.new @global_configuration end |
#ledgerable_event ⇒ LedgerableEventApi
Access to ledgerable_event controller.
132 133 134 |
# File 'lib/modern_treasury/client.rb', line 132 def ledgerable_event @ledgerable_event ||= LedgerableEventApi.new @global_configuration end |
#line_item ⇒ LineItemApi
Access to line_item controller.
144 145 146 |
# File 'lib/modern_treasury/client.rb', line 144 def line_item @line_item ||= LineItemApi.new @global_configuration end |
#mreturn ⇒ ReturnApi
Access to mreturn controller.
174 175 176 |
# File 'lib/modern_treasury/client.rb', line 174 def mreturn @mreturn ||= ReturnApi.new @global_configuration end |
#paper_item ⇒ PaperItemApi
Access to paper_item controller.
150 151 152 |
# File 'lib/modern_treasury/client.rb', line 150 def paper_item @paper_item ||= PaperItemApi.new @global_configuration end |
#payment_flow ⇒ PaymentFlowApi
Access to payment_flow controller.
222 223 224 |
# File 'lib/modern_treasury/client.rb', line 222 def payment_flow @payment_flow ||= PaymentFlowApi.new @global_configuration end |
#payment_order ⇒ PaymentOrderApi
Access to payment_order controller.
156 157 158 |
# File 'lib/modern_treasury/client.rb', line 156 def payment_order @payment_order ||= PaymentOrderApi.new @global_configuration end |
#payment_reference ⇒ PaymentReferenceApi
Access to payment_reference controller.
162 163 164 |
# File 'lib/modern_treasury/client.rb', line 162 def payment_reference @payment_reference ||= PaymentReferenceApi.new @global_configuration end |
#ping ⇒ PingApi
Access to ping controller.
168 169 170 |
# File 'lib/modern_treasury/client.rb', line 168 def ping @ping ||= PingApi.new @global_configuration end |
#reversal ⇒ ReversalApi
Access to reversal controller.
180 181 182 |
# File 'lib/modern_treasury/client.rb', line 180 def reversal @reversal ||= ReversalApi.new @global_configuration end |
#routing_detail ⇒ RoutingDetailApi
Access to routing_detail controller.
186 187 188 |
# File 'lib/modern_treasury/client.rb', line 186 def routing_detail @routing_detail ||= RoutingDetailApi.new @global_configuration end |
#transaction ⇒ TransactionApi
Access to transaction controller.
198 199 200 |
# File 'lib/modern_treasury/client.rb', line 198 def transaction @transaction ||= TransactionApi.new @global_configuration end |
#transaction_line_item ⇒ TransactionLineItemApi
Access to transaction_line_item controller.
192 193 194 |
# File 'lib/modern_treasury/client.rb', line 192 def transaction_line_item @transaction_line_item ||= TransactionLineItemApi.new @global_configuration end |
#user_agent_detail ⇒ Object
12 13 14 |
# File 'lib/modern_treasury/client.rb', line 12 def user_agent_detail config.user_agent_detail end |
#validation ⇒ ValidationApi
Access to validation controller.
204 205 206 |
# File 'lib/modern_treasury/client.rb', line 204 def validation @validation ||= ValidationApi.new @global_configuration end |
#virtual_account ⇒ VirtualAccountApi
Access to virtual_account controller.
210 211 212 |
# File 'lib/modern_treasury/client.rb', line 210 def virtual_account @virtual_account ||= VirtualAccountApi.new @global_configuration end |