mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-20 14:05:07 +00:00
Commit from m3o/m3o action
This commit is contained in:
39
go/sms/sms.go
Executable file
39
go/sms/sms.go
Executable file
@@ -0,0 +1,39 @@
|
||||
package sms
|
||||
|
||||
import (
|
||||
"github.com/m3o/m3o-go/client"
|
||||
)
|
||||
|
||||
func NewSmsService(token string) *SmsService {
|
||||
return &SmsService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type SmsService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Send an SMS.
|
||||
func (t *SmsService) Send(request *SendRequest) (*SendResponse, error) {
|
||||
rsp := &SendResponse{}
|
||||
return rsp, t.client.Call("sms", "Send", request, rsp)
|
||||
}
|
||||
|
||||
type SendRequest struct {
|
||||
// who is the message from? The message will be suffixed with "Sent from <from>"
|
||||
From string `json:"from"`
|
||||
// the main body of the message to send
|
||||
Message string `json:"message"`
|
||||
// the destination phone number including the international dialling code (e.g. +44)
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type SendResponse struct {
|
||||
// any additional info
|
||||
Info string `json:"info"`
|
||||
// will return "ok" if successful
|
||||
Status string `json:"status"`
|
||||
}
|
||||
Reference in New Issue
Block a user