Class: Ejaydj::Spotify::Client
- Inherits:
-
Object
- Object
- Ejaydj::Spotify::Client
- Defined in:
- lib/ejaydj/spotify/client.rb
Constant Summary collapse
- API_URL =
'https://api.spotify.com'- ACCOUNT_API_URL =
'https://accounts.spotify.com'
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ Client
constructor
A new instance of Client.
- #playlist_tracks(user_id: nil, playlist_id: nil) ⇒ Object
- #user_playlists(user_id: nil) ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 |
# File 'lib/ejaydj/spotify/client.rb', line 12 def initialize(config={}) @rest_client = config[:rest_client] || RestClient @client_id = config[:client_id] @client_secret = config[:client_secret] end |
Instance Method Details
#playlist_tracks(user_id: nil, playlist_id: nil) ⇒ Object
24 25 26 27 28 |
# File 'lib/ejaydj/spotify/client.rb', line 24 def playlist_tracks(user_id: nil, playlist_id: nil) url = "#{API_URL}/v1/users/#{user_id}/playlists/#{playlist_id}/tracks" response = get_request(url) fetch_items(response) end |
#user_playlists(user_id: nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/ejaydj/spotify/client.rb', line 18 def user_playlists(user_id: nil) url = "#{API_URL}/v1/users/#{user_id}/playlists?limit=50" response = get_request(url) fetch_items(response) end |