-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_virtual_numbers_test.go
184 lines (137 loc) · 4.89 KB
/
api_virtual_numbers_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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
Messaging API v3.4.3
Testing VirtualNumbersAPIService
*/
package TelstraMessaging
import (
"context"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_TelstraMessaging_VirtualNumbersAPIService(t *testing.T) {
t.Skip("skip test")
configuration := NewConfiguration()
apiClient := NewAPIClient(configuration)
virtualNumber := "0428180739"
clientId := "YOUR CLIENT ID"
clientSecret := "YOUR CLIENT SECRET"
authorization, _ := GetAuthorization(apiClient, clientId, clientSecret)
t.Run("Test VirtualNumbersAPIService AssignNumber", func(t *testing.T) {
//t.Skip("skip test") // remove to run test
tags := []string{
"reprehenderit",
"Excepteur non labore",
"labore in consequat culpa",
"qui voluptate",
"n",
"incididunt aliqua tempor",
"incididunt dolor Lorem",
"adipisicing aliquip elit eiusm",
"consequat id sunt enim",
"co",
}
assignNumberRequest := NewAssignNumberRequest()
assignNumberRequest.SetReplyCallbackUrl("http://www.example.com")
assignNumberRequest.SetTags(tags)
vnApi := apiClient.VirtualNumbersAPI.AssignNumber(context.Background(), authorization)
resp, httpRes, err := vnApi.AssignNumber(*assignNumberRequest)
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Printf("httpRes Result: %+v\n", httpRes)
fmt.Printf("resp Result: %+v\n", resp)
fmt.Printf("resp err: %+v\n", err)
assert.Equal(t, 201, httpRes.StatusCode)
assert.NotEmpty(t, httpRes, "httpRes should not be empty")
assert.NotNil(t, resp, "resp should not be nil")
})
t.Run("Test VirtualNumbersAPIService DeleteNumber", func(t *testing.T) {
vnApi := apiClient.VirtualNumbersAPI.DeleteNumber(context.Background(), virtualNumber, authorization)
httpRes, err := vnApi.DeleteNumber()
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Printf("httpRes Result: %+v\n", httpRes)
assert.Equal(t, 204, httpRes.StatusCode)
assert.NotEmpty(t, httpRes, "httpRes should not be empty")
assert.NoError(t, err, "Error encountered: %v", err)
})
t.Run("Test VirtualNumbersAPIService GetNumbers", func(t *testing.T) {
//t.Skip("skip test") // remove to run test
vnApi := apiClient.VirtualNumbersAPI.GetNumbers(context.Background(), authorization)
resp, httpRes, err := vnApi.GetNumbers()
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Printf("httpRes Result: %+v\n", httpRes)
fmt.Printf("resp Result: %+v\n", resp)
fmt.Printf("resp err: %+v\n", err)
assert.Equal(t, 200, httpRes.StatusCode)
assert.NotEmpty(t, httpRes, "httpRes should not be empty")
assert.NotNil(t, resp, "resp should not be nil")
})
t.Run("Test VirtualNumbersAPIService GetRecipientOptouts", func(t *testing.T) {
//t.Skip("skip test") // remove to run test
vnApi := apiClient.VirtualNumbersAPI.GetRecipientOptouts(context.Background(), virtualNumber, authorization)
resp, httpRes, err := vnApi.GetRecipientOptouts()
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Printf("httpRes Result: %+v\n", httpRes)
fmt.Printf("resp Result: %+v\n", resp)
assert.Equal(t, 200, httpRes.StatusCode)
assert.NotEmpty(t, httpRes, "httpRes should not be empty")
assert.NoError(t, err, "Error encountered: %v", err)
assert.NotNil(t, resp, "resp should not be nil")
})
t.Run("Test VirtualNumbersAPIService GetVirtualNumber", func(t *testing.T) {
//t.Skip("skip test") // remove to run test
vnApi := apiClient.VirtualNumbersAPI.GetVirtualNumber(context.Background(), virtualNumber, authorization)
resp, httpRes, err := vnApi.GetVirtualNumber()
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Printf("httpRes Result: %+v\n", httpRes)
fmt.Printf("resp Result: %+v\n", resp)
fmt.Printf("resp err: %+v\n", err)
assert.Equal(t, 200, httpRes.StatusCode)
assert.NotEmpty(t, httpRes, "httpRes should not be empty")
assert.NotNil(t, resp, "resp should not be nil")
})
t.Run("Test VirtualNumbersAPIService UpdateNumber", func(t *testing.T) {
//t.Skip("skip test") // remove to run test
updateNumberRequest := NewUpdateNumberRequest()
updateNumberRequest.SetReplyCallbackUrl("http://www.example.com")
tags := []string{
"minim qui",
"commodo",
"nostrud laborum minim",
"nulla proident ut voluptat",
"et consectetur dolor",
"est amet cillum",
"exercitation",
"non occaecat cupidatat Duis",
"adipisicing",
"ea aliqua incididunt",
}
updateNumberRequest.SetTags(tags)
vnApi := apiClient.VirtualNumbersAPI.UpdateNumber(context.Background(), virtualNumber, authorization)
resp, httpRes, err := vnApi.UpdateNumber(*updateNumberRequest)
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Printf("httpRes Result: %+v\n", httpRes)
fmt.Printf("resp Result: %+v\n", resp)
fmt.Printf("resp err: %+v\n", err)
assert.Equal(t, 200, httpRes.StatusCode)
assert.NotEmpty(t, httpRes, "httpRes should not be empty")
assert.NotNil(t, resp, "resp should not be nil")
})
}