Method: RSpotify::Category.find

Defined in:
lib/rspotify/category.rb

.find(id, **options) ⇒ Category

Returns Category object with id provided

Examples:

category = RSpotify::Category.find('party')
category = RSpotify::Category.find('party', country: 'US')
category = RSpotify::Category.find('party', locale: 'es_MX')

Parameters:

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rspotify/category.rb', line 23

def self.find(id, **options)
  url = "browse/categories/#{id}"
  url << '?' if options.any?

  options.each_with_index do |option, index|
    url << "#{option[0]}=#{option[1]}"
    url << '&' unless index == options.size-1
  end

  response = RSpotify.get(url)
  return response if RSpotify.raw_response
  Category.new response
end