-
Notifications
You must be signed in to change notification settings - Fork 0
/
trackingnumbers_test.go
212 lines (191 loc) · 6.39 KB
/
trackingnumbers_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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
package ebct
import (
"encoding/json"
"github.com/davecgh/go-spew/spew"
"github.com/stretchr/testify/assert"
"testing"
"time"
)
const TrackingInput = `{
"distributionModality": 33170,
"quantity": 5
}`
const TackingInputPut = `{
"senderName": "Paulo.COM ",
"senderAddress": "Rua Remetente",
"senderAddressNumber": "123",
"senderAddressComplement": "comp",
"senderZipCode": "12345678",
"senderCityName": "Grecia",
"senderState": "",
"senderCountryCode": "GB",
"senderEmail": "[email protected]",
"senderWebsite": "www.remetente.com",
"recipientName": "Destinatario da Silva",
"recipientDocumentType": "CPF",
"recipientDocumentNumber": "12345678909",
"recipientAddress": "Rua do Destinatario, Bairro do Destinatario",
"recipientAddressNumber": "123",
"recipientAddressComplement": "ED. SAO JOAO, APTO 900",
"recipientCityName": "Belo Horizonte",
"recipientState": "MG",
"recipientZipCode": "31748320",
"recipientEmail": "[email protected]",
"recipientPhoneNumber": "1499999999",
"totalWeight": 200.15,
"packagingLength": 35.5,
"packagingWidth": 15.45,
"packagingHeight": 50,
"taxPaymentMethod": "DDU",
"currency": "USD",
"freightPaidValue": 7.54,
"insurancePaidValue": 0,
"items": [
{
"hsCode": "401120",
"description": "Tste de Itens",
"quantity": 1,
"value": 14.61
}
]
}`
const packageasyncPut = `{
"packageList": [
{
"trackingNumber": "NX002551329BR",
"senderName": "Remetente de Teste",
"senderAddress": "S. SILVERSTONE WAY ",
"senderAddressNumber": "201654",
"senderAddressComplement": "comp ",
"senderZipCode": "83642555887858953222",
"senderCityName": "MERIDIAN",
"senderState": "",
"senderCountryCode": "US",
"senderEmail": "[email protected]",
"senderWebsite": "www.bodybuilding.comdfasdf",
"recipientName": "Destinatario de Teste 1",
"recipientDocumentType": "CPF",
"recipientDocumentNumber": "44517000001",
"recipientAddress": "QQAA 5 LOTE 5 BLOCO 8",
"recipientAddressNumber": "4565456sad",
"recipientAddressComplement": "ED. SAO JOAO, APTO 900",
"recipientCityName": "SAO PAULO",
"recipientState": "SP",
"recipientZipCode": "17270001",
"recipientEmail": "[email protected]",
"recipientPhoneNumber": "1499999999",
"totalWeight": 120,
"packagingLength": 16,
"packagingWidth": 11,
"packagingHeight": 2,
"taxPaymentMethod": "DDU",
"currency": "USD",
"freightPaidValue": 7.54,
"insurancePaidValue": 0,
"items": [
{
"hsCode": "401120",
"description": "TOYS, GAMES AND SPORTS REQUISITES",
"quantity": 1,
"value": 140.61
}
]
},
{
"trackingNumber": "IX000682556BR",
"senderName": "Remetente de Teste 2",
"senderAddress": "S. SILVERSTONE WAY ",
"senderAddressNumber": "201654",
"senderAddressComplement": "comp ",
"senderZipCode": "83642555887858953222",
"senderCityName": "MERIDIAN",
"senderState": "",
"senderCountryCode": "US",
"senderEmail": "[email protected]",
"senderWebsite": "www.bodybuilding.comdfasdf",
"recipientName": "Destinatario de Teste 2",
"recipientDocumentType": "CPF",
"recipientDocumentNumber": "61385307056",
"recipientAddress": "QMSW 5 LOTE 2 BLOCO B",
"recipientAddressNumber": "4565456sad",
"recipientAddressComplement": "ED. SAN JUAN, APTO 600",
"recipientCityName": "SAO PAULO",
"recipientState": "SP",
"recipientZipCode": "17270001",
"recipientEmail": "[email protected]",
"recipientPhoneNumber": "1499999999",
"totalWeight": 120,
"packagingLength": 16,
"packagingWidth": 11,
"packagingHeight": 2,
"taxPaymentMethod": "DDU",
"currency": "USD",
"freightPaidValue": 7.54,
"insurancePaidValue": 0,
"items": [
{
"hsCode": "401120",
"description": "TOYS, GAMES AND SPORTS REQUISITES",
"quantity": 1,
"value": 140.61
}
]
}
]
}`
func TestTrackingNumbersGet(t *testing.T) {
packList, err := client.GetTrackingNumbers()
spew.Dump(packList)
assert.NoError(t, err)
}
func TestTrackingNumbersPost(t *testing.T) {
trackingNumbers := &TrackingNumbersInput{}
var bPack = []byte(TrackingInput)
var err error
err = json.Unmarshal(bPack, trackingNumbers)
if err != nil {
spew.Dump(err)
}
packList, err := client.PostTrackingNumbers(trackingNumbers)
spew.Dump(packList)
assert.NoError(t, err)
}
func TestTrackingNumbersPut(t *testing.T) {
trackingNumbers := &PackageTrack{}
var bPack = []byte(TackingInputPut)
var err error
err = json.Unmarshal(bPack, trackingNumbers)
if err != nil {
spew.Dump(err)
}
packList, err := client.PutTrackingNumbers(trackingNumbers, "IX000478440BR")
spew.Dump(packList)
assert.NoError(t, err)
}
func TestPackageAsyncPut(t *testing.T) {
trackingNumbers := &PackList{}
var bPack = []byte(packageasyncPut)
var err error
err = json.Unmarshal(bPack, trackingNumbers)
if err != nil {
spew.Dump(err)
}
packList, err := client.PutPackageAsync(trackingNumbers)
spew.Dump(packList)
assert.NoError(t, err)
}
func TestPackageAsyncGet(t *testing.T) {
requestReturn, err := client.GetPackageAsync("854bc67f-1fef-45a8-8bc6-7f1fefa5a812")
spew.Dump(requestReturn)
assert.NoError(t, err)
}
func TestPackageTrackingNumbersGet(t *testing.T) {
packList, err := client.GetPackageTrackingNumbersId("NX000928682BR", "NX000928696BR")
spew.Dump(packList)
assert.NoError(t, err)
}
func TestPackageTrackingNumbersListGet(t *testing.T) {
requestReturn, err := client.GetPackageTrackingNumbersList(time.Now().AddDate(-1, 0, 0), time.Now())
spew.Dump(requestReturn)
assert.NoError(t, err)
}