lib/itunes_api/music/requests/songs.rb in itunes_api-2.1.0 vs lib/itunes_api/music/requests/songs.rb in itunes_api-2.2.0

- old
+ new

@@ -2,16 +2,16 @@ module Music module Requests # Allows querying the API via lookup for album songs. class Songs include Request - attr_reader_init :collection_id, :store - selfie :find_by_collection_id + attr_reader_init :search_id, :store + selfie :find_by_id - def find_by_collection_id - unwrapped_results.map do |result| - Results::Song.new(result) + def find_by_id + unwrapped_results(:track).map do |result| + Results::Song.new(result, store) end end private @@ -19,23 +19,15 @@ 'lookup' end def query { - entity: 'song', - id: collection_id, country: store.to_s.upcase, + entity: 'song', + id: search_id, limit: LIMIT, sort: 'trackNumber' } - end - - def unwrapped_results - return [] unless results.any? - - results.find_all do |wrappers| - wrappers['wrapperType'] == 'track' - end end end end end end