Class: Usps::Imis::Config
- Inherits:
-
Object
- Object
- Usps::Imis::Config
- Defined in:
- lib/usps/imis/config.rb
Overview
API Configuration
Constant Summary collapse
- IMIS_ROOT_URL_PROD =
'https://portal.americasboatingclub.org'- IMIS_ROOT_URL_DEV =
'https://abcdev.imiscloud.com'
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#imis_id_query_name ⇒ Object
Returns the value of attribute imis_id_query_name.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#logger_level ⇒ Object
readonly
Returns the value of attribute logger_level.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#filtered_parameters ⇒ Object
Parameters to filter out of logging.
-
#hostname ⇒ Object
Environment-specific API endpoint hostname.
-
#initialize {|_self| ... } ⇒ Config
constructor
A new instance of Config.
-
#instance_variables_to_inspect ⇒ Object
Ruby 3.5 instance variable filter.
- #silence! ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Config
Returns a new instance of Config.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/usps/imis/config.rb', line 14 def initialize @environment = default_environment @imis_id_query_name = ENV.fetch('IMIS_ID_QUERY_NAME', nil) @username = ENV.fetch('IMIS_USERNAME', nil) @password = ENV.fetch('IMIS_PASSWORD', nil) @logger = ActiveSupport::TaggedLogging.new(Logger.new($stdout, level: :info)) yield self if block_given? @logger_level = logger.class::SEV_LABEL[logger.level].downcase.to_sym end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
12 13 14 |
# File 'lib/usps/imis/config.rb', line 12 def environment @environment end |
#imis_id_query_name ⇒ Object
Returns the value of attribute imis_id_query_name.
11 12 13 |
# File 'lib/usps/imis/config.rb', line 11 def imis_id_query_name @imis_id_query_name end |
#logger ⇒ Object
Returns the value of attribute logger.
12 13 14 |
# File 'lib/usps/imis/config.rb', line 12 def logger @logger end |
#logger_level ⇒ Object (readonly)
Returns the value of attribute logger_level.
12 13 14 |
# File 'lib/usps/imis/config.rb', line 12 def logger_level @logger_level end |
#password ⇒ Object
Returns the value of attribute password.
11 12 13 |
# File 'lib/usps/imis/config.rb', line 11 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
11 12 13 |
# File 'lib/usps/imis/config.rb', line 11 def username @username end |
Instance Method Details
#filtered_parameters ⇒ Object
Parameters to filter out of logging
55 |
# File 'lib/usps/imis/config.rb', line 55 def filtered_parameters = i[password] |
#hostname ⇒ Object
Environment-specific API endpoint hostname
42 43 44 45 46 47 |
# File 'lib/usps/imis/config.rb', line 42 def hostname return IMIS_ROOT_URL_PROD if environment.production? return IMIS_ROOT_URL_DEV if environment.development? raise Errors::ConfigError, "Unexpected API environment: #{environment}" end |
#instance_variables_to_inspect ⇒ Object
Ruby 3.5 instance variable filter
51 |
# File 'lib/usps/imis/config.rb', line 51 def instance_variables_to_inspect = instance_variables - i[@password @logger] |
#silence! ⇒ Object
34 35 36 |
# File 'lib/usps/imis/config.rb', line 34 def silence! self.logger = Logger.new(nil) end |