47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"git.jojodev.com/Minecraft/go-mcm/internal"
|
|
"git.jojodev.com/Minecraft/go-mcm/model/django"
|
|
)
|
|
|
|
type TicketNote struct {
|
|
ID int64 `json:"id"`
|
|
AuthorID int64 `json:"author_id"`
|
|
TicketID int64 `json:"ticket_id"`
|
|
Message string `json:"message"`
|
|
LastUpdate string `json:"last_update"`
|
|
Date string `json:"date"`
|
|
Link string `json:"link"`
|
|
|
|
model *Model `json:"-"`
|
|
}
|
|
|
|
func (q *Model) TicketNote(builder *django.Builder) ([]*TicketNote, error) {
|
|
endpoint := q.queryEndpoint("ticketnote", builder.QueryString())
|
|
ticketNotes := make([]*TicketNote, 0)
|
|
|
|
resp, err := internal.ResponseGet(endpoint)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
err = json.Unmarshal(resp, &ticketNotes)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
for _, ticketNote := range ticketNotes {
|
|
ticketNote.model = q
|
|
}
|
|
|
|
return ticketNotes, nil
|
|
}
|
|
|
|
func (t *TicketNote) Save() (*internal.Status, error) {
|
|
endpoint := t.model.endpoint("ticketnote")
|
|
return internal.ResponseStatus(endpoint, t.model.Values(t))
|
|
}
|