-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
122 lines (98 loc) · 2.66 KB
/
structs.go
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package spotify
import (
"context"
"fmt"
)
type scope string
const (
ScopePlaylistModifyPrivate = scope("playlist-modify-private")
ScopePlaylistModifyPublic = scope("playlist-modify-public")
ScopeUserReadPlaybackState = scope("user-read-playback-state")
ScopeUserModifyPlaybackState = scope("user-modify-playback-state")
ScopeUserLibraryRead = scope("user-library-read")
ScopeUserReadRecentlyPlayed = scope("user-read-recently-played")
ScopeUserReadEmail = scope("user-read-email")
ScopeUserReadPrivate = scope("user-read-private")
)
type requestConfigOption func(r *requestConfig)
type requestConfig struct {
accessTokenGetter func(ctx context.Context) (string, bool)
}
func defaultRequestOptions() requestConfig {
return requestConfig{
accessTokenGetter: userAccessToken,
}
}
func WithStrideSongsAccessToken() requestConfigOption {
return func(r *requestConfig) {
r.accessTokenGetter = strideSongsAccessToken
}
}
type AuthResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
Scope string `json:"scope"`
ExpiresIn int `json:"expires_in"`
RefreshToken string `json:"refresh_token"`
}
type User struct {
ID string `json:"id"`
}
type Track struct {
ID string `json:"id"`
}
type AnalyzedTrack struct {
Track
Tempo float64 `json:"tempo"`
}
type CreatePlaylistRequest struct {
Name string `json:"name"`
Public bool `json:"public"`
Collaborative bool `json:"collaborative"`
Description *string `json:"description"`
UserID string `json:"-"`
}
type Playlist struct {
ID string `json:"id"`
Name string `json:"string"`
}
type AddTracksToPlaylistRequest struct {
PlaylistID string
Tracks []Track
}
type addTracksToPlaylistRequest struct {
URIs []string `json:"uris"`
}
type repeatMode string
const (
RepeatModeTrack = repeatMode("track")
RepeatModeContext = repeatMode("context")
RepeatModeOff = repeatMode("off")
)
type itemType string
const (
ItemTypeTrack = itemType("track")
ItemTypeAlbum = itemType("album")
ItemTypePlaylist = itemType("playlist")
)
type PlayRequest struct {
ItemType itemType
ItemID string
}
func (p *PlayRequest) ToRequestPayload() *playRequest {
return &playRequest{
ContextURI: fmt.Sprintf("spotify:%s:%s", p.ItemType, p.ItemID),
}
}
type playRequest struct {
ContextURI string `json:"context_uri"`
}
type SpotifyContext struct {
URI string `json:"uri"`
}
type CurrentPlayback struct {
IsPlaying bool `json:"is_playing"`
ShuffleState bool `json:"shuffle_state"`
RepeatState repeatMode `json:"repeat_state"`
Context SpotifyContext `json:"context"`
}