Class: LocalSearchService::LocalSearchResponse

Inherits:
BasicResponse show all
Defined in:
lib/local_search_service/local_search_response.rb

Instance Attribute Summary collapse

Attributes inherited from BasicResponse

#error_code, #error_message

Instance Method Summary collapse

Methods inherited from BasicResponse

#inizialize, #raise_on_error

Constructor Details

#initialize(response_xml, raise_exception_on_error = true) ⇒ LocalSearchResponse

Constructor.

Parameters

response_xml

Xml as returned by a ip_location-method call.

raise_exception_on_error

Xml as returned by a call_status-method call.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/local_search_service/local_search_response.rb', line 13

def initialize(response_xml, raise_exception_on_error = true)

  doc = response_xml.document

  @error_code           = LocalSearchService.xpath_query(doc, "statusCode").to_s
  @error_message        = LocalSearchService.xpath_query(doc, "statusMessage").to_s

  #TODO
  @search_result        = LocalSearchService.xpath_query(doc, "searchResult/RESULTS")

  raise_on_error(response_xml) if raise_exception_on_error
end

Instance Attribute Details

#search_resultObject

Returns the value of attribute search_result.



6
7
8
# File 'lib/local_search_service/local_search_response.rb', line 6

def search_result
  @search_result
end

Instance Method Details

#to_sObject



26
27
28
# File 'lib/local_search_service/local_search_response.rb', line 26

def to_s
  "#{@error_code.to_s}: #{@error_message.to_s}: #{@search_result.to_s}"
end