Sha256: c8125eca5163be45bc390495cbc18cc7452e1204f422677359e3428413bb8470
Contents?: true
Size: 655 Bytes
Versions: 3
Compression:
Stored size: 655 Bytes
Contents
# frozen_string_literal: true require 'faraday' require 'json' module ItunesApi # Allow requests to the iTunes API. module Request def results @results ||= parsed_response.fetch('results') { [] } end private def connection Faraday.new(url: BASE_URL) end def parsed_response JSON.parse(response.body) rescue JSON::ParserError { 'results' => [] } end def response connection.get(action, query) end def unwrapped_results(type) return [] unless results.any? results.find_all do |wrappers| wrappers['wrapperType'] == type.to_s end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
itunes_api-2.4.1 | lib/itunes_api/request.rb |
itunes_api-2.4.0 | lib/itunes_api/request.rb |
itunes_api-2.3.2 | lib/itunes_api/request.rb |