feat: getusertitles now must return all the title info
This commit is contained in:
parent
258eb749d9
commit
ba68b5ee04
3 changed files with 14 additions and 14 deletions
|
|
@ -143,7 +143,7 @@ type UserTitle struct {
|
|||
|
||||
// Status User's title status
|
||||
Status UserTitleStatus `json:"status"`
|
||||
TitleId int64 `json:"title_id"`
|
||||
Title *Title `json:"title,omitempty"`
|
||||
UserId int64 `json:"user_id"`
|
||||
AdditionalProperties map[string]interface{} `json:"-"`
|
||||
}
|
||||
|
|
@ -493,12 +493,12 @@ func (a *UserTitle) UnmarshalJSON(b []byte) error {
|
|||
delete(object, "status")
|
||||
}
|
||||
|
||||
if raw, found := object["title_id"]; found {
|
||||
err = json.Unmarshal(raw, &a.TitleId)
|
||||
if raw, found := object["title"]; found {
|
||||
err = json.Unmarshal(raw, &a.Title)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error reading 'title_id': %w", err)
|
||||
return fmt.Errorf("error reading 'title': %w", err)
|
||||
}
|
||||
delete(object, "title_id")
|
||||
delete(object, "title")
|
||||
}
|
||||
|
||||
if raw, found := object["user_id"]; found {
|
||||
|
|
@ -554,9 +554,11 @@ func (a UserTitle) MarshalJSON() ([]byte, error) {
|
|||
return nil, fmt.Errorf("error marshaling 'status': %w", err)
|
||||
}
|
||||
|
||||
object["title_id"], err = json.Marshal(a.TitleId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error marshaling 'title_id': %w", err)
|
||||
if a.Title != nil {
|
||||
object["title"], err = json.Marshal(a.Title)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error marshaling 'title': %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
object["user_id"], err = json.Marshal(a.UserId)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue