spotify

package
v0.0.0-...-e4d0ebf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewAuthorizedClient

func NewAuthorizedClient(user, token string) Client

func NewClient

func NewClient(id, secret, user string) Client

func (*Client) Authorize

func (c *Client) Authorize() error

func (*Client) CreatePlaylist

func (c *Client) CreatePlaylist(payload CreatePlaylistPayload) (Playlist, error)

CreatePlaylist creates a playlist for a given user as described here: https://developer.spotify.com/documentation/web-api/reference/#/operations/create-playlist The name of the playlist is the only mandatory input.

func (*Client) GetUserPlaylists

func (c *Client) GetUserPlaylists() (UserPlaylists, error)

GetUserPlaylists is targeting the endpoint described here in the spotify web api docs: https://developer.spotify.com/documentation/web-api/reference/#/operations/get-list-users-playlists xxx : this is not covering the entire functionality yet, e.g. the Pagination or the parsing of all existing response fields. This is just needed for the POC for now. ref.: https://github.com/HerrGustav/spotify-playlists/issues/1

func (*Client) IsAuthorized

func (c *Client) IsAuthorized() bool

type CreatePlaylistPayload

type CreatePlaylistPayload struct {
	Name          string `json:"name"`
	Public        bool   `json:"public"`
	Collaborative bool   `json:"collaborative"`
	Description   string `json:"description,omitempty"`
}

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type Pagination

type Pagination struct {
	Limit    int64  `json:"limit"`
	Next     string `json:"next"`
	Offset   int64  `json:"offset"`
	Previous string `json:"previous"`
	Total    int64  `json:"total"`
}

Pagination is the representation of the pagination values that are typically included in every response of the spotify web api. This here is for keeping the code a bit more dry.

type Playlist

type Playlist struct {
	Collaborative bool   `json:"collaborative"`
	Description   string `json:"description"`
	Href          string `json:"href"`
	ID            string `json:"id"`
	Name          string `json:"name"`
	Public        bool   `json:"public"`
	SnapshotID    string `json:"snapshot_id"`
	Type          string `json:"type"`
	URI           string `json:"uri"`
	Pagination
}

Playlist is a minimal representation of the response object described here: https://developer.spotify.com/documentation/web-api/reference/#/operations/create-playlist It does not aim to be the complete representation for now.

type UserPlaylists

type UserPlaylists struct {
	Href  string        `json:"href"`
	Items []interface{} `json:"items"`
	Pagination
}

UserPlaylists is the minimal representation of this response // https://developer.spotify.com/documentation/web-api/reference/#/operations/get-list-users-playlists

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL