From 90047717047bf3ba900e7cd79011134cc823c823 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 8 Apr 2024 15:40:13 +0700 Subject: [PATCH] feat(warehouse): add warehouse method get list config --- client/warehouse.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/client/warehouse.go b/client/warehouse.go index 3e4a54d..9993fd7 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -146,6 +146,25 @@ func (w Warehouse) GetConfigByWarehouseID(warehouseID string) (*model.WarehouseC return r.Data, nil } +// GetListConfig ... +func (w Warehouse) GetListConfig(req model.GetListWarehouseConfigReq) ([]*model.WarehouseConfiguration, error) { + msg, err := natsio.GetServer().Request(subject.Warehouse.GetListWarehouseConfig, toBytes(req)) + if err != nil { + return nil, err + } + var r struct { + Data []*model.WarehouseConfiguration `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + return r.Data, nil +} + // GetWarehouses ... func (w Warehouse) GetWarehouses(p model.GetWarehousesRequest) (*model.GetWarehousesResponse, error) { msg, err := natsio.GetServer().Request(subject.Warehouse.GetWarehouses, toBytes(p))