mirror of
https://github.com/go-micro/go-micro.git
synced 2025-01-05 10:20:53 +02:00
4ae2528cbe
* add m3o services * update readme
40 lines
888 B
Go
Executable File
40 lines
888 B
Go
Executable File
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"`
|
|
}
|