Class: Weimark::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/weimark/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

“timestamp”=>“08/21/2018 14:43:24”, “link”=>“secure.weimark.com/applications/view/380854”, “status”=>“COMPLETED”, “report”=>“ficoscores”=>{“applicants”=>{“applicant”=>{“name”=>“John Doe”, “score”=>“850”}}, “fullreport”=>“”}}}



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/weimark/client.rb', line 85

def initialize(response)
  @response = response
  @parsed_response = Hash.from_xml(response)['xml']
  @status = parsed_response['status']

  if successful?
    result = @parsed_response['result']
    application = result['application']
    application.merge!('id' => result['applicationid']) if result['applicationid']
    @application = Weimark::Application.new(application)
    @report = Weimark::Report.new(result['report']) if result['report']
  else
    @message = parsed_response['message']
  end
end

Instance Attribute Details

#applicationObject (readonly)

Returns the value of attribute application.



82
83
84
# File 'lib/weimark/client.rb', line 82

def application
  @application
end

#messageObject (readonly)

Returns the value of attribute message.



82
83
84
# File 'lib/weimark/client.rb', line 82

def message
  @message
end

#parsed_responseObject (readonly)

Returns the value of attribute parsed_response.



82
83
84
# File 'lib/weimark/client.rb', line 82

def parsed_response
  @parsed_response
end

#reportObject (readonly)

Returns the value of attribute report.



82
83
84
# File 'lib/weimark/client.rb', line 82

def report
  @report
end

#responseObject (readonly)

Returns the value of attribute response.



82
83
84
# File 'lib/weimark/client.rb', line 82

def response
  @response
end

#statusObject (readonly)

Returns the value of attribute status.



82
83
84
# File 'lib/weimark/client.rb', line 82

def status
  @status
end

Instance Method Details

#errorsObject



105
106
107
# File 'lib/weimark/client.rb', line 105

def errors
  successful? ? [] : [parsed_response['message']]
end

#successful?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/weimark/client.rb', line 101

def successful?
  status != 'ERROR'
end