-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathresponse.go
More file actions
30 lines (27 loc) · 764 Bytes
/
response.go
File metadata and controls
30 lines (27 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package pushover
import "fmt"
// Response represents a response from the API.
type Response struct {
Status int `json:"status"`
ID string `json:"request"`
Errors Errors `json:"errors"`
Receipt string `json:"receipt"`
Group string `json:"group"`
Limit *Limit
}
// String represents a printable form of the response.
func (r Response) String() string {
ret := fmt.Sprintf("Status: %d\n", r.Status)
ret += fmt.Sprintf("Request id: %s\n", r.ID)
if r.Receipt != "" {
ret += fmt.Sprintf("Receipt: %s\n", r.Receipt)
}
if r.Group != "" {
ret += fmt.Sprintf("Group: %s\n", r.Group)
}
if r.Limit != nil {
ret += fmt.Sprintf("Usage %d/%d messages\nNext reset : %s",
r.Limit.Remaining, r.Limit.Total, r.Limit.NextReset)
}
return ret
}