Class: Lipseys::User

Inherits:
SoapClient show all
Defined in:
lib/lipseys/user.rb

Constant Summary collapse

API_URL =
'https://www.lipseys.com/API/validate.asmx?WSDL'

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ User

Returns a new instance of User.



6
7
8
9
# File 'lib/lipseys/user.rb', line 6

def initialize(options = {})
  requires!(options, :username, :password)
  @options = options
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/lipseys/user.rb', line 11

def authenticated?
  validate[:success]
end

#validateObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lipseys/user.rb', line 15

def validate
  body = { Credentials: { EmailAddress: @options[:username], Password: @options[:password] } }
  response = soap_client(API_URL).call(:validate_dealer, message: body)

  result = response.body[:validate_dealer_response][:validate_dealer_result]

  {
    success: (result[:success] == 'Y'),
    description: result[:return_desc],
  }
rescue Savon::Error => e
  { success: false, description: e.to_s }
end