Sha256: f4ab1bd6558bc82c9905b7a1cc1bde794cef57bfecc704ae578f2b4e0aec3215
Contents?: true
Size: 1.11 KB
Versions: 1
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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
itunes_api-0.6.0 | lib/itunes_api/requests/lookup.rb |