Sha256: 5f419d928f50726ab5f6661b545402d2d2370f942da5dad6907fd588fb72a423

Contents?: true

Size: 815 Bytes

Versions: 4

Compression:

Stored size: 815 Bytes

Contents

module ItunesApi
  module Music
    module Requests
      # Allows querying the API via search for artists.
      class Search
        include Request
        attr_reader_init :artist_name, :store
        selfie :artists

        def artists
          @artists ||= decorated_results.find_all(&:relevant?)
        end

        private

        def action
          'search'
        end

        def decorated_results
          results.map do |result|
            Results::Artist.new(result, store, artist_name)
          end
        end

        def query
          {
            attribute: 'artistTerm',
            country: store.to_s.upcase,
            entity: 'musicArtist',
            limit: LIMIT,
            media: 'music',
            term: artist_name
          }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
itunes_api-2.2.1 lib/itunes_api/music/requests/search.rb
itunes_api-2.2.0 lib/itunes_api/music/requests/search.rb
itunes_api-2.1.0 lib/itunes_api/music/requests/search.rb
itunes_api-2.0.0 lib/itunes_api/music/requests/search.rb