Sha256: 9c23efe83bc21321197a1b7e06d7e0773599afb230d1a6b96bb2b39058d17d65

Contents?: true

Size: 751 Bytes

Versions: 1

Compression:

Stored size: 751 Bytes

Contents

module ItunesApi
  module Requests
    # Fetch all the artist ids corresponding to a search term
    class Search
      include Base

      def initialize(artist_name)
        @artist_name = artist_name
      end

      def self.artist_ids(artist_name)
        new(artist_name).artist_ids
      end

      def artist_ids
        results.collect do |result|
          result['artistId']
        end.compact.uniq.sort
      end

      private

      def action
        'search'
      end

      def query
        {
          attribute: 'artistTerm',
          entity: 'album',
          term: @artist_name,
          country: country_code,
          limit: LIMIT,
          media: 'music',
          sort: 'recent'
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itunes_api-0.7.0 lib/itunes_api/requests/search.rb