-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport.go
70 lines (60 loc) · 1.57 KB
/
report.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package smsapicom
type Report struct {
Count int `json:"count"`
List []reportByNumber `json:"list"`
}
type reportByNumber struct {
Id string `json:"id"`
Idx string `json:"idx"`
Points float64 `json:"points"`
Number string `json:"number"`
SubmittedNumber string `json:"submitted_number"`
DateSent int64 `json:"date_sent"`
Status string `json:"status"`
Error string `json:"error"`
}
type DetailedReport struct {
Report
Length int `json:"length"`
Parts int `json:"parts"`
Message string `json:"message"`
}
type ErrorReport struct {
Message string `json:"message"`
Error int `json:"error"`
InvalidNumbers []invalidNumber `json:"invalid_numbers"`
}
type invalidNumber struct {
Number string `json:"number"`
SubmittedNumber string `json:"submitted_number"`
Message string `json:"message"`
}
type rawReport struct {
Count int
List []reportByNumber
Length int
Parts int
Message string
Error int
InvalidNumbers []invalidNumber
}
func (r rawReport) HasError() bool {
return r.Error != 0
}
func (r rawReport) ToError() *Error {
return &Error{code: r.Error, message: r.Message}
}
func (r rawReport) ToReport() *Report {
return &Report{
Count: r.Count,
List: r.List,
}
}
func (r rawReport) ToDetailedReport() *DetailedReport {
return &DetailedReport{
Report: Report{Count: r.Count, List: r.List},
Length: r.Length,
Parts: r.Parts,
Message: r.Message,
}
}