client

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package client provides an (partial) implementation of Takeout API with support for authentication and tokens.

Index

Constants

View Source
const (
	BearerAuthorization = "Bearer"
)

Variables

View Source
var (
	HeaderAuthorization = http.CanonicalHeaderKey("Authorization")
	HeaderContentType   = http.CanonicalHeaderKey("Content-Type")
	HeaderLocation      = http.CanonicalHeaderKey("Location")
	HeaderUserAgent     = http.CanonicalHeaderKey("User-Agent")

	ErrClientError   = errors.New("client error")
	ErrForbidden     = errors.New("forbidden")
	ErrNoRedirection = errors.New("no redirection")
	ErrServerError   = errors.New("server error")
	ErrUnauthorized  = errors.New("unauthorized")
)

Functions

func Activity added in v0.13.0

func Activity(context Context, activity model.Events) error

func Get

func Get(context requestContext, uri string, result interface{}) error

func GetLocation

func GetLocation(context requestContext, uri string) (*url.URL, error)

func Home

func Home(context Context) (*view.Home, error)

func Locate

func Locate(context Context, uri string) (*url.URL, error)

func Patch

func Patch(context requestContext, uri string, body interface{}, result interface{}) error

func Playlist

func Playlist(context Context) (*spiff.Playlist, error)

func Position

func Position(context Context, index int, position float64) error

func Post

func Post(context requestContext, uri string, body interface{}, result interface{}) error

func Progress

func Progress(context Context) (*view.Progress, error)

func Radio

func Radio(context Context) (*view.Radio, error)

func Replace

func Replace(context Context, ref, spiffType, creator, title string) (*spiff.Playlist, error)

func SearchReplace

func SearchReplace(context Context, query string, shuffle, best bool) (*spiff.Playlist, error)

Types

type AccessCode

type AccessCode struct {
	AccessToken string
	Code        string
}

func Code

func Code(context Context) (*AccessCode, error)

type Context

type Context interface {
	Endpoint() string
	UserAgent() string
	Transport() http.RoundTripper
	Code() string
	CodeToken() string
	AccessToken() string
	RefreshToken() string
	MediaToken() string
	UpdateAccessToken(string)
}

type Headers

type Headers map[string]string

func NewHeaders

func NewHeaders() Headers

func (Headers) Authorization

func (h Headers) Authorization(bearer string) Headers

func (Headers) UserAgent

func (h Headers) UserAgent(value string) Headers

type L

type L []string

type M

type M map[string]interface{}

type Tokens

type Tokens struct {
	AccessToken  string
	RefreshToken string
	MediaToken   string `json:",omitempty"`
}

func CheckCode

func CheckCode(context Context) (*Tokens, error)

Jump to

Keyboard shortcuts

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