Add missing model fields from Python audit
LandingList: Added type, type_for_from, title, id, new_releases, new_playlists, podcasts New type: PlaylistID Presaves: Added upcoming_albums, released_albums Presaves: Added DeJSON method QueueItem: Added id, context, modified fields (fixed duplicate context) Clip: Fixed PreviewURI → PreviewURL field name
This commit is contained in:
1 parent
463e0bcd1a
commit
9d3bcc4a9b
3 files changed
+109
-17
No files matched your search
@@ -102,10 +102,61 @@ type LandingBlockData struct {
|
||||
// LandingList represents a list of landings.
|
||||
type LandingList struct {
|
||||
BaseModel
|
||||
Landings []Landing `json:"landings"`
|
||||
Total int `json:"total"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
Type string `json:"type"`
|
||||
TypeForFrom string `json:"type_for_from"`
|
||||
Title string `json:"title"`
|
||||
ID string `json:"id"`
|
||||
Landings []Landing `json:"landings"`
|
||||
NewReleases []int `json:"new_releases"`
|
||||
NewPlaylists []PlaylistID `json:"new_playlists"`
|
||||
Podcasts []int `json:"podcasts"`
|
||||
Total int `json:"total"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// PlaylistID represents a playlist ID reference.
|
||||
type PlaylistID struct {
|
||||
BaseModel
|
||||
UID int `json:"uid"`
|
||||
Kind int `json:"kind"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a PlaylistID from JSON data.
|
||||
func (pid *PlaylistID) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
playlistID := &PlaylistID{BaseModel: *NewBaseModel(c)}
|
||||
|
||||
if v, ok := raw["uid"]; ok {
|
||||
json.Unmarshal(v, &playlistID.UID)
|
||||
}
|
||||
if v, ok := raw["kind"]; ok {
|
||||
json.Unmarshal(v, &playlistID.Kind)
|
||||
}
|
||||
|
||||
return playlistID, nil
|
||||
}
|
||||
|
||||
// DeList deserializes a list of PlaylistID from JSON data.
|
||||
func (pid *PlaylistID) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
var rawList []json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawList); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make([]Model, 0, len(rawList))
|
||||
for _, item := range rawList {
|
||||
pid := &PlaylistID{BaseModel: *NewBaseModel(c)}
|
||||
if err := json.Unmarshal(item, pid); err != nil {
|
||||
continue
|
||||
}
|
||||
result = append(result, pid)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeJSON deserializes a LandingList from JSON data.
|
||||
|
||||
+43
-4
@@ -127,10 +127,12 @@ type PinsList struct {
|
||||
// Presaves represents presaves.
|
||||
type Presaves struct {
|
||||
BaseModel
|
||||
Presaves []Presave `json:"presaves"`
|
||||
Total int `json:"total"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
UpcomingAlbums []Album `json:"upcoming_albums"`
|
||||
ReleasedAlbums []Album `json:"released_albums"`
|
||||
Presaves []Presave `json:"presaves"`
|
||||
Total int `json:"total"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// Presave represents a presave.
|
||||
@@ -219,3 +221,40 @@ func (p *Presave) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeJSON deserializes Presaves from JSON data.
|
||||
func (p *Presaves) DeJSON(data []byte, client ClientInterface) (Model, error) {
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
presaves := &Presaves{BaseModel: *NewBaseModel(client)}
|
||||
|
||||
if v, ok := raw["upcoming_albums"]; ok {
|
||||
var albums []Album
|
||||
json.Unmarshal(v, &albums)
|
||||
presaves.UpcomingAlbums = albums
|
||||
}
|
||||
if v, ok := raw["released_albums"]; ok {
|
||||
var albums []Album
|
||||
json.Unmarshal(v, &albums)
|
||||
presaves.ReleasedAlbums = albums
|
||||
}
|
||||
if v, ok := raw["presaves"]; ok {
|
||||
var presaveList []Presave
|
||||
json.Unmarshal(v, &presaveList)
|
||||
presaves.Presaves = presaveList
|
||||
}
|
||||
if v, ok := raw["total"]; ok {
|
||||
json.Unmarshal(v, &presaves.Total)
|
||||
}
|
||||
if v, ok := raw["page"]; ok {
|
||||
json.Unmarshal(v, &presaves.Page)
|
||||
}
|
||||
if v, ok := raw["page_size"]; ok {
|
||||
json.Unmarshal(v, &presaves.PageSize)
|
||||
}
|
||||
|
||||
return presaves, nil
|
||||
}
|
||||
@@ -93,13 +93,15 @@ func (q *Queue) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
||||
// QueueItem represents a queue item.
|
||||
type QueueItem struct {
|
||||
BaseModel
|
||||
TrackID string `json:"track_id"`
|
||||
Track *Track `json:"track"`
|
||||
Position int `json:"position"`
|
||||
AddedAt string `json:"added_at"`
|
||||
AddedBy string `json:"added_by"`
|
||||
Playable bool `json:"playable"`
|
||||
PlayContext *PlayContext `json:"play_context"`
|
||||
ID JSONID `json:"id"`
|
||||
TrackID string `json:"track_id"`
|
||||
Track *Track `json:"track"`
|
||||
Position int `json:"position"`
|
||||
AddedAt string `json:"added_at"`
|
||||
AddedBy string `json:"added_by"`
|
||||
Playable bool `json:"playable"`
|
||||
Modified string `json:"modified"`
|
||||
Context *PlayContext `json:"context"`
|
||||
}
|
||||
|
||||
// DeJSON deserializes a QueueItem from JSON data.
|
||||
@@ -132,10 +134,10 @@ func (qi *QueueItem) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
||||
json.Unmarshal(v, &track)
|
||||
item.Track = &track
|
||||
}
|
||||
if v, ok := raw["play_context"]; ok {
|
||||
if v, ok := raw["context"]; ok {
|
||||
var ctx PlayContext
|
||||
json.Unmarshal(v, &ctx)
|
||||
item.PlayContext = &ctx
|
||||
item.Context = &ctx
|
||||
}
|
||||
|
||||
return item, nil
|
||||
|
||||
Reference in new issue
Block a user