Module: TelphinApi::Configuration
- Included in:
- TelphinApi
- Defined in:
- lib/telphin_api/configuration.rb
Overview
Note:
TelphinApi::Configuration
extends TelphinApi
so these methods should be called from the latter.
General configuration module.
Constant Summary collapse
- OPTION_NAMES =
Available options.
[ :app_key, :app_secret, :site, :adapter, :faraday_options, :max_retries, :logger, :log_requests, :log_errors, :log_responses, ]
- DEFAULT_ADAPTER =
Default HTTP adapter.
Faraday.default_adapter
- DEFAULT_HTTP_VERB =
Default HTTP verb for API methods.
:post
- DEFAULT_MAX_RETRIES =
Default max retries count.
2
- DEFAULT_LOGGER_OPTIONS =
Logger default options.
{ requests: true, errors: true, responses: false }
- DEFAULT_URL =
Default url for site api
'https://pbx.telphin.ru/uapi'
Class Method Summary collapse
-
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
A global configuration set via the block.
-
#reset ⇒ Object
Reset all configuration options to defaults.
Class Method Details
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
71 72 73 |
# File 'lib/telphin_api/configuration.rb', line 71 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
A global configuration set via the block.
53 54 55 56 |
# File 'lib/telphin_api/configuration.rb', line 53 def configure yield self if block_given? self end |
#reset ⇒ Object
Reset all configuration options to defaults.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/telphin_api/configuration.rb', line 59 def reset @site = DEFAULT_URL @adapter = DEFAULT_ADAPTER @faraday_options = {} @max_retries = DEFAULT_MAX_RETRIES @logger = ::Logger.new(STDOUT) @log_requests = DEFAULT_LOGGER_OPTIONS[:requests] @log_errors = DEFAULT_LOGGER_OPTIONS[:errors] @log_responses = DEFAULT_LOGGER_OPTIONS[:responses] end |