package model import ( "encoding/json" "go.etztech.xyz/go-mcm/internal" "go.etztech.xyz/go-mcm/model/django" ) type Alert struct { ID int64 `json:"id"` UserID int64 `json:"user_id"` Message string `json:"message"` Seen bool `json:"seen"` Date string `json:"date"` Link string `json:"link"` model *Model `json:"-"` } func (q *Model) Alert(builder *django.Builder) ([]*Alert, error) { endpoint := q.queryEndpoint("alert", builder.QueryString()) alerts := make([]*Alert, 0) resp, err := internal.ResponseGet(endpoint) if err != nil { return nil, err } err = json.Unmarshal(resp, &alerts) if err != nil { return nil, err } for _, alert := range alerts { alert.model = q } return alerts, nil } func (a *Alert) Save() (*internal.Status, error) { endpoint := a.model.endpoint("alert") return internal.ResponseStatus(endpoint, a.model.Values(a)) }