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

33 lines
761 B
Go
Raw Normal View History

2024-08-29 03:26:59 +00:00
package kavenegar
import (
"net/url"
)
//Send ...
func (m *MessageService) Send(sender string, receptor []string, message string, params *MessageSendParam) ([]Message, error) {
v := url.Values{}
v.Set("receptor", ToString(receptor))
v.Set("message", message)
if params != nil {
if !params.Date.IsZero() {
v.Set("date", ToUnix(params.Date))
}
if params.Type != nil {
v.Set("type", ToString(params.Type))
}
if params.LocalID != nil {
v.Set("localid", ToString(params.LocalID))
}
}
return m.CreateSend(v)
}
//CreateSend ...
func (m *MessageService) CreateSend(v url.Values) ([]Message, error) {
u := m.client.EndPoint("sms", "send")
res := new(MessageResult)
err := m.client.Execute(u.String(), v, res)
return res.Entries, err
}