-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
51 lines (42 loc) · 959 Bytes
/
provider.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
package provider
import (
"fmt"
"strings"
"golang.org/x/oauth2"
)
type PlaylistID string
type TrackID string
type TokenProvider interface {
GetToken() (*oauth2.Token, error)
RefreshToken() (*oauth2.Token, error)
}
//go:generate mockery --name Provider
type Provider interface {
Name() string
IsLoggedIn() bool
GetPlaylists() ([]Playlist, error)
CreatePlaylist(name string) (PlaylistID, error)
FindTrack(name string) (TrackID, error)
FindPlaylistByName(name string) (PlaylistID, error)
GetFullPlaylist(id string) (*FullPlaylist, error)
AddToPlaylist(playlistId string, trackId string) error
}
type FullPlaylist struct {
Playlist
Tracks []Track
}
type Track struct {
ID string
Name string
Artists []string
}
func (t Track) FullName() string {
artists := strings.Join(t.Artists, ", ")
return fmt.Sprintf("%s - %s", artists, t.Name)
}
type Playlist struct {
ID PlaylistID
Name string
Tracks uint
Creator string
}