forked from AfterShip/aftership-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotifications_example_test.go
93 lines (74 loc) · 1.76 KB
/
notifications_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
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
package aftership_test
import (
"context"
"fmt"
"github.com/aftership/aftership-sdk-go/v2"
)
func ExampleClient_GetNotification() {
cli, err := aftership.NewClient(aftership.Config{
APIKey: "YOUR_API_KEY",
})
if err != nil {
fmt.Println(err)
return
}
// Get the notification
param := aftership.SlugTrackingNumber{
Slug: "dhl",
TrackingNumber: "1588226550",
}
result, err := cli.GetNotification(context.Background(), param)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(result)
}
func ExampleClient_AddNotification() {
cli, err := aftership.NewClient(aftership.Config{
APIKey: "YOUR_API_KEY",
})
if err != nil {
fmt.Println(err)
return
}
// Add notification receivers to a tracking number.
param := aftership.SlugTrackingNumber{
Slug: "dhl",
TrackingNumber: "1588226550",
}
data := aftership.Notification{
Emails: []string{"user1@gmail.com", "user2@gmail.com", "invalid EMail @ Gmail. com"},
SMSes: []string{"+85291239123", "+85261236123", "Invalid Mobile Phone Number"},
}
result, err := cli.AddNotification(context.Background(), param, data)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(result)
}
func ExampleClient_RemoveNotification() {
cli, err := aftership.NewClient(aftership.Config{
APIKey: "YOUR_API_KEY",
})
if err != nil {
fmt.Println(err)
return
}
// Remove notification receivers from a tracking number.
param := aftership.SlugTrackingNumber{
Slug: "dhl",
TrackingNumber: "1588226550",
}
data := aftership.Notification{
Emails: []string{"user2@gmail.com"},
SMSes: []string{"+85261236123"},
}
result, err := cli.RemoveNotification(context.Background(), param, data)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(result)
}