deezer

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse added in v0.0.2

func CheckResponse(r *http.Response) error

checkResponse inspect the repsonse status code for HTTP errors and returns them as errors if present,

given an http.Client's Do() does not returns an error on non-2xx status codes.

view: https://golang.org/pkg/net/http/#Client.Do

func DoRequestWithClient

func DoRequestWithClient(client *http.Client, req *http.Request) (*http.Response, error)

DoRequestWithClient submits an HTTP request using the specified client.

Types

type APIError added in v0.0.2

type APIError struct {
	Type    string `json:"type"`
	Message string `json:"message"`
	Code    int    `json:"code"`
}

type Album

type Album struct {
	ID                    int            `json:"id"`
	Title                 string         `json:"title"`
	Upc                   string         `json:"upc"`
	Link                  string         `json:"link"`
	Share                 string         `json:"share"`
	Cover                 string         `json:"cover"`
	CoverSmall            string         `json:"cover_small"`
	CoverMedium           string         `json:"cover_medium"`
	CoverBig              string         `json:"cover_big"`
	CoverXl               string         `json:"cover_xl"`
	Md5Image              string         `json:"md5_image"`
	GenreID               int            `json:"genre_id"`
	Genres                Genres         `json:"genres"`
	Label                 string         `json:"label"`
	NbTracks              int            `json:"nb_tracks"`
	Duration              int            `json:"duration"`
	Fans                  int            `json:"fans"`
	Rating                int            `json:"rating"`
	ReleaseDate           string         `json:"release_date"`
	RecordType            string         `json:"record_type"`
	Available             bool           `json:"available"`
	Tracklist             string         `json:"tracklist"`
	ExplicitLyrics        bool           `json:"explicit_lyrics"`
	ExplicitContentLyrics int            `json:"explicit_content_lyrics"`
	ExplicitContentCover  int            `json:"explicit_content_cover"`
	Contributors          []Contributors `json:"contributors"`
	Artist                Artist         `json:"artist"`
	Type                  string         `json:"type"`
	Tracks                Tracks         `json:"tracks"`
}

Album represents an artist's album.

type AlbumService

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

AlbumService defines a client to interface with the Deezer Album service

func (*AlbumService) Get

func (a *AlbumService) Get(id string) (*Album, *Response, error)

Get fetches an Album given an album id.

func (*AlbumService) GetRaw added in v0.0.2

func (a *AlbumService) GetRaw(id string) ([]byte, *Response, error)

GetRaw fetches an Album given an album id.

type Artist

type Artist struct {
	ID            int    `json:"id"`
	Name          string `json:"name"`
	Picture       string `json:"picture"`
	PictureSmall  string `json:"picture_small"`
	PictureMedium string `json:"picture_medium"`
	PictureBig    string `json:"picture_big"`
	PictureXl     string `json:"picture_xl"`
	Tracklist     string `json:"tracklist"`
	Type          string `json:"type"`
}

Artist is for Album

type Client

type Client struct {
	URL *url.URL

	Albums *AlbumService
	// contains filtered or unexported fields
}

Client manages communication with the Deezer API.

func NewClient

func NewClient() *Client

NewClient returns a new Deezer API client.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do makes an API request and returns a custom Response. The API response is JSON and will be decoded in the value specified by v. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(method, url string, body interface{}) (*http.Request, error)

NewRequest creates a request. It takes care of using the BaseURL and setup common headers. Setting up the BaseURL allows to seamlessly use the loopback interface when using the test server.

type Contributors

type Contributors struct {
	ID            int    `json:"id"`
	Name          string `json:"name"`
	Link          string `json:"link"`
	Share         string `json:"share"`
	Picture       string `json:"picture"`
	PictureSmall  string `json:"picture_small"`
	PictureMedium string `json:"picture_medium"`
	PictureBig    string `json:"picture_big"`
	PictureXl     string `json:"picture_xl"`
	Radio         bool   `json:"radio"`
	Tracklist     string `json:"tracklist"`
	Type          string `json:"type"`
	Role          string `json:"role"`
}

Controbutors is for Album

type ErrorResponse added in v0.0.2

type ErrorResponse struct {
	// HTTP response that cause this error
	Response *http.Response

	// Error message
	Message string `json:"message"`

	// Error returned by the API on successful HTTP request
	APIError *APIError `json:"error"`

	// Carries any other error up the chain
	Carrier error
}

func (*ErrorResponse) Error added in v0.0.2

func (e *ErrorResponse) Error() string

type Genres

type Genres struct {
	Data []GenresData `json:"data"`
}

Genres is for Album

type GenresData

type GenresData struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	Picture string `json:"picture"`
	Type    string `json:"type"`
}

GenresData is for Album

type Response

type Response struct {
	*http.Response
}

Response is a wrapper for the standard http.Response. Typical use cases are: add pagination data, rate limits, etc.

type Tracks

type Tracks struct {
	Data []TracksData `json:"data"`
}

Tracks is for Album

type TracksData

type TracksData struct {
	ID                    int    `json:"id"`
	Readable              bool   `json:"readable"`
	Title                 string `json:"title"`
	TitleShort            string `json:"title_short"`
	TitleVersion          string `json:"title_version"`
	Link                  string `json:"link"`
	Duration              int    `json:"duration"`
	Rank                  int    `json:"rank"`
	ExplicitLyrics        bool   `json:"explicit_lyrics"`
	ExplicitContentLyrics int    `json:"explicit_content_lyrics"`
	ExplicitContentCover  int    `json:"explicit_content_cover"`
	Preview               string `json:"preview"`
	Md5Image              string `json:"md5_image"`
	Artist                Artist `json:"artist"`
	Type                  string `json:"type"`
}

TracksData is for Album

Jump to

Keyboard shortcuts

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