Class: Shoppr::GeneralSearchResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/shoppr/general_search_response.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ GeneralSearchResponse

Returns a new instance of GeneralSearchResponse.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/shoppr/general_search_response.rb', line 4

def initialize(options={})
  response = Shoppr::Client.get('/GeneralSearch', :query => options)
  h = Hashie::Mash.new(response["GeneralSearchResponse"])     
  
  Shoppr.map_mash_attrs(self, h)
  
  if self.categories.category.is_a?(Array)
    @categories = self.categories.category.map {|category| Category.new(category) } 
  else
    @categories = [Category.new(self.categories.category)]
  end
  
  if self.exceptions.exception.is_a?(Array)
    @exceptions = self.exceptions.exception.map {|exception| APIException.new(exception) } 
  else
    @exceptions = [APIException.new(self.exceptions.exception)]
  end
  
  @server_detail = ServerDetail.new(self.server_detail)  
  @client_tracking = ClientTracking.new(self.client_tracking)
  @related_terms = self.related_terms ? self.related_terms.term : []
  @search_history = SearchHistory.new(self.search_history)
end