go-mcm/model/ip.go

32 lines
582 B
Go
Raw Normal View History

2019-10-02 19:03:23 +00:00
package model
import (
"encoding/json"
2019-10-03 20:22:22 +00:00
"go.etztech.xyz/go-mcm/internal"
2019-10-02 19:03:23 +00:00
"go.etztech.xyz/go-mcm/model/django"
)
type IP struct {
ID int64 `json:"id"`
PlayerID int64 `json:"player_id"`
LastUsed string `json:"last_used"`
Link string `json:"link"`
}
2019-10-03 20:22:22 +00:00
func (q *Model) IP(builder *django.Builder) ([]*IP, error) {
2019-10-02 19:03:23 +00:00
endpoint := q.endpoint("ip", builder.QueryString())
ips := make([]*IP, 0)
2019-10-03 20:22:22 +00:00
resp, err := internal.ResponseGet(endpoint)
2019-10-02 19:03:23 +00:00
if err != nil {
return nil, err
}
err = json.Unmarshal(resp, &ips)
if err != nil {
return nil, err
}
return ips, nil
}