forked from espired/esp32-spotify-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspotify_api.h
50 lines (45 loc) · 1.08 KB
/
spotify_api.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
struct TrackInfo
{
String name;
String artistName;
String coverUrl;
int duration;
int progress;
bool isPlaying;
};
struct FeaturedPlaylist
{
String name;
String id;
String imageUrl;
};
struct Device
{
String id;
String name;
};
class SpotifyApi
{
public:
int errorCount;
int lastHttpResponseCode;
SpotifyApi(String, String, String, String);
TrackInfo getCurrentTrackInfo();
String refreshAccessToken();
std::tuple<Device *, size_t> getDevicesList();
void setActiveDevice(String);
String getUsername();
bool performHttpRequestWithRetry(HTTPClient &http, String &apiUrl, String &response);
void controlSpotify(String command);
void setVolume(int volume);
void playPlaylist(String playlistId);
std::tuple<FeaturedPlaylist *, size_t> getFeaturedPlaylists(int limit, int offset);
std::tuple<FeaturedPlaylist *, size_t> getUserPlaylists(int limit, int offset);
private:
String clientId;
String clientSecret;
String accessToken;
String refreshToken;
void withAuth(HTTPClient &http);
};