-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwhatsapp_test.go
104 lines (85 loc) · 2.2 KB
/
whatsapp_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package sendchamp_test
import (
"testing"
)
func TestSendTemplate(t *testing.T) {
sender := "2348120678278"
recipient := "2348153207998"
templateCode := "912671fe-5f20-4b59-92ee-a33a62ea6a19"
data := map[string]string{
"1": "Test",
"2": "1234",
"3": "10",
}
res, err := client.NewWhatsapp().SendTemplate(sender, recipient, templateCode, data)
if err != nil {
t.Error(err)
}
if res.Status != 200 {
t.Error("res.Status: ", res.Status)
}
}
func TestSendText(t *testing.T) {
sender := "2348120678278"
recipient := "2348153207998"
message := "Hello World"
res, err := client.NewWhatsapp().SendText(sender, recipient, message)
if err != nil {
t.Error(err)
}
if res.Status != 200 {
t.Error("res.Status: ", res.Status)
}
}
func TestSendAudio(t *testing.T) {
sender := "2348120678278"
recipient := "2348153207998"
message := "I am the best"
link := "https://sample-videos.com/audio/mp3/crowd-cheering.mp3"
res, err := client.NewWhatsapp().SendAudio(sender, recipient, message, link)
if err != nil {
t.Error(err)
}
if res.Status != 200 {
t.Error("res.Status: ", res.Status)
}
}
func TestSendVideo(t *testing.T) {
sender := "2348120678278"
recipient := "2348153207998"
link := "https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4"
res, err := client.NewWhatsapp().SendVideo(sender, recipient, link)
if err != nil {
t.Error(err)
}
if res.Status != 200 {
t.Error("res.Status: ", res.Status)
}
}
func TestSendSticker(t *testing.T) {
sender := "2348120678278"
recipient := "2348153207998"
link := "https://studio.posit.us/api/samples/sticker.webp"
res, err := client.NewWhatsapp().SendSticker(sender, recipient, link)
if err != nil {
t.Error(err)
}
if res.Status != 200 {
t.Error("res.Status: ", res.Status)
}
}
func TestSendLocation(t *testing.T) {
sender := "2348120678278"
recipient := "2348153207998"
longitude := -46.662787
latitude := -23.553610
name := "Robbu Brazil"
address := "Av. Angélica, 2530 - Bela Vista, São Paulo - SP, 01228-200"
res, err := client.NewWhatsapp().SendLocation(sender, recipient, longitude, latitude, name, address)
if err != nil {
t.Error(err)
}
if res.Status != 200 {
t.Error("res.Status: ", res.Status)
}
}