Class: Hawkei::Config
- Inherits:
-
Object
- Object
- Hawkei::Config
- Defined in:
- lib/hawkei/config.rb
Overview
Hawkei Config
Represent the Hawkei configuration for the API
Constant Summary collapse
- DEFAULT_OBFUSCATED_FIELDS =
%w[ password password_confirmation secret secret_token authenticity_token token api_key access_token credit_card_number cvv ccv ].freeze
Instance Attribute Summary collapse
-
#api_host ⇒ String
API host.
-
#api_key ⇒ String
API account token.
-
#api_version ⇒ String
API version.
-
#domain ⇒ String
Domain.
-
#enabled ⇒ Boolean
Service is enable.
-
#environment_name ⇒ String
API environment name.
-
#http_secure ⇒ Boolean
Http secure.
-
#log ⇒ Boolean
Enable the logger.
-
#logger ⇒ Logger
Logger.
-
#metadata ⇒ Hash
Metadata to be attach to the payload.
-
#obfuscated_fields ⇒ Array[String]
Fields to obfuscate.
-
#proxy_url ⇒ String
Proxy url.
-
#space_name ⇒ String
API space name.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Config
constructor
Initialize and validate the configuration.
-
#valid! ⇒ Boolean
validate the configuration Raise when configuration are not valid.
Constructor Details
#initialize(options = {}) ⇒ Config
Initialize and validate the configuration
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/hawkei/config.rb', line 77 def initialize( = {}) self.api_key = [:api_key] self.space_name = [:space_name] self.environment_name = [:environment_name] self.api_host = [:api_host] || 'api.hawkei.io' self.api_version = [:api_version] || 'v1' self.proxy_url = [:proxy_url] self.http_secure = [:http_secure] || true self.enabled = [:enabled] || true self. = [:obfuscated_fields] || [] self. = [:metadata] self.log = [:log] || true self.logger = FormatedLogger.build([:logger]) self.domain = [:domain] end |
Instance Attribute Details
#api_host ⇒ String
Returns API host.
36 37 38 |
# File 'lib/hawkei/config.rb', line 36 def api_host @api_host end |
#api_key ⇒ String
Returns API account token.
24 25 26 |
# File 'lib/hawkei/config.rb', line 24 def api_key @api_key end |
#api_version ⇒ String
Returns API version.
40 41 42 |
# File 'lib/hawkei/config.rb', line 40 def api_version @api_version end |
#domain ⇒ String
Returns domain.
72 73 74 |
# File 'lib/hawkei/config.rb', line 72 def domain @domain end |
#enabled ⇒ Boolean
Returns service is enable.
52 53 54 |
# File 'lib/hawkei/config.rb', line 52 def enabled @enabled end |
#environment_name ⇒ String
Returns API environment name.
32 33 34 |
# File 'lib/hawkei/config.rb', line 32 def environment_name @environment_name end |
#http_secure ⇒ Boolean
Returns http secure.
48 49 50 |
# File 'lib/hawkei/config.rb', line 48 def http_secure @http_secure end |
#log ⇒ Boolean
Returns enable the logger.
64 65 66 |
# File 'lib/hawkei/config.rb', line 64 def log @log end |
#logger ⇒ Logger
Returns logger.
68 69 70 |
# File 'lib/hawkei/config.rb', line 68 def logger @logger end |
#metadata ⇒ Hash
Returns metadata to be attach to the payload.
60 61 62 |
# File 'lib/hawkei/config.rb', line 60 def @metadata end |
#obfuscated_fields ⇒ Array[String]
Returns fields to obfuscate.
56 57 58 |
# File 'lib/hawkei/config.rb', line 56 def @obfuscated_fields end |
#proxy_url ⇒ String
Returns proxy url.
44 45 46 |
# File 'lib/hawkei/config.rb', line 44 def proxy_url @proxy_url end |
#space_name ⇒ String
Returns API space name.
28 29 30 |
# File 'lib/hawkei/config.rb', line 28 def space_name @space_name end |
Instance Method Details
#valid! ⇒ Boolean
validate the configuration Raise when configuration are not valid
97 98 99 100 101 102 103 104 105 |
# File 'lib/hawkei/config.rb', line 97 def valid! format! %i[api_key space_name environment_name api_host api_version].each do |field| validate_presence(field) end true end |