-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcouriers_example_test.go
67 lines (53 loc) · 1.23 KB
/
couriers_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
package trackingmore_test
import (
"context"
"fmt"
"github.com/trackingmore-api/trackingmore-sdk-go"
)
func ExampleClient_GetCouriers() {
key := "your api key"
cli, err := trackingmore.NewClient(key)
if err != nil {
fmt.Println(err)
return
}
result, err := cli.GetAllCouriers(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(result)
var couriers, ok = result.Data.(*[]trackingmore.Courier)
if !ok {
fmt.Println("Structure type conversion failed")
return
}
for _, item := range *couriers {
fmt.Printf("courier_name:%s courier_code:%s\n", item.CourierName, item.CourierCode)
}
}
func ExampleClient_Detect() {
key := "your api key"
cli, err := trackingmore.NewClient(key)
if err != nil {
fmt.Println(err)
return
}
params := trackingmore.DetectParams{
TrackingNumber: "92612903029511573030094531",
}
result, err := cli.Detect(context.Background(), params)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(result)
var couriers, ok = result.Data.(*[]trackingmore.Courier)
if !ok {
fmt.Println("Structure type conversion failed")
return
}
for _, item := range *couriers {
fmt.Printf("courier_name:%s courier_code:%s\n", item.CourierName, item.CourierCode)
}
}