Class: IletiMerkezi::Configuration
- Inherits:
-
Module
- Object
- Module
- IletiMerkezi::Configuration
- Defined in:
- lib/ileti_merkezi/utils/configuration.rb
Overview
Configuration :reek:TooManyInstanceVariables { max_instance_variables: 8 }
Constant Summary collapse
- ENDPOINT =
'http://api.iletimerkezi.com/v1'
- SENDER =
'APITEST'
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
:reek:Attribute.
-
#password ⇒ Object
:reek:Attribute.
-
#public_key ⇒ Object
:reek:Attribute.
-
#request_overrides ⇒ Object
:reek:Attribute.
-
#secret_key ⇒ Object
:reek:Attribute.
-
#sender ⇒ Object
:reek:Attribute.
-
#username ⇒ Object
:reek:Attribute.
Instance Method Summary collapse
- #auth_method ⇒ Object
-
#default_config ⇒ Object
set default config.
- #hmac ⇒ Object
-
#initialize ⇒ Configuration
constructor
rubocop:disable Lint/MissingSuper.
-
#reset ⇒ Object
config resets.
Constructor Details
#initialize ⇒ Configuration
rubocop:disable Lint/MissingSuper
21 22 23 24 25 26 27 28 29 |
# File 'lib/ileti_merkezi/utils/configuration.rb', line 21 def initialize # rubocop:disable Lint/MissingSuper @endpoint = ENV['IM_ENDPOINT'] || ENDPOINT @username = ENV['IM_USERNAME'] @password = ENV['IM_PASSWORD'] @public_key = ENV['IM_PUBLIC_KEY'] @secret_key = ENV['IM_SECRET_KEY'] @sender = ENV['IM_SENDER'] || SENDER @request_overrides = {} end |
Instance Attribute Details
#endpoint ⇒ Object
:reek:Attribute
10 11 12 |
# File 'lib/ileti_merkezi/utils/configuration.rb', line 10 def endpoint @endpoint end |
#password ⇒ Object
:reek:Attribute
10 11 12 |
# File 'lib/ileti_merkezi/utils/configuration.rb', line 10 def password @password end |
#public_key ⇒ Object
:reek:Attribute
10 11 12 |
# File 'lib/ileti_merkezi/utils/configuration.rb', line 10 def public_key @public_key end |
#request_overrides ⇒ Object
:reek:Attribute
10 11 12 |
# File 'lib/ileti_merkezi/utils/configuration.rb', line 10 def request_overrides @request_overrides end |
#secret_key ⇒ Object
:reek:Attribute
10 11 12 |
# File 'lib/ileti_merkezi/utils/configuration.rb', line 10 def secret_key @secret_key end |
#sender ⇒ Object
:reek:Attribute
10 11 12 |
# File 'lib/ileti_merkezi/utils/configuration.rb', line 10 def sender @sender end |
#username ⇒ Object
:reek:Attribute
10 11 12 |
# File 'lib/ileti_merkezi/utils/configuration.rb', line 10 def username @username end |
Instance Method Details
#auth_method ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/ileti_merkezi/utils/configuration.rb', line 31 def auth_method if public_key && secret_key :auth_token elsif username && password :auth_basic else raise CredentialMissingError, 'Credentials missing' end end |
#default_config ⇒ Object
set default config
48 49 50 51 52 53 54 |
# File 'lib/ileti_merkezi/utils/configuration.rb', line 48 def default_config self.username = ENV['IM_USERNAME'] self.password = ENV['IM_PASSWORD'] self.public_key = ENV['IM_PUBLIC_KEY'] self.secret_key = ENV['IM_SECRET_KEY'] true end |
#hmac ⇒ Object
41 42 43 44 45 |
# File 'lib/ileti_merkezi/utils/configuration.rb', line 41 def hmac OpenSSL::HMAC.hexdigest( OpenSSL::Digest.new('sha256'), secret_key.to_s, public_key.to_s ) end |
#reset ⇒ Object
config resets
57 58 59 60 61 62 63 |
# File 'lib/ileti_merkezi/utils/configuration.rb', line 57 def reset self.username = nil self.password = nil self.public_key = nil self.secret_key = nil true end |