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.
|
||||
|
||||
Reference in new issue
Block a user