Add comprehensive godoc documentation to all exported symbols
- Document all exported types, functions, methods, and constants across 52 files - Add package-level doc comments to client, models, utils, and ynison packages - Document HTTP method and endpoint path for each API client method - Document model struct fields and DeJSON/DeList/ToJSON/ToMap methods - Fix duplicate package doc comment in internal/models/base.go Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
1 parent
7a68ad86cb
commit
0456ca0665
54 files changed
+1097
-652
No files matched your search
+13
-12
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// AccountSettings represents account settings
|
||||
// AccountSettings represents account settings from the Yandex Music API.
|
||||
type AccountSettings struct {
|
||||
BaseModel
|
||||
Language string `json:"language"`
|
||||
@@ -26,7 +27,7 @@ type AccountSettings struct {
|
||||
DownloadOnWifiOnly bool `json:"download_on_wifi_only"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes AccountSettings from JSON
|
||||
// DeJSON deserializes AccountSettings from JSON data.
|
||||
func (a *AccountSettings) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -90,7 +91,7 @@ func (a *AccountSettings) DeJSON(data []byte, c ClientInterface) (Model, error)
|
||||
return settings, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of AccountSettings
|
||||
// DeList deserializes a list of AccountSettings from JSON data.
|
||||
func (a *AccountSettings) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -108,7 +109,7 @@ func (a *AccountSettings) DeList(data []byte, c ClientInterface) ([]Model, error
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Subscription represents subscription info
|
||||
// Subscription represents subscription info.
|
||||
type Subscription struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -127,7 +128,7 @@ type Subscription struct {
|
||||
TrialUsed bool `json:"trial_used"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes Subscription from JSON
|
||||
// DeJSON deserializes Subscription from JSON data.
|
||||
func (s *Subscription) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -182,7 +183,7 @@ func (s *Subscription) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return sub, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Subscriptions
|
||||
// DeList deserializes a list of Subscriptions from JSON data.
|
||||
func (s *Subscription) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -200,7 +201,7 @@ func (s *Subscription) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// PlusInfo represents Plus subscription info (from /account/plus or account status)
|
||||
// PlusInfo represents Plus subscription info.
|
||||
type PlusInfo struct {
|
||||
BaseModel
|
||||
HasPlus bool `json:"has_plus"`
|
||||
@@ -208,7 +209,7 @@ type PlusInfo struct {
|
||||
Migrated *bool `json:"migrated,omitempty"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes PlusInfo from JSON
|
||||
// DeJSON deserializes PlusInfo from JSON data.
|
||||
func (p *PlusInfo) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -232,7 +233,7 @@ func (p *PlusInfo) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return plus, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of PlusInfo
|
||||
// DeList deserializes a list of PlusInfo from JSON data.
|
||||
func (p *PlusInfo) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -250,7 +251,7 @@ func (p *PlusInfo) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// PromoCodeStatus represents promo code status
|
||||
// PromoCodeStatus represents promo code status.
|
||||
type PromoCodeStatus struct {
|
||||
BaseModel
|
||||
Code string `json:"code"`
|
||||
@@ -262,7 +263,7 @@ type PromoCodeStatus struct {
|
||||
Activated bool `json:"activated"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes PromoCodeStatus from JSON
|
||||
// DeJSON deserializes PromoCodeStatus from JSON data.
|
||||
func (p *PromoCodeStatus) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -296,7 +297,7 @@ func (p *PromoCodeStatus) DeJSON(data []byte, c ClientInterface) (Model, error)
|
||||
return promo, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of PromoCodeStatus
|
||||
// DeList deserializes a list of PromoCodeStatus from JSON data.
|
||||
func (p *PromoCodeStatus) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
|
||||
+13
-12
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Album represents a full album
|
||||
// Album represents a full album from the Yandex Music API.
|
||||
type Album struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -34,7 +35,7 @@ type Album struct {
|
||||
Trailer *TrailerInfo `json:"trailer"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes an Album from JSON
|
||||
// DeJSON deserializes an Album from JSON data.
|
||||
func (a *Album) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -138,7 +139,7 @@ func (a *Album) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return album, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Albums
|
||||
// DeList deserializes a list of Albums from JSON data.
|
||||
func (a *Album) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -156,14 +157,14 @@ func (a *Album) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AlbumMeta represents album metadata
|
||||
// AlbumMeta represents album metadata.
|
||||
type AlbumMeta struct {
|
||||
BaseModel
|
||||
Availability *Availability `json:"availability"`
|
||||
Upsell *Upsell `json:"upsell"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes an AlbumMeta from JSON
|
||||
// DeJSON deserializes an AlbumMeta from JSON data.
|
||||
func (am *AlbumMeta) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -186,7 +187,7 @@ func (am *AlbumMeta) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return meta, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of AlbumMeta
|
||||
// DeList deserializes a list of AlbumMeta from JSON data.
|
||||
func (am *AlbumMeta) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -204,24 +205,24 @@ func (am *AlbumMeta) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Availability represents availability info
|
||||
// Availability represents availability info for an album.
|
||||
type Availability struct {
|
||||
AvailableForPremiumUsers bool `json:"available_for_premium_users"`
|
||||
Territories []string `json:"territories"`
|
||||
}
|
||||
|
||||
// Upsell represents upsell info
|
||||
// Upsell represents upsell info for an album.
|
||||
type Upsell struct {
|
||||
Type string `json:"type"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// Best represents best tracks info
|
||||
// Best represents best tracks info for an album.
|
||||
type Best struct {
|
||||
Tracks []Track `json:"tracks"`
|
||||
}
|
||||
|
||||
// TrailerInfo represents album/track trailer info
|
||||
// TrailerInfo represents album/track trailer info.
|
||||
type TrailerInfo struct {
|
||||
BaseModel
|
||||
PreviewURI string `json:"preview_uri"`
|
||||
@@ -230,7 +231,7 @@ type TrailerInfo struct {
|
||||
Duration int `json:"duration"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a TrailerInfo from JSON
|
||||
// DeJSON deserializes a TrailerInfo from JSON data.
|
||||
func (ti *TrailerInfo) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -255,7 +256,7 @@ func (ti *TrailerInfo) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return trailer, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of TrailerInfo
|
||||
// DeList deserializes a list of TrailerInfo from JSON data.
|
||||
func (ti *TrailerInfo) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
|
||||
+17
-16
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Artist represents a full artist
|
||||
// Artist represents a full artist from the Yandex Music API.
|
||||
type Artist struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -34,7 +35,7 @@ type Artist struct {
|
||||
TracksData []Track `json:"tracks_data"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes an Artist from JSON
|
||||
// DeJSON deserializes an Artist from JSON data.
|
||||
func (a *Artist) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -146,7 +147,7 @@ func (a *Artist) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return artist, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Artists
|
||||
// DeList deserializes a list of Artists from JSON data.
|
||||
func (a *Artist) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -164,27 +165,27 @@ func (a *Artist) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Ratings represents artist ratings
|
||||
// Ratings represents artist ratings.
|
||||
type Ratings struct {
|
||||
Rating float64 `json:"rating"`
|
||||
Votes int `json:"votes"`
|
||||
}
|
||||
|
||||
// Counts represents artist counts
|
||||
// Counts represents artist counts.
|
||||
type Counts struct {
|
||||
Tracks int `json:"tracks"`
|
||||
Albums int `json:"albums"`
|
||||
Folders int `json:"folders"`
|
||||
}
|
||||
|
||||
// SocialLink represents a social media link
|
||||
// SocialLink represents a social media link.
|
||||
type SocialLink struct {
|
||||
URL string `json:"url"`
|
||||
Title string `json:"title"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// Cover represents cover image info
|
||||
// Cover represents cover image info.
|
||||
type Cover struct {
|
||||
URI string `json:"uri"`
|
||||
Type string `json:"type"`
|
||||
@@ -193,13 +194,13 @@ type Cover struct {
|
||||
Background string `json:"background"`
|
||||
}
|
||||
|
||||
// ArtistBriefInfo represents brief artist info
|
||||
// ArtistBriefInfo represents brief artist info.
|
||||
type ArtistBriefInfo struct {
|
||||
Description string `json:"description"`
|
||||
Available bool `json:"available"`
|
||||
}
|
||||
|
||||
// ArtistDonations represents artist donations info
|
||||
// ArtistDonations represents artist donations info.
|
||||
type ArtistDonations struct {
|
||||
Items []DonationItem `json:"items"`
|
||||
Total int `json:"total"`
|
||||
@@ -207,7 +208,7 @@ type ArtistDonations struct {
|
||||
Raised int `json:"raised"`
|
||||
}
|
||||
|
||||
// DonationItem represents a donation item
|
||||
// DonationItem represents a donation item.
|
||||
type DonationItem struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
@@ -218,7 +219,7 @@ type DonationItem struct {
|
||||
Currency string `json:"currency"`
|
||||
}
|
||||
|
||||
// ConcertShort represents a concert (minimal for artist)
|
||||
// ConcertShort represents a concert (minimal for artist).
|
||||
type ConcertShort struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -233,7 +234,7 @@ type ConcertShort struct {
|
||||
Available bool `json:"available"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a ConcertShort from JSON
|
||||
// DeJSON deserializes a ConcertShort from JSON data.
|
||||
func (c *ConcertShort) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -276,7 +277,7 @@ func (c *ConcertShort) DeJSON(data []byte, client ClientInterface) (Model, error
|
||||
return concert, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of ConcertShort
|
||||
// DeList deserializes a list of ConcertShort from JSON data.
|
||||
func (c *ConcertShort) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -294,7 +295,7 @@ func (c *ConcertShort) DeList(data []byte, client ClientInterface) ([]Model, err
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ClipShort represents a clip (minimal for artist)
|
||||
// ClipShort represents a clip (minimal for artist).
|
||||
type ClipShort struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -308,7 +309,7 @@ type ClipShort struct {
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a ClipShort from JSON
|
||||
// DeJSON deserializes a ClipShort from JSON data.
|
||||
func (c *ClipShort) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -348,7 +349,7 @@ func (c *ClipShort) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
return clip, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of ClipShort
|
||||
// DeList deserializes a list of ClipShort from JSON data.
|
||||
func (c *ClipShort) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// ArtistAlbums represents a page of albums by an artist
|
||||
// ArtistAlbums represents a page of albums by an artist.
|
||||
type ArtistAlbums struct {
|
||||
BaseModel
|
||||
Albums []Album `json:"albums"`
|
||||
Pager *Pager `json:"pager"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes an ArtistAlbums from JSON
|
||||
// DeJSON deserializes an ArtistAlbums from JSON data.
|
||||
func (aa *ArtistAlbums) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -36,7 +37,7 @@ func (aa *ArtistAlbums) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return albums, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of ArtistAlbums
|
||||
// DeList deserializes a list of ArtistAlbums from JSON data.
|
||||
func (aa *ArtistAlbums) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// ArtistTracks represents a page of tracks by an artist
|
||||
// ArtistTracks represents a page of tracks by an artist.
|
||||
type ArtistTracks struct {
|
||||
BaseModel
|
||||
Tracks []Track `json:"tracks"`
|
||||
Pager *Pager `json:"pager"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes an ArtistTracks from JSON
|
||||
// DeJSON deserializes an ArtistTracks from JSON data.
|
||||
func (at *ArtistTracks) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -36,7 +37,7 @@ func (at *ArtistTracks) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return tracks, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of ArtistTracks
|
||||
// DeList deserializes a list of ArtistTracks from JSON data.
|
||||
func (at *ArtistTracks) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
|
||||
+16
-13
@@ -8,35 +8,38 @@ import (
|
||||
"gitea.mrixs.me/Mrixs/yandex-music-api-go/internal/utils"
|
||||
)
|
||||
|
||||
// Model is the base interface for all models
|
||||
// Model is the base interface for all models.
|
||||
// All model types implement this interface for JSON deserialization and serialization.
|
||||
type Model interface {
|
||||
// DeJSON deserializes from JSON
|
||||
// DeJSON deserializes a model from JSON data.
|
||||
DeJSON(data []byte, c ClientInterface) (Model, error)
|
||||
// DeList deserializes a list of models
|
||||
// DeList deserializes a list of models from JSON data.
|
||||
DeList(data []byte, c ClientInterface) ([]Model, error)
|
||||
// ToJSON serializes to JSON
|
||||
// ToJSON serializes the model to JSON.
|
||||
ToJSON() ([]byte, error)
|
||||
// ToMap converts to map
|
||||
// ToMap converts the model to a map.
|
||||
ToMap() (map[string]any, error)
|
||||
}
|
||||
|
||||
// BaseModel provides common functionality for models
|
||||
// BaseModel provides common functionality for models, including a client reference.
|
||||
type BaseModel struct {
|
||||
Client ClientInterface `json:"-"`
|
||||
}
|
||||
|
||||
// NewBaseModel creates a new BaseModel
|
||||
// NewBaseModel creates a new BaseModel with the given client interface.
|
||||
func NewBaseModel(c ClientInterface) *BaseModel {
|
||||
return &BaseModel{Client: c}
|
||||
}
|
||||
|
||||
// DeJSON implements Model.DeJSON for basic models
|
||||
// DeJSON implements Model.DeJSON for basic models.
|
||||
// This should be overridden by concrete types.
|
||||
func (b *BaseModel) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
// This should be overridden by concrete types
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// DeList implements Model.DeList for basic models
|
||||
// DeList implements Model.DeList for basic models.
|
||||
// This should be overridden by concrete types.
|
||||
func (b *BaseModel) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -51,12 +54,12 @@ func (b *BaseModel) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ToJSON serializes the model to JSON
|
||||
// ToJSON serializes the model to JSON using the default JSON backend.
|
||||
func (b *BaseModel) ToJSON() ([]byte, error) {
|
||||
return utils.Marshal(b)
|
||||
}
|
||||
|
||||
// ToMap converts the model to a map
|
||||
// ToMap converts the model to a map by serializing to JSON and unmarshaling into a map.
|
||||
func (b *BaseModel) ToMap() (map[string]any, error) {
|
||||
data, err := b.ToJSON()
|
||||
if err != nil {
|
||||
@@ -69,12 +72,12 @@ func (b *BaseModel) ToMap() (map[string]any, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SetClient sets the client on the model
|
||||
// SetClient sets the client interface on the model.
|
||||
func (b *BaseModel) SetClient(c ClientInterface) {
|
||||
b.Client = c
|
||||
}
|
||||
|
||||
// GetClient returns the client
|
||||
// GetClient returns the client interface associated with the model.
|
||||
func (b *BaseModel) GetClient() ClientInterface {
|
||||
return b.Client
|
||||
}
|
||||
@@ -1,19 +1,28 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// ClientInterface defines the minimal client interface needed by models
|
||||
// ClientInterface defines the minimal client interface needed by models.
|
||||
// Models use this to access the underlying request handler.
|
||||
type ClientInterface interface {
|
||||
// GetRequest returns the underlying request handler.
|
||||
GetRequest() RequestInterface
|
||||
}
|
||||
|
||||
// RequestInterface defines the minimal request interface needed by models
|
||||
// RequestInterface defines the minimal request interface needed by models.
|
||||
// It provides methods for making HTTP requests to the Yandex Music API.
|
||||
type RequestInterface interface {
|
||||
// Get performs a GET request to the given path with query parameters.
|
||||
Get(ctx context.Context, path string, params map[string]string, result any) error
|
||||
// Post performs a POST request to the given path with a JSON body.
|
||||
Post(ctx context.Context, path string, body any, result any) error
|
||||
// Put performs a PUT request to the given path with a JSON body.
|
||||
Put(ctx context.Context, path string, body any, result any) error
|
||||
// Delete performs a DELETE request to the given path with an optional JSON body.
|
||||
Delete(ctx context.Context, path string, body any, result any) error
|
||||
// Download downloads a file from the given URL and returns the raw response body.
|
||||
Download(ctx context.Context, url string) ([]byte, error)
|
||||
}
|
||||
+13
-12
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Clip represents a clip (short video)
|
||||
// Clip represents a clip (short video) from the Yandex Music API.
|
||||
type Clip struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -24,7 +25,7 @@ type Clip struct {
|
||||
AspectRatio string `json:"aspect_ratio"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Clip from JSON
|
||||
// DeJSON deserializes a Clip from JSON data.
|
||||
func (c *Clip) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -89,7 +90,7 @@ func (c *Clip) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
return clip, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Clips
|
||||
// DeList deserializes a list of Clips from JSON data.
|
||||
func (c *Clip) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -107,28 +108,28 @@ func (c *Clip) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ClipsWillLike represents clips the user might like
|
||||
// ClipsWillLike represents clips the user might like.
|
||||
type ClipsWillLike struct {
|
||||
BaseModel
|
||||
Clips []Clip `json:"clips"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// ArtistClipData represents artist clip data
|
||||
// ArtistClipData represents artist clip data.
|
||||
type ArtistClipData struct {
|
||||
BaseModel
|
||||
Clips []Clip `json:"clips"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// ArtistClipItem represents an artist clip item
|
||||
// ArtistClipItem represents an artist clip item.
|
||||
type ArtistClipItem struct {
|
||||
BaseModel
|
||||
Clip *Clip `json:"clip"`
|
||||
Index int `json:"index"`
|
||||
}
|
||||
|
||||
// Shot represents a shot (short video)
|
||||
// Shot represents a shot (short video).
|
||||
type Shot struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -150,7 +151,7 @@ type Shot struct {
|
||||
AspectRatio string `json:"aspect_ratio"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Shot from JSON
|
||||
// DeJSON deserializes a Shot from JSON data.
|
||||
func (s *Shot) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -219,7 +220,7 @@ func (s *Shot) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
return shot, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Shots
|
||||
// DeList deserializes a list of Shots from JSON data.
|
||||
func (s *Shot) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -237,14 +238,14 @@ func (s *Shot) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ShotData represents shot data
|
||||
// ShotData represents shot data.
|
||||
type ShotData struct {
|
||||
BaseModel
|
||||
Shots []Shot `json:"shots"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// ShotEvent represents a shot event
|
||||
// ShotEvent represents a shot event.
|
||||
type ShotEvent struct {
|
||||
BaseModel
|
||||
EventID string `json:"event_id"`
|
||||
@@ -254,7 +255,7 @@ type ShotEvent struct {
|
||||
Action string `json:"action"`
|
||||
}
|
||||
|
||||
// ShotType represents a shot type
|
||||
// ShotType represents a shot type.
|
||||
type ShotType struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
|
||||
+17
-16
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Concert represents a concert
|
||||
// Concert represents a concert from the Yandex Music API.
|
||||
type Concert struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -28,7 +29,7 @@ type Concert struct {
|
||||
Skeleton *ConcertSkeleton `json:"skeleton"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Concert from JSON
|
||||
// DeJSON deserializes a Concert from JSON data.
|
||||
func (c *Concert) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -111,7 +112,7 @@ func (c *Concert) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
return concert, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Concerts
|
||||
// DeList deserializes a list of Concerts from JSON data.
|
||||
func (c *Concert) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -129,7 +130,7 @@ func (c *Concert) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ConcertVenue represents a concert venue
|
||||
// ConcertVenue represents a concert venue.
|
||||
type ConcertVenue struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -141,7 +142,7 @@ type ConcertVenue struct {
|
||||
ImageURI string `json:"image_uri"`
|
||||
}
|
||||
|
||||
// ConcertLocation represents a concert location
|
||||
// ConcertLocation represents a concert location.
|
||||
type ConcertLocation struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -152,7 +153,7 @@ type ConcertLocation struct {
|
||||
Venues []ConcertVenue `json:"venues"`
|
||||
}
|
||||
|
||||
// ConcertLocations represents concert locations
|
||||
// ConcertLocations represents concert locations.
|
||||
type ConcertLocations struct {
|
||||
BaseModel
|
||||
Locations []ConcertLocation `json:"locations"`
|
||||
@@ -161,7 +162,7 @@ type ConcertLocations struct {
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// ConcertFeed represents a concert feed
|
||||
// ConcertFeed represents a concert feed.
|
||||
type ConcertFeed struct {
|
||||
BaseModel
|
||||
Concerts []Concert `json:"concerts"`
|
||||
@@ -170,14 +171,14 @@ type ConcertFeed struct {
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// ConcertInfo represents concert info
|
||||
// ConcertInfo represents concert info.
|
||||
type ConcertInfo struct {
|
||||
BaseModel
|
||||
Concert *Concert `json:"concert"`
|
||||
Related []Concert `json:"related"`
|
||||
}
|
||||
|
||||
// ConcertEventInfo represents concert event info
|
||||
// ConcertEventInfo represents concert event info.
|
||||
type ConcertEventInfo struct {
|
||||
BaseModel
|
||||
EventID string `json:"event_id"`
|
||||
@@ -186,7 +187,7 @@ type ConcertEventInfo struct {
|
||||
Data json.RawMessage `json:"data"`
|
||||
}
|
||||
|
||||
// ConcertDescription represents concert description
|
||||
// ConcertDescription represents concert description.
|
||||
type ConcertDescription struct {
|
||||
BaseModel
|
||||
Text string `json:"text"`
|
||||
@@ -194,7 +195,7 @@ type ConcertDescription struct {
|
||||
ShortText string `json:"short_text"`
|
||||
}
|
||||
|
||||
// ConcertCashback represents concert cashback
|
||||
// ConcertCashback represents concert cashback.
|
||||
type ConcertCashback struct {
|
||||
BaseModel
|
||||
Amount int `json:"amount"`
|
||||
@@ -203,14 +204,14 @@ type ConcertCashback struct {
|
||||
Expires string `json:"expires"`
|
||||
}
|
||||
|
||||
// ConcertMinPrice represents concert min price
|
||||
// ConcertMinPrice represents concert min price.
|
||||
type ConcertMinPrice struct {
|
||||
BaseModel
|
||||
Price int `json:"price"`
|
||||
Currency string `json:"currency"`
|
||||
}
|
||||
|
||||
// ConcertTabConfig represents concert tab config
|
||||
// ConcertTabConfig represents concert tab config.
|
||||
type ConcertTabConfig struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -220,20 +221,20 @@ type ConcertTabConfig struct {
|
||||
Range *ConcertTabRange `json:"range"`
|
||||
}
|
||||
|
||||
// ConcertTabRange represents concert tab range
|
||||
// ConcertTabRange represents concert tab range.
|
||||
type ConcertTabRange struct {
|
||||
BaseModel
|
||||
From string `json:"from"`
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
// ConcertSkeleton represents concert skeleton
|
||||
// ConcertSkeleton represents concert skeleton.
|
||||
type ConcertSkeleton struct {
|
||||
BaseModel
|
||||
Blocks []ConcertSkeletonBlock `json:"blocks"`
|
||||
}
|
||||
|
||||
// ConcertSkeletonBlock represents a concert skeleton block
|
||||
// ConcertSkeletonBlock represents a concert skeleton block.
|
||||
type ConcertSkeletonBlock struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Credits represents track credits
|
||||
// Credits represents track credits from the Yandex Music API.
|
||||
type Credits struct {
|
||||
BaseModel
|
||||
Items []Credit `json:"items"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes Credits from JSON
|
||||
// DeJSON deserializes Credits from JSON data.
|
||||
func (c *Credits) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -32,7 +33,7 @@ func (c *Credits) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
return credits, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Credits
|
||||
// DeList deserializes a list of Credits from JSON data. from JSON data.
|
||||
func (c *Credits) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -50,7 +51,7 @@ func (c *Credits) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Credit represents a credit
|
||||
// Credit represents a credit.
|
||||
type Credit struct {
|
||||
BaseModel
|
||||
Role string `json:"role"`
|
||||
@@ -62,7 +63,7 @@ type Credit struct {
|
||||
AlbumID string `json:"album_id"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Credit from JSON
|
||||
// DeJSON deserializes a Credit from JSON data.
|
||||
func (c *Credit) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -114,7 +115,7 @@ func (c *Credit) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// LicenceTextPart represents a licence text part
|
||||
// LicenceTextPart represents a licence text part.
|
||||
type LicenceTextPart struct {
|
||||
BaseModel
|
||||
Text string `json:"text"`
|
||||
@@ -124,7 +125,7 @@ type LicenceTextPart struct {
|
||||
IsMain bool `json:"is_main"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a LicenceTextPart from JSON
|
||||
// DeJSON deserializes a LicenceTextPart from JSON data.
|
||||
func (ltp *LicenceTextPart) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -152,7 +153,7 @@ func (ltp *LicenceTextPart) DeJSON(data []byte, client ClientInterface) (Model,
|
||||
return part, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of LicenceTextPart
|
||||
// DeList deserializes a list of LicenceTextPart from JSON data.
|
||||
func (ltp *LicenceTextPart) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
|
||||
+18
-17
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Feed represents the main feed
|
||||
// Feed represents the main feed from the Yandex Music API.
|
||||
type Feed struct {
|
||||
BaseModel
|
||||
Days []Day `json:"days"`
|
||||
@@ -12,7 +13,7 @@ type Feed struct {
|
||||
PlayContexts []PlayContext `json:"play_contexts"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Feed from JSON
|
||||
// DeJSON deserializes a Feed from JSON data.
|
||||
func (f *Feed) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -40,7 +41,7 @@ func (f *Feed) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return feed, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Feeds
|
||||
// DeList deserializes a list of Feeds from JSON data.
|
||||
func (f *Feed) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -58,7 +59,7 @@ func (f *Feed) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Day represents a day in the feed
|
||||
// Day represents a day in the feed.
|
||||
type Day struct {
|
||||
BaseModel
|
||||
Date string `json:"date"`
|
||||
@@ -68,7 +69,7 @@ type Day struct {
|
||||
GeneratedPlaylists []GeneratedPlaylist `json:"generated_playlists"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Day from JSON
|
||||
// DeJSON deserializes a Day from JSON data.
|
||||
func (d *Day) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -100,7 +101,7 @@ func (d *Day) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return day, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Days
|
||||
// DeList deserializes a list of Days from JSON data.
|
||||
func (d *Day) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -118,7 +119,7 @@ func (d *Day) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DayBlock represents a block in a day
|
||||
// DayBlock represents a block in a day.
|
||||
type DayBlock struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -128,7 +129,7 @@ type DayBlock struct {
|
||||
Data *DayBlockData `json:"data"`
|
||||
}
|
||||
|
||||
// DayBlockData represents data in a day block
|
||||
// DayBlockData represents data in a day block.
|
||||
type DayBlockData struct {
|
||||
Tracks []Track `json:"tracks"`
|
||||
Playlists []Playlist `json:"playlists"`
|
||||
@@ -137,7 +138,7 @@ type DayBlockData struct {
|
||||
GeneratedPlaylist *GeneratedPlaylist `json:"generated_playlist"`
|
||||
}
|
||||
|
||||
// GeneratedPlaylist represents a generated playlist
|
||||
// GeneratedPlaylist represents a generated playlist.
|
||||
type GeneratedPlaylist struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -153,7 +154,7 @@ type GeneratedPlaylist struct {
|
||||
Tracks []Track `json:"tracks"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a GeneratedPlaylist from JSON
|
||||
// DeJSON deserializes a GeneratedPlaylist from JSON data.
|
||||
func (gp *GeneratedPlaylist) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -201,7 +202,7 @@ func (gp *GeneratedPlaylist) DeJSON(data []byte, c ClientInterface) (Model, erro
|
||||
return playlist, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of GeneratedPlaylists
|
||||
// DeList deserializes a list of GeneratedPlaylists from JSON data.
|
||||
func (gp *GeneratedPlaylist) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -219,7 +220,7 @@ func (gp *GeneratedPlaylist) DeList(data []byte, c ClientInterface) ([]Model, er
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Event represents a feed event
|
||||
// Event represents a feed event.
|
||||
type Event struct {
|
||||
BaseModel
|
||||
Timestamp string `json:"timestamp"`
|
||||
@@ -231,7 +232,7 @@ type Event struct {
|
||||
Action string `json:"action"`
|
||||
}
|
||||
|
||||
// AlbumEvent represents an album event
|
||||
// AlbumEvent represents an album event.
|
||||
type AlbumEvent struct {
|
||||
BaseModel
|
||||
Album *Album `json:"album"`
|
||||
@@ -240,7 +241,7 @@ type AlbumEvent struct {
|
||||
Action string `json:"action"`
|
||||
}
|
||||
|
||||
// ArtistEvent represents an artist event
|
||||
// ArtistEvent represents an artist event.
|
||||
type ArtistEvent struct {
|
||||
BaseModel
|
||||
Artist *Artist `json:"artist"`
|
||||
@@ -249,7 +250,7 @@ type ArtistEvent struct {
|
||||
Action string `json:"action"`
|
||||
}
|
||||
|
||||
// TrackWithAds represents a track with ads
|
||||
// TrackWithAds represents a track with ads.
|
||||
type TrackWithAds struct {
|
||||
BaseModel
|
||||
Track *Track `json:"track"`
|
||||
@@ -257,7 +258,7 @@ type TrackWithAds struct {
|
||||
AdParams *AdParams `json:"ad_params"`
|
||||
}
|
||||
|
||||
// Ad represents an ad
|
||||
// Ad represents an ad.
|
||||
type Ad struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -269,7 +270,7 @@ type Ad struct {
|
||||
Duration int `json:"duration"`
|
||||
}
|
||||
|
||||
// AdParams represents ad parameters
|
||||
// AdParams represents ad parameters.
|
||||
type AdParams struct {
|
||||
BaseModel
|
||||
Frequency int `json:"frequency"`
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Label represents a label
|
||||
// Label represents a label from the Yandex Music API.
|
||||
type Label struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -17,7 +18,7 @@ type Label struct {
|
||||
Owner *User `json:"owner"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Label from JSON
|
||||
// DeJSON deserializes a Label from JSON data.
|
||||
func (l *Label) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -58,7 +59,7 @@ func (l *Label) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
return label, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Labels
|
||||
// DeList deserializes a list of Labels from JSON data.
|
||||
func (l *Label) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -76,7 +77,7 @@ func (l *Label) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// LabelAlbums represents label albums
|
||||
// LabelAlbums represents label albums.
|
||||
type LabelAlbums struct {
|
||||
BaseModel
|
||||
Albums []Album `json:"albums"`
|
||||
@@ -85,7 +86,7 @@ type LabelAlbums struct {
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// LabelArtists represents label artists
|
||||
// LabelArtists represents label artists.
|
||||
type LabelArtists struct {
|
||||
BaseModel
|
||||
Artists []Artist `json:"artists"`
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Landing represents a landing page
|
||||
// Landing represents a landing page from the Yandex Music API.
|
||||
type Landing struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -16,7 +17,7 @@ type Landing struct {
|
||||
Available bool `json:"available"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Landing from JSON
|
||||
// DeJSON deserializes a Landing from JSON data.
|
||||
func (l *Landing) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -53,7 +54,7 @@ func (l *Landing) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return landing, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Landings
|
||||
// DeList deserializes a list of Landings from JSON data.
|
||||
func (l *Landing) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -71,7 +72,7 @@ func (l *Landing) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// LandingBlock represents a block in a landing
|
||||
// LandingBlock represents a block in a landing.
|
||||
type LandingBlock struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -81,7 +82,7 @@ type LandingBlock struct {
|
||||
Data *LandingBlockData `json:"data"`
|
||||
}
|
||||
|
||||
// LandingBlockData represents data in a landing block
|
||||
// LandingBlockData represents data in a landing block.
|
||||
type LandingBlockData struct {
|
||||
Tracks []Track `json:"tracks"`
|
||||
Playlists []Playlist `json:"playlists"`
|
||||
@@ -90,7 +91,7 @@ type LandingBlockData struct {
|
||||
GeneratedPlaylist *GeneratedPlaylist `json:"generated_playlist"`
|
||||
}
|
||||
|
||||
// LandingList represents a list of landings
|
||||
// LandingList represents a list of landings.
|
||||
type LandingList struct {
|
||||
BaseModel
|
||||
Landings []Landing `json:"landings"`
|
||||
@@ -99,7 +100,7 @@ type LandingList struct {
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a LandingList from JSON
|
||||
// DeJSON deserializes a LandingList from JSON data.
|
||||
func (ll *LandingList) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -126,7 +127,7 @@ func (ll *LandingList) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of LandingLists
|
||||
// DeList deserializes a list of LandingLists from JSON data.
|
||||
func (ll *LandingList) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
|
||||
+23
-22
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Metatag represents a metatag
|
||||
// Metatag represents a metatag from the Yandex Music API.
|
||||
type Metatag struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -16,7 +17,7 @@ type Metatag struct {
|
||||
Children []Metatag `json:"children"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Metatag from JSON
|
||||
// DeJSON deserializes a Metatag from JSON data.
|
||||
func (m *Metatag) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -52,7 +53,7 @@ func (m *Metatag) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
return metatag, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Metatags
|
||||
// DeList deserializes a list of Metatags from JSON data.
|
||||
func (m *Metatag) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -70,14 +71,14 @@ func (m *Metatag) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// MetatagTree represents a metatag tree
|
||||
// MetatagTree represents a metatag tree.
|
||||
type MetatagTree struct {
|
||||
BaseModel
|
||||
Root *Metatag `json:"root"`
|
||||
Leaves []Metatag `json:"leaves"`
|
||||
}
|
||||
|
||||
// MetatagLeaf represents a metatag leaf
|
||||
// MetatagLeaf represents a metatag leaf.
|
||||
type MetatagLeaf struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -88,7 +89,7 @@ type MetatagLeaf struct {
|
||||
Position int `json:"position"`
|
||||
}
|
||||
|
||||
// MetatagArtists represents metatag artists
|
||||
// MetatagArtists represents metatag artists.
|
||||
type MetatagArtists struct {
|
||||
BaseModel
|
||||
Artists []Artist `json:"artists"`
|
||||
@@ -97,7 +98,7 @@ type MetatagArtists struct {
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// MetatagAlbums represents metatag albums
|
||||
// MetatagAlbums represents metatag albums.
|
||||
type MetatagAlbums struct {
|
||||
BaseModel
|
||||
Albums []Album `json:"albums"`
|
||||
@@ -106,7 +107,7 @@ type MetatagAlbums struct {
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// MetatagPlaylists represents metatag playlists
|
||||
// MetatagPlaylists represents metatag playlists.
|
||||
type MetatagPlaylists struct {
|
||||
BaseModel
|
||||
Playlists []Playlist `json:"playlists"`
|
||||
@@ -115,27 +116,27 @@ type MetatagPlaylists struct {
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// MetatagTitle represents a metatag title
|
||||
// MetatagTitle represents a metatag title.
|
||||
type MetatagTitle struct {
|
||||
BaseModel
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
// MetatagSortByValue represents metatag sort by value
|
||||
// MetatagSortByValue represents metatag sort by value.
|
||||
type MetatagSortByValue struct {
|
||||
BaseModel
|
||||
Value string `json:"value"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
|
||||
// MetatagArtistEntry represents a metatag artist entry
|
||||
// MetatagArtistEntry represents a metatag artist entry.
|
||||
type MetatagArtistEntry struct {
|
||||
BaseModel
|
||||
Artist *Artist `json:"artist"`
|
||||
Score float64 `json:"score"`
|
||||
}
|
||||
|
||||
// Genre represents a genre
|
||||
// Genre represents a genre from the Yandex Music API.
|
||||
type Genre struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -147,7 +148,7 @@ type Genre struct {
|
||||
Children []Genre `json:"children"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Genre from JSON
|
||||
// DeJSON deserializes a Genre from JSON data.
|
||||
func (g *Genre) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -183,7 +184,7 @@ func (g *Genre) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
return genre, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Genres
|
||||
// DeList deserializes a list of Genres from JSON data.
|
||||
func (g *Genre) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -201,7 +202,7 @@ func (g *Genre) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Chart represents a chart
|
||||
// Chart represents a chart from the Yandex Music API.
|
||||
type Chart struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -212,7 +213,7 @@ type Chart struct {
|
||||
Items []ChartItem `json:"items"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Chart from JSON
|
||||
// DeJSON deserializes a Chart from JSON data.
|
||||
func (c *Chart) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -245,7 +246,7 @@ func (c *Chart) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
return chart, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Charts
|
||||
// DeList deserializes a list of Charts from JSON data.
|
||||
func (c *Chart) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -263,14 +264,14 @@ func (c *Chart) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ChartInfo represents chart info
|
||||
// ChartInfo represents chart info.
|
||||
type ChartInfo struct {
|
||||
BaseModel
|
||||
Chart *Chart `json:"chart"`
|
||||
Menu []ChartInfoMenu `json:"menu"`
|
||||
}
|
||||
|
||||
// ChartItem represents a chart item
|
||||
// ChartItem represents a chart item.
|
||||
type ChartItem struct {
|
||||
BaseModel
|
||||
Position int `json:"position"`
|
||||
@@ -282,7 +283,7 @@ type ChartItem struct {
|
||||
Trend string `json:"trend"`
|
||||
}
|
||||
|
||||
// ChartInfoMenu represents a chart info menu
|
||||
// ChartInfoMenu represents a chart info menu.
|
||||
type ChartInfoMenu struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -291,7 +292,7 @@ type ChartInfoMenu struct {
|
||||
Items []ChartInfoMenuItem `json:"items"`
|
||||
}
|
||||
|
||||
// ChartInfoMenuItem represents a chart info menu item
|
||||
// ChartInfoMenuItem represents a chart info menu item.
|
||||
type ChartInfoMenuItem struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -300,7 +301,7 @@ type ChartInfoMenuItem struct {
|
||||
Action string `json:"action"`
|
||||
}
|
||||
|
||||
// ChartItems represents chart items response
|
||||
// ChartItems represents chart items response.
|
||||
type ChartItems struct {
|
||||
BaseModel
|
||||
Items []ChartItem `json:"items"`
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// MusicHistory represents music history
|
||||
// MusicHistory represents music history from the Yandex Music API.
|
||||
type MusicHistory struct {
|
||||
BaseModel
|
||||
Tabs []MusicHistoryTab `json:"tabs"`
|
||||
@@ -13,7 +14,7 @@ type MusicHistory struct {
|
||||
Context *MusicHistoryContextFullModel `json:"context"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a MusicHistory from JSON
|
||||
// DeJSON deserializes a MusicHistory from JSON data.
|
||||
func (mh *MusicHistory) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -46,7 +47,7 @@ func (mh *MusicHistory) DeJSON(data []byte, client ClientInterface) (Model, erro
|
||||
return history, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of MusicHistory
|
||||
// DeList deserializes a list of MusicHistory from JSON data.
|
||||
func (mh *MusicHistory) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -64,7 +65,7 @@ func (mh *MusicHistory) DeList(data []byte, client ClientInterface) ([]Model, er
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// MusicHistoryTab represents a music history tab
|
||||
// MusicHistoryTab represents a music history tab.
|
||||
type MusicHistoryTab struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -75,7 +76,7 @@ type MusicHistoryTab struct {
|
||||
Position int `json:"position"`
|
||||
}
|
||||
|
||||
// MusicHistoryGroup represents a music history group
|
||||
// MusicHistoryGroup represents a music history group.
|
||||
type MusicHistoryGroup struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -85,7 +86,7 @@ type MusicHistoryGroup struct {
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// MusicHistoryItem represents a music history item
|
||||
// MusicHistoryItem represents a music history item.
|
||||
type MusicHistoryItem struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -100,7 +101,7 @@ type MusicHistoryItem struct {
|
||||
Context *MusicHistoryItemData `json:"context"`
|
||||
}
|
||||
|
||||
// MusicHistoryItemData represents music history item data
|
||||
// MusicHistoryItemData represents music history item data.
|
||||
type MusicHistoryItemData struct {
|
||||
BaseModel
|
||||
Source string `json:"source"`
|
||||
@@ -112,14 +113,14 @@ type MusicHistoryItemData struct {
|
||||
Progress float64 `json:"progress"`
|
||||
}
|
||||
|
||||
// MusicHistoryItemID represents music history item ID
|
||||
// MusicHistoryItemID represents music history item ID.
|
||||
type MusicHistoryItemID struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// MusicHistoryItems represents music history items
|
||||
// MusicHistoryItems represents music history items.
|
||||
type MusicHistoryItems struct {
|
||||
BaseModel
|
||||
Items []MusicHistoryItem `json:"items"`
|
||||
@@ -128,7 +129,7 @@ type MusicHistoryItems struct {
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// MusicHistoryContextFullModel represents music history context full model
|
||||
// MusicHistoryContextFullModel represents music history context full model.
|
||||
type MusicHistoryContextFullModel struct {
|
||||
BaseModel
|
||||
DeviceID string `json:"device_id"`
|
||||
|
||||
+10
-9
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Pin represents a pin
|
||||
// Pin represents a pin from the Yandex Music API.
|
||||
type Pin struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -22,7 +23,7 @@ type Pin struct {
|
||||
Active bool `json:"active"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Pin from JSON
|
||||
// DeJSON deserializes a Pin from JSON data.
|
||||
func (p *Pin) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -83,7 +84,7 @@ func (p *Pin) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
return pin, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Pins
|
||||
// DeList deserializes a list of Pins from JSON data.
|
||||
func (p *Pin) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -101,14 +102,14 @@ func (p *Pin) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// PinData represents pin data
|
||||
// PinData represents pin data.
|
||||
type PinData struct {
|
||||
BaseModel
|
||||
Pins []Pin `json:"pins"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// PinsList represents a list of pins
|
||||
// PinsList represents a list of pins.
|
||||
type PinsList struct {
|
||||
BaseModel
|
||||
Pins []Pin `json:"pins"`
|
||||
@@ -117,7 +118,7 @@ type PinsList struct {
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// Presaves represents presaves
|
||||
// Presaves represents presaves.
|
||||
type Presaves struct {
|
||||
BaseModel
|
||||
Presaves []Presave `json:"presaves"`
|
||||
@@ -126,7 +127,7 @@ type Presaves struct {
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// Presave represents a presave
|
||||
// Presave represents a presave.
|
||||
type Presave struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -142,7 +143,7 @@ type Presave struct {
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Presave from JSON
|
||||
// DeJSON deserializes a Presave from JSON data.
|
||||
func (p *Presave) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -195,7 +196,7 @@ func (p *Presave) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
return presave, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Presaves
|
||||
// DeList deserializes a list of Presaves from JSON data.
|
||||
func (p *Presave) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
|
||||
+12
-11
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Playlist represents a playlist
|
||||
// Playlist represents a playlist from the Yandex Music API.
|
||||
type Playlist struct {
|
||||
BaseModel
|
||||
Kind int `json:"kind"`
|
||||
@@ -36,7 +37,7 @@ type Playlist struct {
|
||||
Trailer *TrailerInfo `json:"trailer"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Playlist from JSON
|
||||
// DeJSON deserializes a Playlist from JSON data.
|
||||
func (p *Playlist) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -142,7 +143,7 @@ func (p *Playlist) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return playlist, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Playlists
|
||||
// DeList deserializes a list of Playlists from JSON data.
|
||||
func (p *Playlist) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -160,7 +161,7 @@ func (p *Playlist) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// User represents a user (playlist owner)
|
||||
// User represents a user (playlist owner) from the Yandex Music API.
|
||||
type User struct {
|
||||
BaseModel
|
||||
UID int64 `json:"uid"`
|
||||
@@ -184,7 +185,7 @@ type User struct {
|
||||
Counters *UserCounters `json:"counters"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a User from JSON
|
||||
// DeJSON deserializes a User from JSON data.
|
||||
func (u *User) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -255,7 +256,7 @@ func (u *User) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return user, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Users
|
||||
// DeList deserializes a list of Users from JSON data.
|
||||
func (u *User) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -273,7 +274,7 @@ func (u *User) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UserSettings represents user settings (from /account/settings)
|
||||
// UserSettings represents user settings from /account/settings.
|
||||
type UserSettings struct {
|
||||
BaseModel
|
||||
UID int64 `json:"uid"`
|
||||
@@ -295,7 +296,7 @@ type UserSettings struct {
|
||||
ShowDiskTracksInLibrary *bool `json:"show_disk_tracks_in_library,omitempty"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes UserSettings from JSON
|
||||
// DeJSON deserializes UserSettings from JSON data.
|
||||
func (u *UserSettings) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -365,7 +366,7 @@ func (u *UserSettings) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return settings, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of UserSettings
|
||||
// DeList deserializes a list of UserSettings from JSON data.
|
||||
func (u *UserSettings) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -383,7 +384,7 @@ func (u *UserSettings) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UserCounters represents user counters
|
||||
// UserCounters represents user counters.
|
||||
type UserCounters struct {
|
||||
Tracks int `json:"tracks"`
|
||||
Albums int `json:"albums"`
|
||||
@@ -393,7 +394,7 @@ type UserCounters struct {
|
||||
Likes int `json:"likes"`
|
||||
}
|
||||
|
||||
// Image represents an image with multiple sizes
|
||||
// Image represents an image with multiple sizes.
|
||||
type Image struct {
|
||||
URI string `json:"uri"`
|
||||
Type string `json:"type"`
|
||||
|
||||
+13
-12
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Queue represents a playback queue
|
||||
// Queue represents a playback queue from the Yandex Music API.
|
||||
type Queue struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -20,7 +21,7 @@ type Queue struct {
|
||||
TotalDuration int `json:"total_duration_ms"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Queue from JSON
|
||||
// DeJSON deserializes a Queue from JSON data.
|
||||
func (q *Queue) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -71,7 +72,7 @@ func (q *Queue) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return queue, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Queues
|
||||
// DeList deserializes a list of Queues from JSON data.
|
||||
func (q *Queue) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -89,7 +90,7 @@ func (q *Queue) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// QueueItem represents a queue item
|
||||
// QueueItem represents a queue item.
|
||||
type QueueItem struct {
|
||||
BaseModel
|
||||
TrackID string `json:"track_id"`
|
||||
@@ -101,7 +102,7 @@ type QueueItem struct {
|
||||
PlayContext *PlayContext `json:"play_context"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a QueueItem from JSON
|
||||
// DeJSON deserializes a QueueItem from JSON data.
|
||||
func (qi *QueueItem) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -140,7 +141,7 @@ func (qi *QueueItem) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of QueueItems
|
||||
// DeList deserializes a list of QueueItems from JSON data.
|
||||
func (qi *QueueItem) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -158,7 +159,7 @@ func (qi *QueueItem) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// PlayContext represents a play context
|
||||
// PlayContext represents a play context.
|
||||
type PlayContext struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -173,7 +174,7 @@ type PlayContext struct {
|
||||
Available bool `json:"available"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a PlayContext from JSON
|
||||
// DeJSON deserializes a PlayContext from JSON data.
|
||||
func (pc *PlayContext) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -219,7 +220,7 @@ func (pc *PlayContext) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of PlayContexts
|
||||
// DeList deserializes a list of PlayContexts from JSON data.
|
||||
func (pc *PlayContext) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -237,7 +238,7 @@ func (pc *PlayContext) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// PlayContextsData represents play contexts data
|
||||
// PlayContextsData represents play contexts data.
|
||||
type PlayContextsData struct {
|
||||
BaseModel
|
||||
Contexts []PlayContext `json:"contexts"`
|
||||
@@ -246,7 +247,7 @@ type PlayContextsData struct {
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes PlayContextsData from JSON
|
||||
// DeJSON deserializes PlayContextsData from JSON data.
|
||||
func (pcd *PlayContextsData) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -273,7 +274,7 @@ func (pcd *PlayContextsData) DeJSON(data []byte, c ClientInterface) (Model, erro
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of PlayContextsData
|
||||
// DeList deserializes a list of PlayContextsData from JSON data.
|
||||
func (pcd *PlayContextsData) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
|
||||
+19
-18
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// RadioStation represents a radio station
|
||||
// RadioStation represents a radio station from the Yandex Music API.
|
||||
type RadioStation struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -16,7 +17,7 @@ type RadioStation struct {
|
||||
IsPersonal bool `json:"is_personal"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a RadioStation from JSON
|
||||
// DeJSON deserializes a RadioStation from JSON data.
|
||||
func (r *RadioStation) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -50,7 +51,7 @@ func (r *RadioStation) DeJSON(data []byte, client ClientInterface) (Model, error
|
||||
return station, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of RadioStations
|
||||
// DeList deserializes a list of RadioStations from JSON data.
|
||||
func (r *RadioStation) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -68,7 +69,7 @@ func (r *RadioStation) DeList(data []byte, client ClientInterface) ([]Model, err
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// StationTracksResult represents station tracks result
|
||||
// StationTracksResult represents station tracks result.
|
||||
type StationTracksResult struct {
|
||||
BaseModel
|
||||
Tracks []Track `json:"tracks"`
|
||||
@@ -76,7 +77,7 @@ type StationTracksResult struct {
|
||||
Sequence string `json:"sequence"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes StationTracksResult from JSON
|
||||
// DeJSON deserializes StationTracksResult from JSON data.
|
||||
func (s *StationTracksResult) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -100,7 +101,7 @@ func (s *StationTracksResult) DeJSON(data []byte, client ClientInterface) (Model
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of StationTracksResult
|
||||
// DeList deserializes a list of StationTracksResult from JSON data.
|
||||
func (s *StationTracksResult) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -118,7 +119,7 @@ func (s *StationTracksResult) DeList(data []byte, client ClientInterface) ([]Mod
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// RotorStation represents a rotor (generative) station
|
||||
// RotorStation represents a rotor (generative) station.
|
||||
type RotorStation struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -131,7 +132,7 @@ type RotorStation struct {
|
||||
Settings *RotorSettings `json:"settings"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a RotorStation from JSON
|
||||
// DeJSON deserializes a RotorStation from JSON data.
|
||||
func (r *RotorStation) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -170,7 +171,7 @@ func (r *RotorStation) DeJSON(data []byte, client ClientInterface) (Model, error
|
||||
return station, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of RotorStations
|
||||
// DeList deserializes a list of RotorStations from JSON data.
|
||||
func (r *RotorStation) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -188,7 +189,7 @@ func (r *RotorStation) DeList(data []byte, client ClientInterface) ([]Model, err
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// RotorSettings represents rotor station settings
|
||||
// RotorSettings represents rotor station settings.
|
||||
type RotorSettings struct {
|
||||
BaseModel
|
||||
Diversity float64 `json:"diversity"`
|
||||
@@ -201,7 +202,7 @@ type RotorSettings struct {
|
||||
Valence float64 `json:"valence"`
|
||||
}
|
||||
|
||||
// RotorStationTracksResult represents rotor station tracks result
|
||||
// RotorStationTracksResult represents rotor station tracks result.
|
||||
type RotorStationTracksResult struct {
|
||||
BaseModel
|
||||
Tracks []Track `json:"tracks"`
|
||||
@@ -209,7 +210,7 @@ type RotorStationTracksResult struct {
|
||||
Sequence string `json:"sequence"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes RotorStationTracksResult from JSON
|
||||
// DeJSON deserializes RotorStationTracksResult from JSON data.
|
||||
func (r *RotorStationTracksResult) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -233,7 +234,7 @@ func (r *RotorStationTracksResult) DeJSON(data []byte, client ClientInterface) (
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of RotorStationTracksResult
|
||||
// DeList deserializes a list of RotorStationTracksResult from JSON data.
|
||||
func (r *RotorStationTracksResult) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -251,7 +252,7 @@ func (r *RotorStationTracksResult) DeList(data []byte, client ClientInterface) (
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// RotorSession represents a rotor session
|
||||
// RotorSession represents a rotor session.
|
||||
type RotorSession struct {
|
||||
BaseModel
|
||||
SessionID string `json:"session_id"`
|
||||
@@ -262,7 +263,7 @@ type RotorSession struct {
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a RotorSession from JSON
|
||||
// DeJSON deserializes a RotorSession from JSON data.
|
||||
func (r *RotorSession) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -295,7 +296,7 @@ func (r *RotorSession) DeJSON(data []byte, client ClientInterface) (Model, error
|
||||
return session, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of RotorSessions
|
||||
// DeList deserializes a list of RotorSessions from JSON data.
|
||||
func (r *RotorSession) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -313,7 +314,7 @@ func (r *RotorSession) DeList(data []byte, client ClientInterface) ([]Model, err
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SessionFeedback represents session feedback
|
||||
// SessionFeedback represents session feedback.
|
||||
type SessionFeedback struct {
|
||||
BaseModel
|
||||
TrackID string `json:"track_id"`
|
||||
@@ -321,7 +322,7 @@ type SessionFeedback struct {
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
// SessionFeedbacks represents multiple session feedbacks
|
||||
// SessionFeedbacks represents multiple session feedbacks.
|
||||
type SessionFeedbacks struct {
|
||||
BaseModel
|
||||
Feedbacks []SessionFeedback `json:"feedbacks"`
|
||||
|
||||
+11
-10
@@ -1,6 +1,7 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
// SearchResult represents search results
|
||||
// SearchResult represents search results from the Yandex Music API.
|
||||
type SearchResult struct {
|
||||
Tracks *SearchTracksResult `json:"tracks"`
|
||||
Albums *SearchAlbumsResult `json:"albums"`
|
||||
@@ -10,43 +11,43 @@ type SearchResult struct {
|
||||
Users *SearchUsersResult `json:"users"`
|
||||
}
|
||||
|
||||
// SearchTracksResult represents track search results
|
||||
// SearchTracksResult represents track search results.
|
||||
type SearchTracksResult struct {
|
||||
Total int `json:"total"`
|
||||
Results []Track `json:"results"`
|
||||
}
|
||||
|
||||
// SearchAlbumsResult represents album search results
|
||||
// SearchAlbumsResult represents album search results.
|
||||
type SearchAlbumsResult struct {
|
||||
Total int `json:"total"`
|
||||
Results []Album `json:"results"`
|
||||
}
|
||||
|
||||
// SearchArtistsResult represents artist search results
|
||||
// SearchArtistsResult represents artist search results.
|
||||
type SearchArtistsResult struct {
|
||||
Total int `json:"total"`
|
||||
Results []Artist `json:"results"`
|
||||
}
|
||||
|
||||
// SearchPlaylistsResult represents playlist search results
|
||||
// SearchPlaylistsResult represents playlist search results.
|
||||
type SearchPlaylistsResult struct {
|
||||
Total int `json:"total"`
|
||||
Results []Playlist `json:"results"`
|
||||
}
|
||||
|
||||
// SearchVideosResult represents video search results
|
||||
// SearchVideosResult represents video search results.
|
||||
type SearchVideosResult struct {
|
||||
Total int `json:"total"`
|
||||
Results []Video `json:"results"`
|
||||
}
|
||||
|
||||
// SearchUsersResult represents user search results
|
||||
// SearchUsersResult represents user search results.
|
||||
type SearchUsersResult struct {
|
||||
Total int `json:"total"`
|
||||
Results []User `json:"results"`
|
||||
}
|
||||
|
||||
// SearchBanner represents a search banner
|
||||
// SearchBanner represents a search banner.
|
||||
type SearchBanner struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
@@ -57,7 +58,7 @@ type SearchBanner struct {
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// Tag represents a search tag
|
||||
// Tag represents a search tag.
|
||||
type Tag struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
@@ -66,7 +67,7 @@ type Tag struct {
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// Video represents a video (minimal)
|
||||
// Video represents a video (minimal).
|
||||
type Video struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
|
||||
+18
-17
@@ -1,17 +1,18 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Experiments represents experiments
|
||||
// Experiments represents experiments from the Yandex Music API.
|
||||
type Experiments struct {
|
||||
BaseModel
|
||||
Experiments []ExperimentDetail `json:"experiments"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes Experiments from JSON
|
||||
// DeJSON deserializes Experiments from JSON data.
|
||||
func (e *Experiments) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -32,7 +33,7 @@ func (e *Experiments) DeJSON(data []byte, client ClientInterface) (Model, error)
|
||||
return experiments, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Experiments
|
||||
// DeList deserializes a list of Experiments from JSON data.
|
||||
func (e *Experiments) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -50,7 +51,7 @@ func (e *Experiments) DeList(data []byte, client ClientInterface) ([]Model, erro
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ExperimentDetail represents experiment details
|
||||
// ExperimentDetail represents experiment details.
|
||||
type ExperimentDetail struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -62,7 +63,7 @@ type ExperimentDetail struct {
|
||||
EndDate string `json:"end_date"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes ExperimentDetail from JSON
|
||||
// DeJSON deserializes ExperimentDetail from JSON data.
|
||||
func (e *ExperimentDetail) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -96,7 +97,7 @@ func (e *ExperimentDetail) DeJSON(data []byte, client ClientInterface) (Model, e
|
||||
return detail, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of ExperimentDetails
|
||||
// DeList deserializes a list of ExperimentDetails from JSON data.
|
||||
func (e *ExperimentDetail) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -114,7 +115,7 @@ func (e *ExperimentDetail) DeList(data []byte, client ClientInterface) ([]Model,
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Permissions represents user permissions
|
||||
// Permissions represents user permissions.
|
||||
type Permissions struct {
|
||||
BaseModel
|
||||
CanPlay bool `json:"can_play"`
|
||||
@@ -129,7 +130,7 @@ type Permissions struct {
|
||||
CanUseLossless bool `json:"can_use_lossless"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes Permissions from JSON
|
||||
// DeJSON deserializes Permissions from JSON data.
|
||||
func (p *Permissions) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -172,7 +173,7 @@ func (p *Permissions) DeJSON(data []byte, client ClientInterface) (Model, error)
|
||||
return perms, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Permissions
|
||||
// DeList deserializes a list of Permissions from JSON data.
|
||||
func (p *Permissions) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -190,14 +191,14 @@ func (p *Permissions) DeList(data []byte, client ClientInterface) ([]Model, erro
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// PermissionAlerts represents permission alerts
|
||||
// PermissionAlerts represents permission alerts.
|
||||
type PermissionAlerts struct {
|
||||
BaseModel
|
||||
Alerts []PermissionAlert `json:"alerts"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes PermissionAlerts from JSON
|
||||
// DeJSON deserializes PermissionAlerts from JSON data.
|
||||
func (p *PermissionAlerts) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -218,7 +219,7 @@ func (p *PermissionAlerts) DeJSON(data []byte, client ClientInterface) (Model, e
|
||||
return alerts, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of PermissionAlerts
|
||||
// DeList deserializes a list of PermissionAlerts from JSON data. from JSON data.
|
||||
func (p *PermissionAlerts) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -236,7 +237,7 @@ func (p *PermissionAlerts) DeList(data []byte, client ClientInterface) ([]Model,
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// PermissionAlert represents a permission alert
|
||||
// PermissionAlert represents a permission alert.
|
||||
type PermissionAlert struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -248,7 +249,7 @@ type PermissionAlert struct {
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes PermissionAlert from JSON
|
||||
// DeJSON deserializes PermissionAlert from JSON data.
|
||||
func (p *PermissionAlert) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -300,7 +301,7 @@ func (p *PermissionAlert) DeList(data []byte, client ClientInterface) ([]Model,
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ContentRestrictions represents content restrictions
|
||||
// ContentRestrictions represents content restrictions.
|
||||
type ContentRestrictions struct {
|
||||
BaseModel
|
||||
HasExplicitContent bool `json:"has_explicit_content"`
|
||||
@@ -311,7 +312,7 @@ type ContentRestrictions struct {
|
||||
BlockedArtists []string `json:"blocked_artists"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes ContentRestrictions from JSON
|
||||
// DeJSON deserializes ContentRestrictions from JSON data.
|
||||
func (c *ContentRestrictions) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -342,7 +343,7 @@ func (c *ContentRestrictions) DeJSON(data []byte, client ClientInterface) (Model
|
||||
return restrictions, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of ContentRestrictions
|
||||
// DeList deserializes a list of ContentRestrictions from JSON data.
|
||||
func (c *ContentRestrictions) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// LyricsMajor represents a lyrics provider (e.g., Genius, Musixmatch)
|
||||
// LyricsMajor represents a lyrics provider (e.g., Genius, Musixmatch).
|
||||
type LyricsMajor struct {
|
||||
BaseModel
|
||||
ID int `json:"id"`
|
||||
@@ -12,7 +13,7 @@ type LyricsMajor struct {
|
||||
PrettyName string `json:"pretty_name"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes LyricsMajor from JSON
|
||||
// DeJSON deserializes LyricsMajor from JSON data.
|
||||
func (lm *LyricsMajor) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -34,7 +35,7 @@ func (lm *LyricsMajor) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return major, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of LyricsMajor
|
||||
// DeList deserializes a list of LyricsMajor from JSON data.
|
||||
func (lm *LyricsMajor) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -52,7 +53,7 @@ func (lm *LyricsMajor) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// TrackLyrics represents lyrics information from /tracks/{id}/lyrics endpoint
|
||||
// TrackLyrics represents lyrics information from /tracks/{id}/lyrics endpoint.
|
||||
type TrackLyrics struct {
|
||||
BaseModel
|
||||
DownloadURL string `json:"download_url"`
|
||||
@@ -62,7 +63,7 @@ type TrackLyrics struct {
|
||||
Major *LyricsMajor `json:"major"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes TrackLyrics from JSON
|
||||
// DeJSON deserializes TrackLyrics from JSON data.
|
||||
func (tl *TrackLyrics) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -92,7 +93,7 @@ func (tl *TrackLyrics) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return lyrics, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of TrackLyrics
|
||||
// DeList deserializes a list of TrackLyrics from JSON data.
|
||||
func (tl *TrackLyrics) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -110,7 +111,7 @@ func (tl *TrackLyrics) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SupplementLyrics represents the actual lyrics content (from supplement)
|
||||
// SupplementLyrics represents the actual lyrics content from supplement.
|
||||
type SupplementLyrics struct {
|
||||
BaseModel
|
||||
ID int `json:"id"`
|
||||
@@ -123,7 +124,7 @@ type SupplementLyrics struct {
|
||||
Major *LyricsMajor `json:"major"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes SupplementLyrics from JSON
|
||||
// DeJSON deserializes SupplementLyrics from JSON data.
|
||||
func (l *SupplementLyrics) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -162,7 +163,7 @@ func (l *SupplementLyrics) DeJSON(data []byte, c ClientInterface) (Model, error)
|
||||
return lyrics, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of SupplementLyrics
|
||||
// DeList deserializes a list of SupplementLyrics from JSON data.
|
||||
func (l *SupplementLyrics) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -180,7 +181,7 @@ func (l *SupplementLyrics) DeList(data []byte, c ClientInterface) ([]Model, erro
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// LyricsInfo represents lyrics availability information
|
||||
// LyricsInfo represents lyrics availability information.
|
||||
type LyricsInfo struct {
|
||||
BaseModel
|
||||
TrackID string `json:"track_id"`
|
||||
@@ -196,7 +197,7 @@ type LyricsInfo struct {
|
||||
HasAvailableTextLyrics bool `json:"has_available_text_lyrics"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes LyricsInfo from JSON
|
||||
// DeJSON deserializes LyricsInfo from JSON data.
|
||||
func (li *LyricsInfo) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -247,7 +248,7 @@ func (li *LyricsInfo) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return info, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of LyricsInfo
|
||||
// DeList deserializes a list of LyricsInfo from JSON data.
|
||||
func (li *LyricsInfo) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -265,7 +266,7 @@ func (li *LyricsInfo) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// VideoSupplement represents a video supplement (from supplement endpoint)
|
||||
// VideoSupplement represents a video supplement from supplement endpoint.
|
||||
type VideoSupplement struct {
|
||||
BaseModel
|
||||
Cover string `json:"cover"`
|
||||
@@ -277,7 +278,7 @@ type VideoSupplement struct {
|
||||
Embed string `json:"embed"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes VideoSupplement from JSON
|
||||
// DeJSON deserializes VideoSupplement from JSON data.
|
||||
func (vs *VideoSupplement) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -311,7 +312,7 @@ func (vs *VideoSupplement) DeJSON(data []byte, c ClientInterface) (Model, error)
|
||||
return supp, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of VideoSupplements
|
||||
// DeList deserializes a list of VideoSupplements from JSON data.
|
||||
func (vs *VideoSupplement) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -329,7 +330,7 @@ func (vs *VideoSupplement) DeList(data []byte, c ClientInterface) ([]Model, erro
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Supplement represents a track supplement
|
||||
// Supplement represents a track supplement.
|
||||
type Supplement struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -340,7 +341,7 @@ type Supplement struct {
|
||||
Available bool `json:"available"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes Supplement from JSON
|
||||
// DeJSON deserializes Supplement from JSON data.
|
||||
func (s *Supplement) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -376,7 +377,7 @@ func (s *Supplement) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return supp, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Supplements
|
||||
// DeList deserializes a list of Supplements from JSON data.
|
||||
func (s *Supplement) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Track represents a full track
|
||||
// Track represents a full track from the Yandex Music API.
|
||||
type Track struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -27,7 +28,7 @@ type Track struct {
|
||||
DownloadInfo []DownloadInfo `json:"download_info"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a Track from JSON
|
||||
// DeJSON deserializes a Track from JSON data.
|
||||
func (t *Track) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -115,7 +116,7 @@ func (t *Track) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return track, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of Tracks
|
||||
// DeList deserializes a list of Tracks from JSON data.
|
||||
func (t *Track) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -133,7 +134,7 @@ func (t *Track) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetDownloadInfo returns download info for a specific quality
|
||||
// GetDownloadInfo returns download info for a specific quality, or nil if not found.
|
||||
func (t *Track) GetDownloadInfo(quality string) *DownloadInfo {
|
||||
for _, info := range t.DownloadInfo {
|
||||
if info.Quality == quality {
|
||||
@@ -146,14 +147,14 @@ func (t *Track) GetDownloadInfo(quality string) *DownloadInfo {
|
||||
// Note: Artist and Album types are defined in their respective files
|
||||
// These are imported automatically since they're in the same package
|
||||
|
||||
// Major represents major info
|
||||
// Major represents major label info for a track.
|
||||
type Major struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// TrackLyricsInfo represents minimal lyrics info for a track
|
||||
// TrackLyricsInfo represents minimal lyrics info for a track.
|
||||
type TrackLyricsInfo struct {
|
||||
ID string `json:"id"`
|
||||
Text string `json:"text"`
|
||||
@@ -162,7 +163,7 @@ type TrackLyricsInfo struct {
|
||||
HasText bool `json:"has_text"`
|
||||
}
|
||||
|
||||
// DownloadInfo represents file download info
|
||||
// DownloadInfo represents file download info for a track.
|
||||
type DownloadInfo struct {
|
||||
Quality string `json:"quality"`
|
||||
Codec string `json:"codec"`
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Package models provides data models for the Yandex Music API.
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// TrackShort represents a lightweight track (used in lists)
|
||||
// TrackShort represents a lightweight track used in lists.
|
||||
type TrackShort struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
@@ -31,7 +32,7 @@ type TrackShort struct {
|
||||
RingtoneID string `json:"ringtone_id"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a TrackShort from JSON
|
||||
// DeJSON deserializes a TrackShort from JSON data.
|
||||
func (t *TrackShort) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -131,7 +132,7 @@ func (t *TrackShort) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return track, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of TrackShort
|
||||
// DeList deserializes a list of TrackShort from JSON data.
|
||||
func (t *TrackShort) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
@@ -149,7 +150,7 @@ func (t *TrackShort) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// TracksList represents a list of tracks with metadata
|
||||
// TracksList represents a list of tracks with metadata.
|
||||
type TracksList struct {
|
||||
BaseModel
|
||||
Tracks []TrackShort `json:"tracks"`
|
||||
@@ -159,7 +160,7 @@ type TracksList struct {
|
||||
Pager *Pager `json:"pager"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a TracksList from JSON
|
||||
// DeJSON deserializes a TracksList from JSON data.
|
||||
func (t *TracksList) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
@@ -193,7 +194,7 @@ func (t *TracksList) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of TracksList
|
||||
// DeList deserializes a list of TracksList from JSON data.
|
||||
func (t *TracksList) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
|
||||
Reference in new issue
Block a user