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?
Data for a specific artist.
-
.artists_songs(token: nil, id: nil, options: {}) ⇒ Hash?
Songs for the artist specified.
Class Method Details
.artists(token: nil, id: nil) ⇒ Hash?
Data for a specific artist.
14 15 16 17 18 19 20 21 |
# File 'lib/genius/api/artists.rb', line 14 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?
Songs for the artist specified. By default 20 items per request.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/genius/api/artists.rb', line 29 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 |