-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_sms.go
80 lines (68 loc) · 2.14 KB
/
client_sms.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
71
72
73
74
75
76
77
78
79
80
package huwlte
import (
"context"
"encoding/xml"
)
type ClientSMS struct {
base *Client
}
type SMSCount struct {
XMLName xml.Name `xml:"response" human:"-"`
LocalUnread int `xml:"LocalUnread"`
LocalInbox int `xml:"LocalInbox"`
LocalOutbox int `xml:"LocalOutbox"`
LocalDraft int `xml:"LocalDraft"`
LocalDeleted int `xml:"LocalDeleted"`
SimUnread int `xml:"SimUnread"`
SimInbox int `xml:"SimInbox"`
SimOutbox int `xml:"SimOutbox"`
SimDraft int `xml:"SimDraft"`
LocalMax int `xml:"LocalMax"`
SimMax int `xml:"SimMax"`
SimUsed int `xml:"SimUsed"`
NewMsg int `xml:"NewMsg"`
}
type SMSList struct {
XMLName xml.Name `xml:"response" human:"-"`
Count int `xml:"Count"`
Messages []SMSListItem `xml:"Messages>Message"`
}
type SMSListItem struct {
XMLName xml.Name `xml:"Message" human:"-"`
Smstat int `xml:"Smstat"`
Index int `xml:"Index"`
Phone string `xml:"Phone"`
Content string `xml:"Content"`
Date string `xml:"Date"`
Sca string `xml:"Sca"`
SaveType int `xml:"SaveType"`
Priority int `xml:"Priority"`
SmsType int `xml:"SmsType"`
}
type SMSListOptions struct {
XMLName xml.Name `xml:"request"`
PageIndex int `xml:"PageIndex"`
ReadCount int `xml:"ReadCount"`
BoxType int `xml:"BoxType"`
SortType int `xml:"SortType"`
Ascending int `xml:"Ascending"`
UnreadPreferred int `xml:"UnreadPreferred"`
}
func (sms *ClientSMS) List(ctx context.Context, opts SMSListOptions) (*SMSList, error) {
var result SMSList
if err := sms.base.withSessionRetry(ctx, func(ctx context.Context) error {
return sms.base.post(ctx, "/api/sms/sms-list", opts, false, &result)
}); err != nil {
return nil, err
}
return &result, nil
}
func (sms *ClientSMS) Count(ctx context.Context) (*SMSCount, error) {
var result SMSCount
if err := sms.base.withSessionRetry(ctx, func(ctx context.Context) error {
return sms.base.get(ctx, "/api/sms/sms-count", &result)
}); err != nil {
return nil, err
}
return &result, nil
}