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.
|
// LandingList represents a list of landings.
|
||||||
type LandingList struct {
|
type LandingList struct {
|
||||||
BaseModel
|
BaseModel
|
||||||
Landings []Landing `json:"landings"`
|
Type string `json:"type"`
|
||||||
Total int `json:"total"`
|
TypeForFrom string `json:"type_for_from"`
|
||||||
Page int `json:"page"`
|
Title string `json:"title"`
|
||||||
PageSize int `json:"page_size"`
|
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.
|
// DeJSON deserializes a LandingList from JSON data.
|
||||||
|
|||||||
+43
-4
@@ -127,10 +127,12 @@ type PinsList struct {
|
|||||||
// Presaves represents presaves.
|
// Presaves represents presaves.
|
||||||
type Presaves struct {
|
type Presaves struct {
|
||||||
BaseModel
|
BaseModel
|
||||||
Presaves []Presave `json:"presaves"`
|
UpcomingAlbums []Album `json:"upcoming_albums"`
|
||||||
Total int `json:"total"`
|
ReleasedAlbums []Album `json:"released_albums"`
|
||||||
Page int `json:"page"`
|
Presaves []Presave `json:"presaves"`
|
||||||
PageSize int `json:"page_size"`
|
Total int `json:"total"`
|
||||||
|
Page int `json:"page"`
|
||||||
|
PageSize int `json:"page_size"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Presave represents a presave.
|
// Presave represents a presave.
|
||||||
@@ -219,3 +221,40 @@ func (p *Presave) DeList(data []byte, client ClientInterface) ([]Model, error) {
|
|||||||
}
|
}
|
||||||
return result, nil
|
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.
|
// QueueItem represents a queue item.
|
||||||
type QueueItem struct {
|
type QueueItem struct {
|
||||||
BaseModel
|
BaseModel
|
||||||
TrackID string `json:"track_id"`
|
ID JSONID `json:"id"`
|
||||||
Track *Track `json:"track"`
|
TrackID string `json:"track_id"`
|
||||||
Position int `json:"position"`
|
Track *Track `json:"track"`
|
||||||
AddedAt string `json:"added_at"`
|
Position int `json:"position"`
|
||||||
AddedBy string `json:"added_by"`
|
AddedAt string `json:"added_at"`
|
||||||
Playable bool `json:"playable"`
|
AddedBy string `json:"added_by"`
|
||||||
PlayContext *PlayContext `json:"play_context"`
|
Playable bool `json:"playable"`
|
||||||
|
Modified string `json:"modified"`
|
||||||
|
Context *PlayContext `json:"context"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeJSON deserializes a QueueItem from JSON data.
|
// 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)
|
json.Unmarshal(v, &track)
|
||||||
item.Track = &track
|
item.Track = &track
|
||||||
}
|
}
|
||||||
if v, ok := raw["play_context"]; ok {
|
if v, ok := raw["context"]; ok {
|
||||||
var ctx PlayContext
|
var ctx PlayContext
|
||||||
json.Unmarshal(v, &ctx)
|
json.Unmarshal(v, &ctx)
|
||||||
item.PlayContext = &ctx
|
item.Context = &ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
return item, nil
|
return item, nil
|
||||||
|
|||||||
Reference in new issue
Block a user