-
Notifications
You must be signed in to change notification settings - Fork 2
/
example_test.go
50 lines (38 loc) · 926 Bytes
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package esendex_test
import (
"log"
"time"
"github.com/esendex/esendex-go-sdk"
)
func sendMessage(c *esendex.Client, to, body string) (id string, err error) {
account := c.Account("EX00000")
messages, err := account.Send([]esendex.Message{
{To: "4498499", Body: "Hey"},
})
if err != nil {
return "", err
}
return messages.Messages[0].ID, nil
}
func getStatus(c *esendex.Client, id string) (status string, err error) {
message, err := c.Message(id)
if err != nil {
return "", err
}
return message.Status, nil
}
func Example() {
client := esendex.New("[email protected]", "pass")
messageID, err := sendMessage(client, "538734", "Hey")
if err != nil {
log.Fatal(err)
}
for i := range []int{0, 1, 2, 3, 4, 5} {
status, err := getStatus(client, messageID)
if err != nil {
log.Fatal(err)
}
log.Printf("message status after %d seconds: %s\n", i, status)
time.Sleep(time.Second)
}
}