class IletiMerkezi::Configuration

Configuration :reek: TooManyInstanceVariables { max_instance_variables: 8 }

Constants

ENDPOINT
SENDER

Attributes

endpoint[RW]

:reek: Attribute

password[RW]

:reek: Attribute

public_key[RW]

:reek: Attribute

request_overrides[RW]

:reek: Attribute

secret_key[RW]

:reek: Attribute

sender[RW]

:reek: Attribute

username[RW]

:reek: Attribute

Public Class Methods

new() click to toggle source
# 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

Public Instance Methods

auth_method() click to toggle source
# 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() click to toggle source

set default config

# 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() click to toggle source
# 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() click to toggle source

config resets

# 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