Module: Genius::Artists
- Defined in:
- lib/genius/api/artists.rb
Overview
An artist is how Genius represents the creator of one or more songs (or other documents hosted on Genius). It's usually a musician or group of musicians.
Class Method Summary collapse
-
.artists(token: nil, id: nil) ⇒ Hash, NilClass
Genius::Artists.artists
-> Hash. -
.artists_songs(token: nil, id: nil, options: {}) ⇒ Hash, NilClass
Genius::Artists.artists_songs
-> Hash | NilClass.
Class Method Details
.artists(token: nil, id: nil) ⇒ Hash, NilClass
Genius::Artists.artists
-> Hash
Data for a specific artist.
18 19 20 21 22 23 24 25 |
# File 'lib/genius/api/artists.rb', line 18 def artists(token: nil, id: nil) Auth.(method_name: "#{Module.nesting[1].name}.#{__method__}") if token.nil? Errors.validate_token(token) unless token.nil? raise ArgumentError, "`id` can't be nil!" if id.nil? response = HTTParty.get("#{Api::RESOURCE}/artists/#{id}?access_token=#{token_ext(token)}").body JSON.parse(response) end |
.artists_songs(token: nil, id: nil, options: {}) ⇒ Hash, NilClass
Genius::Artists.artists_songs
-> Hash | NilClass
Documents (songs) for the artist specified. By default, 20 items are returned for each request.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/genius/api/artists.rb', line 42 def artists_songs(token: nil, id: nil, options: {}) return if token.nil? && !Auth..nil? Errors.validate_token(token) unless token.nil? sort_values = %w[title popularity] validate(sort_values, sort: [:sort], per_page: [:per_page], page: [:page]) params = (, %i[sort per_page page]) response = HTTParty.get("#{Api::RESOURCE}/artists/#{id}?access_token=#{token_ext(token)}#{params}").body JSON.parse(response) end |