Class: Majestic::Api::ItemInfoResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/majestic/api/item_info_response.rb

Instance Attribute Summary

Attributes inherited from Response

#code, #error_message, #full_error, #items, #parsed_items, #response, #success

Instance Method Summary collapse

Methods inherited from Response

#parse_response, #stacktrace, #success?

Constructor Details

#initialize(response) ⇒ ItemInfoResponse

Returns a new instance of ItemInfoResponse.



5
6
7
8
9
10
# File 'lib/majestic/api/item_info_response.rb', line 5

def initialize(response)
  super(response)
  
  raise_exceptions_if_necessary
  parse_item_info_objects
end

Instance Method Details

#parse_item_info_objectsObject



19
20
21
22
23
24
# File 'lib/majestic/api/item_info_response.rb', line 19

def parse_item_info_objects
  self.parsed_items.each do |parsed_item|
    item_info   =   Majestic::Api::ItemInfo.new(parsed_item)
    self.items <<   item_info unless self.items.include?(item_info)
  end if self.parsed_items && self.parsed_items.any?
end

#raise_exceptions_if_necessaryObject



12
13
14
15
16
17
# File 'lib/majestic/api/item_info_response.rb', line 12

def raise_exceptions_if_necessary
  case self.code
    when 'InsufficientIndexItemInfoUnits'
      raise Majestic::Api::InsufficientIndexItemInfoUnitsException.new(self.error_message)
  end unless success?
end