-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgoods.warehouse.go
50 lines (43 loc) · 1.39 KB
/
goods.warehouse.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
package temu
import (
"context"
validation "github.com/go-ozzo/ozzo-validation/v4"
"github.com/hiscaler/temu-go/entity"
"github.com/hiscaler/temu-go/normal"
"github.com/hiscaler/temu-go/validators/is"
)
// 商品仓库服务
type goodsWarehouseService service
type GoodsWarehouseQueryParams struct {
SiteIdList []int `json:"siteIdList"` // 站点列表
}
func (m GoodsWarehouseQueryParams) validate() error {
return validation.ValidateStruct(&m,
validation.Field(&m.SiteIdList,
validation.Required.Error("站点列表不能为空"),
validation.By(is.SiteIds(entity.SiteIds)),
),
)
}
// Query 根据站点查询可绑定的发货仓库信息接口(半托管专属)
// https://seller.kuajingmaihuo.com/sop/view/867739977041685428#hpIdAo
func (s goodsWarehouseService) Query(ctx context.Context, params GoodsWarehouseQueryParams) (items []entity.SiteWarehouses, err error) {
if err = params.validate(); err != nil {
return items, invalidInput(err)
}
var result = struct {
normal.Response
Result struct {
WarehouseDTOList []entity.SiteWarehouses `json:"warehouseDTOList"` // 可选发货仓列表
} `json:"result"`
}{}
resp, err := s.httpClient.R().
SetContext(ctx).
SetBody(params).
SetResult(&result).
Post("bg.goods.warehouse.list.get")
if err = recheckError(resp, result.Response, err); err != nil {
return items, err
}
return result.Result.WarehouseDTOList, nil
}