Sha256: 6c4d983c46b26662708030d2402cfab175b458ddc91f2a6effc5e94005d16aa9

Contents?: true

Size: 804 Bytes

Versions: 1

Compression:

Stored size: 804 Bytes

Contents

module MajesticSeo
  module Api
    class ItemInfoResponse < Response
      
      def initialize(response)
        super(response)
        
        raise_exceptions_if_necessary
        parse_item_info_objects
      end
      
      def raise_exceptions_if_necessary
        case self.code
          when 'InsufficientIndexItemInfoUnits'
            raise MajesticSeo::Api::InsufficientIndexItemInfoUnitsException.new(self.error_message)
        end unless success?
      end
      
      def parse_item_info_objects
        self.parsed_items.each do |parsed_item|
          item_info   =   MajesticSeo::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
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
majestic_seo_api-1.4.0 lib/majestic_seo/api/item_info_response.rb