package model import ( "encoding/json" "go.etztech.xyz/go-mcm/internal" "go.etztech.xyz/go-mcm/model/django" ) type Player struct { ID int64 `json:"id"` AuthUserID int64 `json:"auth_user_id"` UUID string `json:"uuid"` Username string `json:"username"` ApplicationID int64 `json:"application_id"` FirstSeen string `json:"first_seen"` LastSeen string `json:"last_seen"` Link string `json:"link"` model *Model `json:"-"` } func (q *Model) Player(builder *django.Builder) ([]*Player, error) { endpoint := q.queryEndpoint("player", builder.QueryString()) players := make([]*Player, 0) resp, err := internal.ResponseGet(endpoint) if err != nil { return nil, err } err = json.Unmarshal(resp, &players) if err != nil { return nil, err } for _, player := range players { player.model = q } return players, nil } func (p *Player) Save() (*internal.Status, error) { endpoint := p.model.endpoint("player") return internal.ResponseStatus(endpoint, p.model.Values(p)) }