forked from ebhomengo/niki
1
0
Fork 0
niki/vendor/github.com/kavenegar/kavenegar-go/message_countoutbox.go

42 lines
1.0 KiB
Go
Raw Normal View History

2024-02-18 10:42:21 +00:00
package kavenegar
import (
"net/url"
"time"
)
2024-04-26 19:30:35 +00:00
// MessageCountOutbox ...
2024-02-18 10:42:21 +00:00
type MessageCountOutbox struct {
*MessageCountInbox
Sumpart int `json:"sumpart"`
Cost int `json:"cost"`
}
2024-04-26 19:30:35 +00:00
// MessageCountOutboxResult ...
2024-02-18 10:42:21 +00:00
type MessageCountOutboxResult struct {
*Return `json:"return"`
Entries []MessageCountOutbox `json:"entries"`
}
2024-04-26 19:30:35 +00:00
// CountOutbox ...
2024-02-18 10:42:21 +00:00
func (message *MessageService) CountOutbox(startdate time.Time, endate time.Time, status MessageStatusType) (MessageCountOutbox, error) {
v := url.Values{}
v.Set("startdate", ToUnix(startdate))
if !endate.IsZero() {
v.Set("endate", ToUnix(startdate))
}
v.Set("status", status.String())
return message.CreateCountOutbox(v)
}
2024-04-26 19:30:35 +00:00
// CreateCountOutbox ...
2024-02-18 10:42:21 +00:00
func (message *MessageService) CreateCountOutbox(v url.Values) (MessageCountOutbox, error) {
u := message.client.EndPoint("sms", "countoutbox")
m := new(MessageCountOutboxResult)
err := message.client.Execute(u.String(), v, m)
2024-04-26 19:30:35 +00:00
if m.Entries == nil {
return MessageCountOutbox{}, err
2024-02-18 10:42:21 +00:00
}
return m.Entries[0], err
}