Sha256: 730a7d3039199cae7637c9449309bcf5a44d2d7db1e59e723fb014ba1c77c52b
Contents?: true
Size: 561 Bytes
Versions: 6
Compression:
Stored size: 561 Bytes
Contents
require 'json' module Paapi class Response attr_reader :http_response, :hash, :datas, :doc, :items def initialize(response) @http_response = response @hash = JSON.parse(response.body.to_s) @items_data = @hash.dig('ItemsResult', 'Items') @items_data ||= @hash.dig('SearchResult', 'Items') @items_data ||= @hash.dig('VariationsResult', 'Items') @items_data ||= [] @items = @items_data.map {|d| Item.new(d)} end def result_count @hash.dig('SearchResult', 'TotalResultCount') end end end
Version data entries
6 entries across 6 versions & 1 rubygems