Sha256: abc1d6a4e02d0361bf0f3371308460c888612af5d13b8f39faceedc54f90ef9a

Contents?: true

Size: 843 Bytes

Versions: 3

Compression:

Stored size: 843 Bytes

Contents

# frozen_string_literal: true

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

3 entries across 3 versions & 1 rubygems

Version Path
itunes_api-2.4.1 lib/itunes_api/music/requests/search.rb
itunes_api-2.4.0 lib/itunes_api/music/requests/search.rb
itunes_api-2.3.2 lib/itunes_api/music/requests/search.rb