Class: Spotify::SDK::Me
- Defined in:
- lib/spotify/sdk/me.rb,
lib/spotify/sdk/me/info.rb
Defined Under Namespace
Classes: Info
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#following(override_opts = {}) ⇒ Array
Get the current user’s followed artists.
-
#following?(list, type = :artist, override_opts = {}) ⇒ Boolean
Check if the current user is following N users.
-
#info(override_opts = {}) ⇒ Spotify::SDK::Me::Info
Get the current user’s information.
Methods inherited from Base
#initialize, #inspect, #send_http_request
Constructor Details
This class inherits a constructor from Spotify::SDK::Base
Instance Method Details
#following(override_opts = {}) ⇒ Array
Get the current user’s followed artists. Requires the ‘user-read-follow` scope. GET /v1/me/following
45 46 47 48 49 50 |
# File 'lib/spotify/sdk/me.rb', line 45 def following(override_opts={}) artists = send_following_http_requests("/v1/me/following?type=artist&limit=50", override_opts) artists.map do |artist| Spotify::SDK::Artist.new(artist, self) end end |
#following?(list, type = :artist, override_opts = {}) ⇒ Boolean
Check if the current user is following N users.
28 29 30 31 32 33 |
# File 'lib/spotify/sdk/me.rb', line 28 def following?(list, type=:artist, override_opts={}) raise "Must contain an array" unless list.is_a?(Array) raise "Must contain an array of String or Spotify::SDK::Artist" if any_of?(list, [String, Spotify::SDK::Artist]) raise "type must be either 'artist' or 'user'" unless i[artist user].include?(type) send_is_following_http_requests(list.map {|id| id.try(:id) || id }, type, override_opts) end |
#info(override_opts = {}) ⇒ Spotify::SDK::Me::Info
Get the current user’s information. Respective information requires the ‘user-read-private user-read-email user-read-birthdate` scopes. GET /v1/me
20 21 22 23 |
# File 'lib/spotify/sdk/me.rb', line 20 def info(override_opts={}) me_info = send_http_request(:get, "/v1/me", override_opts) Spotify::SDK::Me::Info.new(me_info, self) end |