Method: Spotify::API::Track#search

Defined in:
lib/spotify/api/track.rb

#search(args = {}) ⇒ Spotify::Models::Paging

Gets the tracks related to the given parameters.

Parameters:

  • args (Hash) (defaults to: {})

    the search arguments.

  • [Fixnum] (Hash)

    a customizable set of options

Returns:



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/spotify/api/track.rb', line 73

def search(args = {})
  if args[:market].to_s.to_sym == FROM_TOKEN
    # TODO: Authorization.
    return Spotify::API::Errors::NOT_AVAILABLE
  end

  get(SEARCH_URL, args)

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

    Spotify::Models::Paging.new(response["tracks"], klass)
  end
end