Sha256: c1681fe297c21a2341c20cf8c91f0691254b4f5ecc7a4985b7f1a1e348b81de8
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
module ItunesApi module Requests # Allows querying the API via lookup. class Lookup include Base def initialize(artist_id) @artist_id = artist_id end def self.artist_with_albums(id) new(id).artist_with_albums end def artist_with_albums artist.merge(albums: albums) end private def action 'lookup' end def albums albums_data.map do |album| symbolize_keys(unwrapped(album)) end end def albums_data results.find_all { |wrappers| wrappers['wrapperType'] == 'collection' } end def artist symbolize_keys(unwrapped(artist_data)) end def artist_data results.find do |wrappers| wrappers['wrapperType'] == 'artist' end end def query { entity: 'album', amgArtistId: @artist_id, country: COUNTRY_CODE, limit: LIMIT, sort: 'recent' } end def unwrapped(hash) hash.delete('wrapperType') hash end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
itunes_api-0.5.1 | lib/itunes_api/requests/lookup.rb |
itunes_api-0.5.0 | lib/itunes_api/requests/lookup.rb |
itunes_api-0.4.2 | lib/itunes_api/requests/lookup.rb |