Sha256: 11c962ad8b1470f00291fafbd5afd813ef486da013827215e235923583a6c6d7
Contents?: true
Size: 701 Bytes
Versions: 3
Compression:
Stored size: 701 Bytes
Contents
require 'open-uri' require 'json' module ItunesApi module Requests # Allow requests to the iTunes API. module Base def results response.fetch('results') { [] } end private def query Addressable::URI.new( query_values: query_values ).query end def request open(url).read end def response @response ||= JSON.parse(request) end def symbolize_keys(hash) hash.each_with_object({}) do |(key, value), new_hash| new_hash[key.to_sym] = value new_hash end end def url "#{BASE_URL}/#{action}?#{query}" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
itunes_api-0.4.0 | lib/itunes_api/requests/base.rb |
itunes_api-0.3.1 | lib/itunes_api/requests/base.rb |
itunes_api-0.3 | lib/itunes_api/requests/base.rb |