Class: ApimaticCalculator::Client
- Inherits:
-
Object
- Object
- ApimaticCalculator::Client
- Includes:
- CoreLibrary
- Defined in:
- lib/apimatic_calculator/client.rb
Overview
apimatic_calculator client class.
Instance Attribute Summary collapse
-
#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
-
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 60, 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, environment: Environment::PRODUCTION, config: nil) ⇒ Client
constructor
A new instance of Client.
-
#simple_calculator ⇒ SimpleCalculatorController
Access to simple_calculator controller.
- #user_agent_detail ⇒ Object
Constructor Details
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 60, 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, environment: Environment::PRODUCTION, config: nil) ⇒ Client
Returns a new instance of Client.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/apimatic_calculator/client.rb', line 22 def initialize( connection: nil, adapter: :net_http_persistent, timeout: 60, 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, 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, environment: environment) else config end @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) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/apimatic_calculator/client.rb', line 10 def config @config end |
Class Method Details
.from_env(**overrides) ⇒ Object
Creates a client directly from environment variables.
50 51 52 53 54 |
# File 'lib/apimatic_calculator/client.rb', line 50 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
#simple_calculator ⇒ SimpleCalculatorController
Access to simple_calculator controller.
18 19 20 |
# File 'lib/apimatic_calculator/client.rb', line 18 def simple_calculator @simple_calculator ||= SimpleCalculatorController.new @global_configuration end |
#user_agent_detail ⇒ Object
12 13 14 |
# File 'lib/apimatic_calculator/client.rb', line 12 def user_agent_detail config.user_agent_detail end |