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 ⇒ AccountCollectionFlowController
Access to account_collection_flow controller.
-
#account_detail ⇒ AccountDetailController
Access to account_detail controller.
-
#balance_report ⇒ BalanceReportController
Access to balance_report controller.
-
#connection ⇒ ConnectionController
Access to connection controller.
-
#counterparty ⇒ CounterpartyController
Access to counterparty controller.
-
#document ⇒ DocumentController
Access to document controller.
-
#event ⇒ EventController
Access to event controller.
-
#expected_payment ⇒ ExpectedPaymentController
Access to expected_payment controller.
-
#external_account ⇒ ExternalAccountController
Access to external_account controller.
-
#incoming_payment_detail ⇒ IncomingPaymentDetailController
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 ⇒ InternalAccountController
Access to internal_account controller.
-
#invoice ⇒ InvoiceController
Access to invoice controller.
-
#invoice_line_item ⇒ InvoiceLineItemController
Access to invoice_line_item controller.
-
#ledger ⇒ LedgerController
Access to ledger controller.
-
#ledger_account ⇒ LedgerAccountController
Access to ledger_account controller.
-
#ledger_account_category ⇒ LedgerAccountCategoryController
Access to ledger_account_category controller.
-
#ledger_account_payout ⇒ LedgerAccountPayoutController
Access to ledger_account_payout controller.
-
#ledger_account_statement ⇒ LedgerAccountStatementController
Access to ledger_account_statement controller.
-
#ledger_entry ⇒ LedgerEntryController
Access to ledger_entry controller.
-
#ledger_event_handler ⇒ LedgerEventHandlerController
Access to ledger_event_handler controller.
-
#ledger_transaction ⇒ LedgerTransactionController
Access to ledger_transaction controller.
-
#ledgerable_event ⇒ LedgerableEventController
Access to ledgerable_event controller.
-
#line_item ⇒ LineItemController
Access to line_item controller.
-
#mreturn ⇒ ReturnController
Access to mreturn controller.
-
#paper_item ⇒ PaperItemController
Access to paper_item controller.
-
#payment_flow ⇒ PaymentFlowController
Access to payment_flow controller.
-
#payment_order ⇒ PaymentOrderController
Access to payment_order controller.
-
#payment_reference ⇒ PaymentReferenceController
Access to payment_reference controller.
-
#ping ⇒ PingController
Access to ping controller.
-
#reversal ⇒ ReversalController
Access to reversal controller.
-
#routing_detail ⇒ RoutingDetailController
Access to routing_detail controller.
-
#transaction ⇒ TransactionController
Access to transaction controller.
-
#transaction_line_item ⇒ TransactionLineItemController
Access to transaction_line_item controller.
- #user_agent_detail ⇒ Object
-
#validation ⇒ ValidationController
Access to validation controller.
-
#virtual_account ⇒ VirtualAccountController
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 = BaseController.user_agent_parameters @global_configuration = GlobalConfiguration.new(client_configuration: @config) .base_uri_executor(@config.method(:get_base_uri)) .global_errors(BaseController::GLOBAL_ERRORS) .user_agent(BaseController.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 ⇒ AccountCollectionFlowController
Access to account_collection_flow controller.
216 217 218 |
# File 'lib/modern_treasury/client.rb', line 216 def account_collection_flow @account_collection_flow ||= AccountCollectionFlowController.new @global_configuration end |
#account_detail ⇒ AccountDetailController
Access to account_detail controller.
18 19 20 |
# File 'lib/modern_treasury/client.rb', line 18 def account_detail @account_detail ||= AccountDetailController.new @global_configuration end |
#balance_report ⇒ BalanceReportController
Access to balance_report controller.
24 25 26 |
# File 'lib/modern_treasury/client.rb', line 24 def balance_report @balance_report ||= BalanceReportController.new @global_configuration end |
#connection ⇒ ConnectionController
Access to connection controller.
30 31 32 |
# File 'lib/modern_treasury/client.rb', line 30 def connection @connection ||= ConnectionController.new @global_configuration end |
#counterparty ⇒ CounterpartyController
Access to counterparty controller.
36 37 38 |
# File 'lib/modern_treasury/client.rb', line 36 def counterparty @counterparty ||= CounterpartyController.new @global_configuration end |
#document ⇒ DocumentController
Access to document controller.
42 43 44 |
# File 'lib/modern_treasury/client.rb', line 42 def document @document ||= DocumentController.new @global_configuration end |
#event ⇒ EventController
Access to event controller.
48 49 50 |
# File 'lib/modern_treasury/client.rb', line 48 def event @event ||= EventController.new @global_configuration end |
#expected_payment ⇒ ExpectedPaymentController
Access to expected_payment controller.
54 55 56 |
# File 'lib/modern_treasury/client.rb', line 54 def expected_payment @expected_payment ||= ExpectedPaymentController.new @global_configuration end |
#external_account ⇒ ExternalAccountController
Access to external_account controller.
60 61 62 |
# File 'lib/modern_treasury/client.rb', line 60 def external_account @external_account ||= ExternalAccountController.new @global_configuration end |
#incoming_payment_detail ⇒ IncomingPaymentDetailController
Access to incoming_payment_detail controller.
66 67 68 |
# File 'lib/modern_treasury/client.rb', line 66 def incoming_payment_detail @incoming_payment_detail ||= IncomingPaymentDetailController.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 ⇒ InternalAccountController
Access to internal_account controller.
72 73 74 |
# File 'lib/modern_treasury/client.rb', line 72 def internal_account @internal_account ||= InternalAccountController.new @global_configuration end |
#invoice ⇒ InvoiceController
Access to invoice controller.
84 85 86 |
# File 'lib/modern_treasury/client.rb', line 84 def invoice @invoice ||= InvoiceController.new @global_configuration end |
#invoice_line_item ⇒ InvoiceLineItemController
Access to invoice_line_item controller.
78 79 80 |
# File 'lib/modern_treasury/client.rb', line 78 def invoice_line_item @invoice_line_item ||= InvoiceLineItemController.new @global_configuration end |
#ledger ⇒ LedgerController
Access to ledger controller.
138 139 140 |
# File 'lib/modern_treasury/client.rb', line 138 def ledger @ledger ||= LedgerController.new @global_configuration end |
#ledger_account ⇒ LedgerAccountController
Access to ledger_account controller.
108 109 110 |
# File 'lib/modern_treasury/client.rb', line 108 def ledger_account @ledger_account ||= LedgerAccountController.new @global_configuration end |
#ledger_account_category ⇒ LedgerAccountCategoryController
Access to ledger_account_category controller.
90 91 92 |
# File 'lib/modern_treasury/client.rb', line 90 def ledger_account_category @ledger_account_category ||= LedgerAccountCategoryController.new @global_configuration end |
#ledger_account_payout ⇒ LedgerAccountPayoutController
Access to ledger_account_payout controller.
96 97 98 |
# File 'lib/modern_treasury/client.rb', line 96 def ledger_account_payout @ledger_account_payout ||= LedgerAccountPayoutController.new @global_configuration end |
#ledger_account_statement ⇒ LedgerAccountStatementController
Access to ledger_account_statement controller.
102 103 104 |
# File 'lib/modern_treasury/client.rb', line 102 def ledger_account_statement @ledger_account_statement ||= LedgerAccountStatementController.new @global_configuration end |
#ledger_entry ⇒ LedgerEntryController
Access to ledger_entry controller.
114 115 116 |
# File 'lib/modern_treasury/client.rb', line 114 def ledger_entry @ledger_entry ||= LedgerEntryController.new @global_configuration end |
#ledger_event_handler ⇒ LedgerEventHandlerController
Access to ledger_event_handler controller.
120 121 122 |
# File 'lib/modern_treasury/client.rb', line 120 def ledger_event_handler @ledger_event_handler ||= LedgerEventHandlerController.new @global_configuration end |
#ledger_transaction ⇒ LedgerTransactionController
Access to ledger_transaction controller.
126 127 128 |
# File 'lib/modern_treasury/client.rb', line 126 def ledger_transaction @ledger_transaction ||= LedgerTransactionController.new @global_configuration end |
#ledgerable_event ⇒ LedgerableEventController
Access to ledgerable_event controller.
132 133 134 |
# File 'lib/modern_treasury/client.rb', line 132 def ledgerable_event @ledgerable_event ||= LedgerableEventController.new @global_configuration end |
#line_item ⇒ LineItemController
Access to line_item controller.
144 145 146 |
# File 'lib/modern_treasury/client.rb', line 144 def line_item @line_item ||= LineItemController.new @global_configuration end |
#mreturn ⇒ ReturnController
Access to mreturn controller.
174 175 176 |
# File 'lib/modern_treasury/client.rb', line 174 def mreturn @mreturn ||= ReturnController.new @global_configuration end |
#paper_item ⇒ PaperItemController
Access to paper_item controller.
150 151 152 |
# File 'lib/modern_treasury/client.rb', line 150 def paper_item @paper_item ||= PaperItemController.new @global_configuration end |
#payment_flow ⇒ PaymentFlowController
Access to payment_flow controller.
222 223 224 |
# File 'lib/modern_treasury/client.rb', line 222 def payment_flow @payment_flow ||= PaymentFlowController.new @global_configuration end |
#payment_order ⇒ PaymentOrderController
Access to payment_order controller.
156 157 158 |
# File 'lib/modern_treasury/client.rb', line 156 def payment_order @payment_order ||= PaymentOrderController.new @global_configuration end |
#payment_reference ⇒ PaymentReferenceController
Access to payment_reference controller.
162 163 164 |
# File 'lib/modern_treasury/client.rb', line 162 def payment_reference @payment_reference ||= PaymentReferenceController.new @global_configuration end |
#ping ⇒ PingController
Access to ping controller.
168 169 170 |
# File 'lib/modern_treasury/client.rb', line 168 def ping @ping ||= PingController.new @global_configuration end |
#reversal ⇒ ReversalController
Access to reversal controller.
180 181 182 |
# File 'lib/modern_treasury/client.rb', line 180 def reversal @reversal ||= ReversalController.new @global_configuration end |
#routing_detail ⇒ RoutingDetailController
Access to routing_detail controller.
186 187 188 |
# File 'lib/modern_treasury/client.rb', line 186 def routing_detail @routing_detail ||= RoutingDetailController.new @global_configuration end |
#transaction ⇒ TransactionController
Access to transaction controller.
198 199 200 |
# File 'lib/modern_treasury/client.rb', line 198 def transaction @transaction ||= TransactionController.new @global_configuration end |
#transaction_line_item ⇒ TransactionLineItemController
Access to transaction_line_item controller.
192 193 194 |
# File 'lib/modern_treasury/client.rb', line 192 def transaction_line_item @transaction_line_item ||= TransactionLineItemController.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 ⇒ ValidationController
Access to validation controller.
204 205 206 |
# File 'lib/modern_treasury/client.rb', line 204 def validation @validation ||= ValidationController.new @global_configuration end |
#virtual_account ⇒ VirtualAccountController
Access to virtual_account controller.
210 211 212 |
# File 'lib/modern_treasury/client.rb', line 210 def virtual_account @virtual_account ||= VirtualAccountController.new @global_configuration end |