class SageWorld::Auth

Attributes

request_body[R]

Public Class Methods

new(params) click to toggle source
# File lib/sage_world/auth.rb, line 8
def initialize(params)
  validate_configuration
  @login_id   = SageWorld.configuration.login
  @password   = SageWorld.configuration.password
  @version    = SageWorld.configuration.version
  @account_id = SageWorld.configuration.account_id
  @params = params
end

Public Instance Methods

to_xml() click to toggle source
# File lib/sage_world/auth.rb, line 17
def to_xml
  if request_body
    Gyoku.xml(request_body, key_converter: lambda { |key| key.camelize(:upper) })
  end
end

Private Instance Methods

body() click to toggle source
# File lib/sage_world/auth.rb, line 27
        def body
  {
    XML_data_stream_request: {
      version: @version,
      auth: {
        acct_id: @account_id,
        login_id: @login_id,
        password: @password
      }
    }
  }
end
check_account_presence() click to toggle source
# File lib/sage_world/auth.rb, line 60
        def check_account_presence
  raise SageWorld::InvalidConfigurationError.new(SageWorld::Constants::ACCOUNT_ID_MISSING_ERROR) unless SageWorld.configuration.account_id
end
check_configuration_presence() click to toggle source
# File lib/sage_world/auth.rb, line 47
        def check_configuration_presence
  raise SageWorld::InvalidConfigurationError.new unless SageWorld.configuration.present?
end
check_credentials_presence() click to toggle source
# File lib/sage_world/auth.rb, line 55
        def check_credentials_presence
  raise SageWorld::InvalidConfigurationError.new(SageWorld::Constants::INVALID_CREDENTIALS) unless SageWorld.configuration.login
  raise SageWorld::InvalidConfigurationError.new(SageWorld::Constants::INVALID_CREDENTIALS) unless SageWorld.configuration.password
end
check_end_point_presence() click to toggle source
# File lib/sage_world/auth.rb, line 51
        def check_end_point_presence
  raise SageWorld::InvalidConfigurationError.new(SageWorld::Constants::END_POINT_MISSING_ERROR) unless SageWorld.configuration.end_point
end
validate_configuration() click to toggle source
# File lib/sage_world/auth.rb, line 40
        def validate_configuration
  check_configuration_presence
  check_end_point_presence
  check_credentials_presence
  check_account_presence
end