Documentation ¶
Overview ¶
Package wavy provides bindings to interact with the wavy.fm api.
Index ¶
- type Album
- type ApiError
- type Artists
- type Client
- type CurrentPlayingItem
- type Discord
- type GetCurrentResponse
- type GetHistroyStatsResponse
- type GetRecentResponse
- type GetUserProfileResponse
- type Item
- type MetricsService
- type Profile
- type Song
- type Spotify
- type UserHistoryService
- type UserListensLeaderboardResponse
- type UserService
- type UserURI
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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
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 ¶
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 GetCurrentResponse ¶
type GetCurrentResponse struct {
Item CurrentPlayingItem `json:"item"`
}
type GetHistroyStatsResponse ¶
type GetRecentResponse ¶
type GetRecentResponse struct {
Items []Item `json:"items"`
}
type GetUserProfileResponse ¶
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 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 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 ¶
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 ¶
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 ¶
String returns a properly formatted uri depending on which field is set on the struct.