Sha256: f3ebca3e37e5289ae019721d5cf7c9400888065f4ec03a0f8c97e0f96fb1c7f1

Contents?: true

Size: 399 Bytes

Versions: 2

Compression:

Stored size: 399 Bytes

Contents

require 'faraday'
require 'json'
module ItunesApi
  # Allow requests to the iTunes API.
  module Request
    def results
      @results ||= parsed_response.fetch('results') { [] }
    end

    private

    def parsed_response
      JSON.parse(response.body)
    end

    def connection
      Faraday.new(url: BASE_URL)
    end

    def response
      connection.get(action, query)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
itunes_api-2.1.0 lib/itunes_api/request.rb
itunes_api-2.0.0 lib/itunes_api/request.rb