Class: Batches::Client

Inherits:
Object
  • Object
show all
Includes:
CoreLibrary
Defined in:
lib/batches/client.rb

Overview

batches client class.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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, config: nil) ⇒ Client

Returns a new instance of Client.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/batches/client.rb', line 34

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,
  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
              )
            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)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/batches/client.rb', line 10

def config
  @config
end

Class Method Details

.from_env(**overrides) ⇒ Object

Creates a client directly from environment variables.



66
67
68
69
70
# File 'lib/batches/client.rb', line 66

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

#close_a_batchCloseABatchApi

Access to close_a_batch controller.

Returns:



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

def close_a_batch
  @close_a_batch ||= CloseABatchApi.new @global_configuration
end

#get_a_batchGetABatchApi

Access to get_a_batch controller.

Returns:



18
19
20
# File 'lib/batches/client.rb', line 18

def get_a_batch
  @get_a_batch ||= GetABatchApi.new @global_configuration
end

#get_transactions_within_a_batchGetTransactionsWithinABatchApi

Access to get_transactions_within_a_batch controller.

Returns:



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

def get_transactions_within_a_batch
  @get_transactions_within_a_batch ||= GetTransactionsWithinABatchApi.new @global_configuration
end

#user_agent_detailObject



12
13
14
# File 'lib/batches/client.rb', line 12

def user_agent_detail
  config.user_agent_detail
end