class Spotify::API::Album

Constants

ALBUMS_URL

API endpoint for albums.

Public Class Methods

search_by_id(args = {}) click to toggle source

Gets an album.

@param [Hash] args the search arguments. @option [Fixnum] :timeout the max time a request can take. @option [Fixnum] :retries the number of retries if necessary.

@return [Full::Album] the extracted album.

# File lib/spotify/api/album.rb, line 38
def self.search_by_id(args = {})
  service_params = args.slice(:timeout, :retries)
  args           = args.slice(:id)

  self.new(service_params).search_by_id(args)
end
search_by_ids(args = {}) click to toggle source

Gets an album.

@param [Hash] args the search arguments. @option [Fixnum] :timeout the max time a request can take. @option [Fixnum] :retries the number of retries if necessary.

@return [Array<Full::Album>] the extracted album.

# File lib/spotify/api/album.rb, line 54
def self.search_by_ids(args = {})
  args[:ids] = Array(args[:ids]).join(',')

  service_params = args.slice(:timeout, :retries)
  args           = args.slice(:ids)

  self.new(service_params).search_by_ids(args)
end
tracks(args = {}) click to toggle source

Gets an album.

@param [Hash] args the search arguments. @option [Fixnum] :timeout the max time a request can take. @option [Fixnum] :retries the number of retries if necessary.

@return [Full::Album] the extracted album.

# File lib/spotify/api/album.rb, line 72
def self.tracks(args = {})
  service_params = args.slice(:timeout, :retries)
  args           = args.slice(:id, :limit, :offset, :market)

  self.new(service_params).tracks(args)
end

Public Instance Methods

search_by_id(args = {}) click to toggle source

Gets an album.

@param [Hash] args the search arguments. @option [String] :id the album id.

@return [Full::Album] the extracted album.

# File lib/spotify/api/album.rb, line 111
def search_by_id(args = {})
  url = ALBUMS_URL + '/' + args[:id].to_s

  get(url)

  define_response do
    Spotify::Models::Full::Album.new(response)
  end
end
search_by_ids(args = {}) click to toggle source

Gets several albums.

@param [Hash] args the search arguments. @option [String] :ids the artists ids between “,”.

@return [Array<Full::Album>] an array containing

the extracted albums.
# File lib/spotify/api/album.rb, line 130
def search_by_ids(args = {})
  get(ALBUMS_URL, args)

  define_response do
    response["albums"].map do |album|
      Spotify::Models::Full::Album.new(album)
    end
  end
end
tracks(args = {}) click to toggle source

Gets the album's tracks.

@param [Hash] args the search arguments.

@return [Paging] an array containing album's tracks.

# File lib/spotify/api/album.rb, line 147
def tracks(args = {})
  url    = ALBUMS_URL + '/' + args[:id] + '/tracks'
  params = args.slice(:limit, :offset, :market)

  get(url, params)

  define_response do
    klass = Spotify::Models::Simplified::Track

    Spotify::Models::Paging.new(response, klass)
  end
end