wavy

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package wavy provides bindings to interact with the wavy.fm api.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Album

type Album struct {
	Source    string `json:"source"`
	SourceURL string `json:"source_url"`
	Name      string `json:"name"`
	ArtURL    string `json:"art_url"`
}

type ApiError

type ApiError struct {
	Status int    `json:"status"`
	Code   string `json:"code"`
	Name   string `json:"name"`
	Detail string `json:"detail"`
}

ApiError defines the error object returned by wavy api. For more info see: https://wavy.fm/developers/docs/v1beta/errors

func (*ApiError) Error

func (a *ApiError) Error() string

type Artists

type Artists struct {
	Source    string `json:"source"`
	SourceURL string `json:"source_url"`
	Name      string `json:"name"`
}

type Client

type Client interface {
	// MetricsService
	// Reference for accessing global wavy.fm metrics.
	// https://wavy.fm/developers/docs/v1beta/metrics
	MetricsService() MetricsService
	// UserService Reference for accessing public user profiles.
	// https://wavy.fm/developers/docs/v1beta/users
	UserService() UserService
}

Client This interfacte marks the contract exposed by this SDK to interact with the wavy API. You can implement this interface for usage in mock test.

func NewClient

func NewClient(ctx context.Context, logger hclog.Logger, clientID, clientSecret string) Client
Example
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

c := NewClient(ctx, hclog.NewNullLogger(), os.Getenv("CLIENT_ID"), os.Getenv("CLIENT_SECRET"))
profile, err := c.UserService().GetProfile(ctx, UserURI{Username: "OGKevin"})
if err != nil {
	panic(err)
}

fmt.Print(profile.URI)
Output:

type CurrentPlayingItem

type CurrentPlayingItem struct {
	Local   bool      `json:"local"`
	Song    Song      `json:"song"`
	Album   Album     `json:"album"`
	Artists []Artists `json:"artists"`
}

type Discord

type Discord struct {
	ID          string `json:"id"`
	DisplayName string `json:"display_name"`
}

type GetCurrentResponse

type GetCurrentResponse struct {
	Item CurrentPlayingItem `json:"item"`
}

type GetHistroyStatsResponse

type GetHistroyStatsResponse struct {
	TotalListens int `json:"total_listens"`
	TotalArtists int `json:"total_artists"`
}

type GetRecentResponse

type GetRecentResponse struct {
	Items []Item `json:"items"`
}

type GetUserProfileResponse

type GetUserProfileResponse struct {
	URI      string    `json:"uri"`
	ID       string    `json:"id"`
	Username string    `json:"username"`
	JoinTime time.Time `json:"join_time"`
	Profile  Profile   `json:"profile"`
}

type Item

type Item struct {
	CurrentPlayingItem
	// Local   bool      `json:"local"`
	Date   time.Time `json:"date"`
	PlayID string    `json:"play_id"`
}

type MetricsService

type MetricsService interface {
	// GetTotalListens
	// Retrieves the total amount of listens recorded on wavy.fm. Note that this value is cached for a few seconds.
	GetTotalListens(ctx context.Context) (int, error)
	// GetTotalUsers
	// Retrieves the total amount of registered users on wavy.fm. Note that this value is cached for a few seconds.
	GetTotalUsers(ctx context.Context) (int, error)
	// GetUserListensLeaderboard
	// Retrieves the leaderboard of the top 10 users by listen count. Note that this endpoint is cached for a few minutes.
	GetUserListensLeaderboard(ctx context.Context) (UserListensLeaderboardResponse, error)
}

MetricsService Reference for accessing global wavy.fm metrics. https://wavy.fm/developers/docs/v1beta/metrics

type Profile

type Profile struct {
	URL         string  `json:"url"`
	Avatar      string  `json:"avatar"`
	AvatarSmall string  `json:"avatar_small"`
	Country     string  `json:"country"`
	Biography   string  `json:"biography"`
	Twitter     string  `json:"twitter"`
	Instagram   string  `json:"instagram"`
	Spotify     Spotify `json:"spotify"`
	Discord     Discord `json:"discord"`
}

type Song

type Song struct {
	Source    string `json:"source"`
	SourceURL string `json:"source_url"`
	Name      string `json:"name"`
}

type Spotify

type Spotify struct {
	ID          string `json:"id"`
	DisplayName string `json:"display_name"`
}

type UserHistoryService

type UserHistoryService interface {
	// GetHistryStats
	// Retrieves some statistics about the user's history. Note that private profiles will not be returned at all by this endpoint, regardless of authorization scopes.
	GetStats(ctx context.Context) (*GetHistroyStatsResponse, error)
	// GetCurrent
	// Retrieves the song, album, and artist(s) the user is currently listening to. Note that private profiles will not be returned at all by this endpoint, regardless of authorization scopes.
	GetCurrent(ctx context.Context) (*GetCurrentResponse, error)
	// GetRecent
	// Retrieves the most recent listens recorded by the user. Note that private profiles will not be returned at all by this endpoint, regardless of authorization scopes.
	GetRecent(ctx context.Context) (*GetRecentResponse, error)
}

type UserListensLeaderboardResponse

type UserListensLeaderboardResponse []struct {
	Count    int    `json:"count"`
	Username string `json:"username"`
	UserID   string `json:"user_id"`
}

type UserService

type UserService interface {
	// GetProfile
	// Retrieves the public profile of a wavy.fm user. Note that private profiles will not be returned at all by this endpoint, regardless of authorization scopes.
	GetProfile(ctx context.Context, uri UserURI) (*GetUserProfileResponse, error)
	// HistroyService this service gives access to the /history endpoints
	HistroyService(uri UserURI) UserHistoryService
}

UserService Reference for accessing public user profiles. https://wavy.fm/developers/docs/v1beta/users

type UserURI

type UserURI struct {
	Username  string
	UserID    string
	DiscordID string
}

UserURI Represents a data strcut to build proper UserURI. Only one of the fields should be set. UserURI is explaned on this page: https://wavy.fm/developers/docs/v1beta/overview#user-uris

func ParseUserURI

func ParseUserURI(uri string) (*UserURI, error)

ParseUserURI takes a full uri string and parses it into a struct. The uri formats are explained at: https://wavy.fm/developers/docs/v1beta/overview#user-uris

func (*UserURI) String

func (u *UserURI) String() string

String returns a properly formatted uri depending on which field is set on the struct.

func (*UserURI) UnmarshalBinary

func (u *UserURI) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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