Module: SimpleSpotify::Actions::Browse
- Defined in:
- lib/simplespotify/actions/browse.rb
Instance Method Summary collapse
- #categories(country: nil, locale: nil, limit: 20, offset: 0) ⇒ Object
- #category(category, country: nil, locale: nil) ⇒ Object
- #category_playlists(category, country: nil, limit: 20, offset: 0) ⇒ Object
- #featured_playlists(locale: nil, country: nil, timestamp: nil, limit: 20, offset: 0) ⇒ Object
- #new_releases(country: nil, limit: 20, offset: 0) ⇒ Object
Instance Method Details
#categories(country: nil, locale: nil, limit: 20, offset: 0) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/simplespotify/actions/browse.rb', line 34 def categories country: nil, locale: nil, limit: 20, offset: 0 = {limit: limit, offset: offset} market = country || @market [:country] = market if market locale ||= ENV['LANG'].split('.').first if ENV['LANG'] [:locale] = locale if locale response = get "browse/categories", Model::Collection.of(Model::Category, response.body[:categories]) end |
#category(category, country: nil, locale: nil) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/simplespotify/actions/browse.rb', line 48 def category category, country: nil, locale: nil = {} market = country || @market [:country] = market if market locale ||= ENV['LANG'].split('.').first if ENV['LANG'] [:locale] = locale if locale response = get "browse/categories/#{id_for(category)}" Model::Category.new(response) end |
#category_playlists(category, country: nil, limit: 20, offset: 0) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/simplespotify/actions/browse.rb', line 61 def category_playlists category, country: nil, limit: 20, offset: 0 = {limit: limit, offset: offset} market = country || @market [:country] = market if market response = get "browse/categories/#{id_for(category)}/playlists", Model::Collection.of(:playlists, response.body[:playlists]) end |
#featured_playlists(locale: nil, country: nil, timestamp: nil, limit: 20, offset: 0) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/simplespotify/actions/browse.rb', line 6 def featured_playlists locale: nil, country: nil, timestamp: nil, limit: 20, offset: 0 locale ||= ENV['LANG'].split('.').first if ENV['LANG'] = .to_time if .is_a Date = .iso8601 if .is_a? Time = { locale: locale, country: country || @market, timestamp: , limit: limit, offset: offset }.reject {|k,v| v.nil? || v==''}.to_h response = get "browse/featured-playlists", Model::Collection.of(:playlists, response.body[:playlists]) end |
#new_releases(country: nil, limit: 20, offset: 0) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/simplespotify/actions/browse.rb', line 24 def new_releases country: nil, limit: 20, offset: 0 = {limit: limit, offset: offset} market = country || @market [:country] = market if market response = get "browse/new-releases", Model::Collection.of(:albums, response.body[:albums]) end |