go-mcm/model/alert.go

33 lines
612 B
Go
Raw Normal View History

2019-10-02 19:03:23 +00:00
package model
import (
"encoding/json"
"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"`
}
func (q *Query) Alert(builder *django.Builder) ([]*Alert, error) {
endpoint := q.endpoint("alert", builder.QueryString())
alerts := make([]*Alert, 0)
resp, err := response(endpoint)
if err != nil {
return nil, err
}
err = json.Unmarshal(resp, &alerts)
if err != nil {
return nil, err
}
return alerts, nil
}