2024-02-18 10:42:21 +00:00
|
|
|
package kavenegar
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
//MessageCountInbox ...
|
2024-02-18 10:42:21 +00:00
|
|
|
type MessageCountInbox struct {
|
|
|
|
Startdate int `json:"startdate"`
|
|
|
|
Enddate int `json:"enddate"`
|
|
|
|
Sumcount int `json:"sumcount"`
|
|
|
|
}
|
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
//MessageCountInboxResult ...
|
2024-02-18 10:42:21 +00:00
|
|
|
type MessageCountInboxResult struct {
|
|
|
|
*Return `json:"return"`
|
|
|
|
Entries []MessageCountInbox `json:"entries"`
|
|
|
|
}
|
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
//CountInbox ...
|
2024-02-18 10:42:21 +00:00
|
|
|
func (message *MessageService) CountInbox(linenumber string, startdate time.Time, endate time.Time, isread bool) (MessageCountInbox, error) {
|
|
|
|
|
|
|
|
v := url.Values{}
|
|
|
|
v.Set("linenumber", linenumber)
|
|
|
|
v.Set("startdate", ToUnix(startdate))
|
|
|
|
if !endate.IsZero() {
|
|
|
|
v.Set("endate", ToUnix(startdate))
|
|
|
|
}
|
|
|
|
//if isread != nil {
|
|
|
|
v.Set("isread", map[bool]string{true: "1", false: "0"}[isread != true])
|
|
|
|
//}
|
|
|
|
return message.CreateCountInbox(v)
|
|
|
|
}
|
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
//CreateCountInbox ...
|
2024-02-18 10:42:21 +00:00
|
|
|
func (message *MessageService) CreateCountInbox(v url.Values) (MessageCountInbox, error) {
|
|
|
|
u := message.client.EndPoint("sms", "countinbox")
|
|
|
|
m := new(MessageCountInboxResult)
|
|
|
|
err := message.client.Execute(u.String(), v, m)
|
2024-05-14 13:07:09 +00:00
|
|
|
if m.Entries==nil{
|
|
|
|
return MessageCountInbox{},err
|
2024-02-18 10:42:21 +00:00
|
|
|
}
|
|
|
|
return m.Entries[0], err
|
2024-05-14 13:07:09 +00:00
|
|
|
}
|