Module: SimpleSpotify::Actions::Artists

Defined in:
lib/simplespotify/actions/artists.rb

Instance Method Summary collapse

Instance Method Details

#artist(artist) ⇒ Object



6
7
8
9
# File 'lib/simplespotify/actions/artists.rb', line 6

def artist artist
  response = get "artist/#{id_for(artist)}"
  Model::Artist.new(response.body)
end

#artist_albums(artist, album_type: nil, market: nil, limit: 20, offset: 0) ⇒ Object



22
23
24
25
26
# File 'lib/simplespotify/actions/artists.rb', line 22

def artist_albums artist, album_type: nil, market: nil, limit: 20, offset: 0
  options = {album_type: album_type, limit: limit, offset: offset}
  response = get "artists/#{id_for(artist)}/albums", options_with_market(market, options)
  Model::Collection.of(:artists, response.body)
end

#artists(*artists) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/simplespotify/actions/artists.rb', line 12

def artists *artists
  artists = artists.map {|a|
    id_for(a)
  }.join(',')

  response = get "artists", {ids: artists}
  Model::Collection.of(:artists, response.body)
end


39
40
41
42
# File 'lib/simplespotify/actions/artists.rb', line 39

def related_artists artist
  response = get "artists/#{id_for(artist)}/related-artists"
  Model::Collection.of(:artists, response.body)
end

#top_tracks(artist, market = nil) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/simplespotify/actions/artists.rb', line 29

def top_tracks artist, market=nil
  id = id_for(artist)
  market = market || @market
  raise "Market required for top tracks" unless market

  response = get "artists/#{id}/top-tracks", {country: market}
  Model::Collection.of(:tracks, response.body)
end