mirror of
https://github.com/dkam/paapi.git
synced 2025-12-28 07:04:53 +00:00
26 lines
503 B
Ruby
26 lines
503 B
Ruby
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 ||= []
|
|
|
|
@items = @items_data.map {|d| Item.new(d)}
|
|
|
|
end
|
|
|
|
def result_count
|
|
@json.dig('SearchResult', 'TotalResultCount')
|
|
end
|
|
|
|
|
|
|
|
end
|
|
end |