-
Notifications
You must be signed in to change notification settings - Fork 15
/
logistics.go
112 lines (95 loc) · 2.55 KB
/
logistics.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
package tiktok
import (
"context"
"github.com/google/go-querystring/query"
)
const (
GetShippingInfoPATH = "/api/logistics/ship/get"
UpdateShippingInfoPATH = "/api/logistics/tracking"
GetShippingDocumentPATH = "/api/logistics/shipping_document"
GetWarehouseListPATH = "/api/logistics/get_warehouse_list"
GetShippingProviderPATH = "/api/logistics/shipping_providers"
GetSubscribedDeliveryPATH = "/api/logistics/get_subscribed_deliveryoptions"
)
func (c *Client) GetShippingInfo(ctx context.Context, p Param, req OrderIDReq) (data LogisticsGetShippingInfoData, err error) {
param, err := c.params(p)
if err != nil {
return
}
if err = c.validate.Struct(req); err != nil {
return
}
values, err := query.Values(req)
if err != nil {
return
}
for k, data := range values {
if items, ok := param[k]; ok {
param[k] = append(items, data...)
} else {
param[k] = data
}
}
err = c.Get(ctx, GetShippingInfoPATH, param, &data)
return
}
func (c *Client) UpdateShippingInfo(ctx context.Context, p Param, req UpdateShippingInfoReq) (err error) {
param, err := c.params(p)
if err != nil {
return
}
if err = c.validate.Struct(req); err != nil {
return
}
err = c.Post(ctx, UpdateShippingInfoPATH, param, req, nil)
return
}
func (c *Client) GetShippingDocument(ctx context.Context, p Param, req GetShippingDocumentRequest) (data GetShippingDocumentData, err error) {
param, err := c.params(p)
if err != nil {
return
}
if err = c.validate.Struct(req); err != nil {
return
}
values, err := query.Values(req)
if err != nil {
return
}
for k, data := range values {
if items, ok := param[k]; ok {
param[k] = append(items, data...)
} else {
param[k] = data
}
}
err = c.Get(ctx, GetShippingDocumentPATH, param, &data)
return
}
func (c *Client) GetWarehouseList(ctx context.Context, p Param) (data GetWarehouseListData, err error) {
param, err := c.params(p)
if err != nil {
return
}
err = c.Get(ctx, GetWarehouseListPATH, param, &data)
return
}
func (c *Client) GetShippingProvider(ctx context.Context, p Param) (data GetShippingProviderData, err error) {
param, err := c.params(p)
if err != nil {
return
}
err = c.Get(ctx, GetShippingProviderPATH, param, &data)
return
}
func (c *Client) GetSubscribedDelivery(ctx context.Context, p Param, req GetSubscribedDeliveryRequest) (data GetSubscribedDeliveryData, err error) {
param, err := c.params(p)
if err != nil {
return
}
if err = c.validate.Struct(req); err != nil {
return
}
err = c.Post(ctx, GetSubscribedDeliveryPATH, param, req, &data)
return
}