From 756740a2d7e451c54b1df484a1869a6d9eba1d23 Mon Sep 17 00:00:00 2001 From: sinhluu Date: Wed, 8 May 2024 07:26:17 +0000 Subject: [PATCH 1/3] feat(onpoint): get inventories (#17) Co-authored-by: Sinh Reviewed-on: https://git.selly.red/Selly-Modules/3pl/pulls/17 --- partnerapi/onpoint/const.go | 3 +- partnerapi/onpoint/model_request.go | 19 +++++--- partnerapi/onpoint/model_response.go | 33 +++++++++++++ partnerapi/onpoint/onpoint.go | 69 ++++++++++++++++++++++++++-- 4 files changed, 112 insertions(+), 12 deletions(-) diff --git a/partnerapi/onpoint/const.go b/partnerapi/onpoint/const.go index d45efac..5c406a6 100644 --- a/partnerapi/onpoint/const.go +++ b/partnerapi/onpoint/const.go @@ -21,13 +21,14 @@ const ( apiPathUpdateDelivery = "/v1/orders/update_delivery" apiPathCancelOrder = "/v1/orders/cancel" apiPathGetChannels = "/v1/channels" + apiPathGetInventories = "/v1/inventories" headerXAPIKey = "x-api-key" headerXTimestamp = "x-timestamp" headerXSignature = "x-signature" webhookEventUpdateOrderStatus = "UPDATE_ORDER_STATUS" - webhookEventUpdateInventory = "update_inventory" + webhookEventUpdateInventory = "UPDATE_INVENTORY" ) var ( diff --git a/partnerapi/onpoint/model_request.go b/partnerapi/onpoint/model_request.go index aca58b3..7f5f11c 100644 --- a/partnerapi/onpoint/model_request.go +++ b/partnerapi/onpoint/model_request.go @@ -50,19 +50,24 @@ type CancelOrderRequest struct { OrderNo string `json:"order_code"` } +type ListInventoriesReq struct { + UpdatedFrom time.Time + UpdatedTo time.Time + SKUList []string + Size int + Page int +} + /** * WEBHOOK ONPOINT */ // WebhookDataUpdateInventory ... type WebhookDataUpdateInventory struct { - Sku string `json:"sku"` - PartnerSku string `json:"partner_sku"` - WarehouseCode string `json:"warehouse_code"` - AvailableQuantity int `json:"available_quantity"` - CommittedQuantity int `json:"committed_quantity"` - TotalQuantity int `json:"total_quantity"` - UpdatedAt string `json:"updated_at"` + Sku string `json:"sku"` + AvailableQuantity int `json:"available_quantity"` + PickupLocationCode string `json:"pickup_location_code"` + UpdatedAt time.Time `json:"updated_at"` } // WebhookDataUpdateOrderStatus ... diff --git a/partnerapi/onpoint/model_response.go b/partnerapi/onpoint/model_response.go index 6ed84e0..237543a 100644 --- a/partnerapi/onpoint/model_response.go +++ b/partnerapi/onpoint/model_response.go @@ -1,5 +1,7 @@ package onpoint +import "time" + // CreateOrderResponse ... type CreateOrderResponse struct { OrderCode string `json:"order_code"` @@ -34,3 +36,34 @@ type ChannelResponse struct { Code string `json:"code"` Name string `json:"name"` } + +type ListInventoriesRes struct { + Code string `json:"code"` + Data struct { + Entries []InventoryEntry `json:"entries"` + Page int `json:"page"` + Size int `json:"size"` + TotalEntries int `json:"total_entries"` + TotalPages int `json:"total_pages"` + } `json:"data"` +} + +type InventoryEntry struct { + AvailableQuantity int `json:"available_quantity"` + PickupLocation Pickup `json:"pickup_location"` + Product Product `json:"product"` + UpdatedAt time.Time `json:"updated_at"` +} + +type Product struct { + Name string `json:"name"` + OriginalPrice int `json:"original_price"` + SellingPrice int `json:"selling_price"` + Sku string `json:"sku"` + Uom interface{} `json:"uom"` +} + +type Pickup struct { + Code string `json:"code"` + Name string `json:"name"` +} diff --git a/partnerapi/onpoint/onpoint.go b/partnerapi/onpoint/onpoint.go index c1f0cf1..a05a079 100644 --- a/partnerapi/onpoint/onpoint.go +++ b/partnerapi/onpoint/onpoint.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "net/http" + "net/url" "strconv" "strings" "time" @@ -152,19 +153,77 @@ func (c *Client) CancelOrder(p CancelOrderRequest) (*CancelOrderResponse, error) return &dataRes.Data, nil } +// GetInventories ... +func (c *Client) GetInventories(req ListInventoriesReq) (*ListInventoriesRes, error) { + url := c.getBaseURL() + apiPathGetInventories + q := map[string]string{} + if !req.UpdatedFrom.IsZero() { + q["updated_from"] = req.UpdatedFrom.Format(TimeLayout) + } + if !req.UpdatedTo.IsZero() { + q["updated_to"] = req.UpdatedTo.Format(TimeLayout) + } + if len(req.SKUList) > 0 { + q["sku_list"] = strings.Join(req.SKUList, ",") + } + if req.Page > 0 { + q["page"] = strconv.Itoa(req.Page) + } + if req.Size > 0 { + q["size"] = strconv.Itoa(req.Size) + } + natsPayload := model.CommunicationRequestHttp{ + ResponseImmediately: true, + Payload: model.HttpRequest{ + URL: url, + Method: http.MethodGet, + Query: q, + }, + } + var ( + r model.CommunicationHttpResponse + errRes Error + dataRes ListInventoriesRes + ) + if err := c.requestHttpViaNats(natsPayload, &r); err != nil { + return nil, err + } + res := r.Response + if res == nil { + return nil, fmt.Errorf("onpoint.Client.GetInventories: empty_response") + } + if res.StatusCode >= http.StatusBadRequest { + if err := r.ParseResponseData(&errRes); err != nil { + return nil, fmt.Errorf("onpoint.Client.GetInventories: parse_response_err: %v", err) + } + return nil, errRes + } + if err := r.ParseResponseData(&dataRes); err != nil { + return nil, fmt.Errorf("onpoint.Client.GetInventories: parse_response_data: %v", err) + } + + return &dataRes, nil +} + func (c *Client) requestHttpViaNats(data model.CommunicationRequestHttp, res interface{}) error { ec, err := c.natsClient.NewJSONEncodedConn() if err != nil { return fmt.Errorf("onpoint: request via nats %v", err) } - qs := "" - for k, v := range data.Payload.Query { - qs += k + "=" + v + u, err := url.ParseRequestURI(data.Payload.URL) + if err != nil { + return fmt.Errorf("onpoint: request via nats %v", err) } + q := u.Query() + for k, v := range data.Payload.Query { + q.Set(k, v) + } + u.RawQuery = q.Encode() + now := time.Now().Unix() ts := strconv.FormatInt(now, 10) arr := []string{ - qs, + u.RawQuery, data.Payload.Data, ts, } @@ -177,6 +236,8 @@ func (c *Client) requestHttpViaNats(data model.CommunicationRequestHttp, res int headerXTimestamp: ts, httputil.HeaderKeyContentType: httputil.HeaderValueApplicationJSON, } + data.Payload.Query = map[string]string{} + data.Payload.URL = u.String() return ec.Request(subject.Communication.RequestHTTP, data, res) } From 1034d2e077a5e8384f2886d7408218abf88c3b71 Mon Sep 17 00:00:00 2001 From: Sinh Date: Fri, 14 Jun 2024 17:31:02 +0700 Subject: [PATCH 2/3] feat: refactor ViettelFFM partner API integration - Add the `const.go` file defining `ENV` type and constants `EnvStaging` and `EnvProd` - Update `go.mod` to use `go 1.20` instead of `go 1.17` - Introduce `model.go` file for ViettelFFM partner API structs - Implement client methods for creating outbound requests and updating logistics information - Implement an authentication method for the client with `AuthRes` struct - Define constants for base URLs and authentication paths in ViettelFFM client - Implement helper methods for getting base URL and making HTTP requests via NATS - Update `util/httputil/const.go` to include `HeaderKeyAuthorization` constant Signed-off-by: Sinh --- const.go | 9 ++ go.mod | 4 +- go.sum | 4 - partnerapi/viettelffm/model.go | 65 +++++++++ partnerapi/viettelffm/viettel_ffm.go | 201 +++++++++++++++++++++++++++ util/httputil/const.go | 3 +- 6 files changed, 279 insertions(+), 7 deletions(-) create mode 100644 const.go create mode 100644 partnerapi/viettelffm/model.go create mode 100644 partnerapi/viettelffm/viettel_ffm.go diff --git a/const.go b/const.go new file mode 100644 index 0000000..bd57f3a --- /dev/null +++ b/const.go @@ -0,0 +1,9 @@ +package tpl + +// ENV ... +type ENV string + +const ( + EnvStaging ENV = "STAGING" + EnvProd ENV = "PROD" +) diff --git a/go.mod b/go.mod index c96ff3a..5bcc490 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,11 @@ module git.selly.red/Selly-Modules/3pl -go 1.17 +go 1.20 require ( git.selly.red/Selly-Modules/logger v0.0.2-0.20221010053254-567df039afdb git.selly.red/Selly-Modules/natsio v1.0.3-0.20231020090841-5edec97ee393 + github.com/go-resty/resty/v2 v2.7.0 github.com/nats-io/nats.go v1.17.0 github.com/thoas/go-funk v0.9.2 ) @@ -14,7 +15,6 @@ require ( github.com/elastic/go-licenser v0.4.1 // indirect github.com/elastic/go-sysinfo v1.1.1 // indirect github.com/elastic/go-windows v1.0.1 // indirect - github.com/go-resty/resty/v2 v2.7.0 // indirect github.com/golang/snappy v0.0.3 // indirect github.com/jcchavezs/porto v0.4.0 // indirect github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect diff --git a/go.sum b/go.sum index 4599338..359510a 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,5 @@ git.selly.red/Selly-Modules/logger v0.0.2-0.20221010053254-567df039afdb h1:AmcYd88IcdSkH+NEvKyJLT7psidSkjJQT/nAg/KuzFk= git.selly.red/Selly-Modules/logger v0.0.2-0.20221010053254-567df039afdb/go.mod h1:Q1//Z6HRmfa7VyjH2J6YyT0YV2jT8+K6SIgwnYuS4II= -git.selly.red/Selly-Modules/natsio v1.0.2-0.20221010041139-c11419a3ad33 h1:GvQjelaV4XZm++AOihYAKOD6k9510aMAr6B6MGnrXPs= -git.selly.red/Selly-Modules/natsio v1.0.2-0.20221010041139-c11419a3ad33/go.mod h1:KNODhfeBqxRmHHQHHU+p3JfH42t8s5aNxfgr6X8fr6g= -git.selly.red/Selly-Modules/natsio v1.0.3-0.20231006093940-b3bde5cd0960 h1:wL/BW1xGoB/EXeA2HtxT6Nr/cXpPJYVNfToV3aFtGls= -git.selly.red/Selly-Modules/natsio v1.0.3-0.20231006093940-b3bde5cd0960/go.mod h1:KNODhfeBqxRmHHQHHU+p3JfH42t8s5aNxfgr6X8fr6g= git.selly.red/Selly-Modules/natsio v1.0.3-0.20231020090841-5edec97ee393 h1:43kE03FW3NONfE6hXlghafS1d233dfc7grlFqd+15SA= git.selly.red/Selly-Modules/natsio v1.0.3-0.20231020090841-5edec97ee393/go.mod h1:KNODhfeBqxRmHHQHHU+p3JfH42t8s5aNxfgr6X8fr6g= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= diff --git a/partnerapi/viettelffm/model.go b/partnerapi/viettelffm/model.go new file mode 100644 index 0000000..b247f52 --- /dev/null +++ b/partnerapi/viettelffm/model.go @@ -0,0 +1,65 @@ +package viettelffm + +type AuthRes struct { + AccessToken string `json:"access_token"` + ExpiresIn int `json:"expires_in"` + RefreshExpiresIn int `json:"refresh_expires_in"` + RefreshToken string `json:"refresh_token"` + TokenType string `json:"token_type"` + NotBeforePolicy int `json:"not-before-policy"` + SessionState string `json:"session_state"` + Scope string `json:"scope"` +} + +type UpdateLogisticInfoPayload struct { + PrintLabelLink string `json:"print_label_link"` + TrackingCode string `json:"tracking_code"` +} + +type ORPayload struct { + OrProductLines []ORProductLine `json:"or_product_lines"` + AmountPaid float64 `json:"amount_paid"` + CodAmount float64 `json:"cod_amount"` + CodType string `json:"cod_type"` + Note string `json:"note"` + OrCode string `json:"or_code"` + OrType string `json:"or_type"` + ShippingType string `json:"shipping_type"` + CustomerName string `json:"customer_name"` + CustomerEmail string `json:"customer_email"` + PackType string `json:"pack_type"` + PriorityType string `json:"priority_type"` + Warehouse ORWarehouse `json:"warehouse"` +} + +type ORProductLine struct { + Discount float64 `json:"discount"` + Price float64 `json:"price"` + Product Product `json:"product"` + Quantity int `json:"quantity"` + SpecifiedProductLine SpecifiedProductLine `json:"specified_product_line"` + Unit string `json:"unit"` +} + +type SpecifiedProductLine struct { + ProductConditionType ProdCondType `json:"product_condition_type"` +} + +type Product struct { + PartnerSku string `json:"partner_sku"` + ProductId int `json:"product_id"` +} + +type ProdCondType struct { + Name string `json:"name"` +} + +type ORWarehouse struct { + WarehouseId int `json:"warehouse_id"` +} + +type ORResult struct { + OrCode string `json:"or_code"` + OrId int `json:"or_id"` + Status string `json:"status"` +} diff --git a/partnerapi/viettelffm/viettel_ffm.go b/partnerapi/viettelffm/viettel_ffm.go new file mode 100644 index 0000000..daefd13 --- /dev/null +++ b/partnerapi/viettelffm/viettel_ffm.go @@ -0,0 +1,201 @@ +package viettelffm + +import ( + "errors" + "fmt" + "net/http" + "net/url" + "time" + + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" + + tpl "git.selly.red/Selly-Modules/3pl" + "git.selly.red/Selly-Modules/3pl/util/httputil" + "git.selly.red/Selly-Modules/3pl/util/pjson" +) + +const ( + baseURLStag = "https://stg-gw.viettelpost.vn" + baseURLAuthStag = "https://stg-keycloak.viettelpost.vn" + + // TODO: update prod url + baseURLProd = "" + baseURLAuthProd = "" + + pathAuth = "/realms/wms/protocol/openid-connect/token" + pathUpdateORLogisticInfo = "/wms-core/api/v1/obms/outbound-request/outbound-request-partner/%s/bill" + pathCreateOR = "/wms-core/api/v1/obms/outbound-request/outbound-request-partner" + + logTarget = "viettel-ffm" +) + +var ( + baseURLENVMapping = map[tpl.ENV]string{ + tpl.EnvProd: baseURLProd, + tpl.EnvStaging: baseURLStag, + } +) + +type Client struct { + env tpl.ENV + username string + password string + + natsClient natsio.Server + authInfo *AuthRes + authTokenExpireTime time.Time +} + +// NewClient generate OnPoint client +func NewClient(env tpl.ENV, user, pwd string, nc natsio.Server) (*Client, error) { + if user == "" || pwd == "" { + return nil, errors.New("viettelffm: cannot init with empty api key") + } + return &Client{ + env: env, + username: user, + password: pwd, + natsClient: nc, + }, nil +} + +func (c *Client) CreateOR(p ORPayload) (*ORResult, error) { + apiURL := c.getBaseURL() + pathCreateOR + token, err := c.getToken() + if err != nil { + return nil, err + } + natsPayload := model.CommunicationRequestHttp{ + ResponseImmediately: true, + Payload: model.HttpRequest{ + URL: apiURL, + Method: http.MethodPost, + Data: pjson.ToJSONString(p), + Header: map[string]string{ + httputil.HeaderKeyAuthorization: fmt.Sprintf("Bearer %s", token), + httputil.HeaderKeyContentType: httputil.HeaderValueApplicationJSON, + }, + }, + LogTarget: logTarget, + } + r, err := c.requestHttpViaNats(natsPayload) + if err != nil { + return nil, fmt.Errorf("viettelffm.Client.CreateOR - requestHttpViaNats %v", err) + } + + res := r.Response + if res.StatusCode >= http.StatusBadRequest { + return nil, fmt.Errorf("viettelffm.Client.CreateOR - requestHttpViaNats %s", res.Body) + } + var data ORResult + if err = r.ParseResponseData(&data); err != nil { + return nil, fmt.Errorf("viettelffm.Client.CreateOR - requestHttpViaNats parse response %v, %s", err, res.Body) + } + return &data, nil +} + +func (c *Client) UpdateOutboundRequestLogisticInfo(p UpdateLogisticInfoPayload) error { + apiURL := c.getBaseURL() + pathUpdateORLogisticInfo + token, err := c.getToken() + if err != nil { + return err + } + natsPayload := model.CommunicationRequestHttp{ + ResponseImmediately: true, + Payload: model.HttpRequest{ + URL: apiURL, + Method: http.MethodPost, + Data: pjson.ToJSONString(p), + Header: map[string]string{ + httputil.HeaderKeyAuthorization: fmt.Sprintf("Bearer %s", token), + httputil.HeaderKeyContentType: httputil.HeaderValueApplicationJSON, + }, + }, + LogTarget: logTarget, + } + r, err := c.requestHttpViaNats(natsPayload) + if err != nil { + return err + } + res := r.Response + if res.StatusCode >= http.StatusBadRequest { + return fmt.Errorf("viettelffm.Client.UpdateOutboundRequestLogisticInfo - requestHttpViaNats %s", res.Body) + } + return nil +} + +// Auth ... +func (c *Client) Auth() (*AuthRes, error) { + v := url.Values{} + v.Set("username", c.username) + v.Set("password", c.password) + v.Set("grant_type", "password") + v.Set("client_id", "wms_account") + b := v.Encode() + header := map[string]string{ + httputil.HeaderKeyContentType: httputil.HeaderValueApplicationURLEncoded, + } + bURL := baseURLAuthStag + if c.env == tpl.EnvProd { + bURL = baseURLAuthProd + } + api := bURL + pathAuth + natsPayload := model.CommunicationRequestHttp{ + ResponseImmediately: true, + Payload: model.HttpRequest{ + URL: api, + Method: http.MethodPost, + Data: b, + Header: header, + }, + LogTarget: logTarget, + } + r, err := c.requestHttpViaNats(natsPayload) + if err != nil { + return nil, fmt.Errorf("viettelffm.Client.Auth - requestHttpViaNats: payload %+v, err %v\n", natsPayload, err) + } + + res := r.Response + if res.StatusCode >= http.StatusBadRequest { + return nil, fmt.Errorf("viettelffm.Client.Auth - requestHttpViaNats %s", res.Body) + } + var data AuthRes + if err = r.ParseResponseData(&data); err != nil { + return nil, fmt.Errorf("viettelffm.Client.Auth - requestHttpViaNats parse response %v, %s", err, res.Body) + } + return &data, nil +} + +func (c *Client) getToken() (string, error) { + if c.authInfo == nil || time.Now().After(c.authTokenExpireTime) { + auth, err := c.Auth() + if err != nil { + return "", err + } + c.authInfo = auth + c.authTokenExpireTime = time.Now().Add(time.Duration(auth.ExpiresIn) * time.Second).Add(-time.Minute) + } + return c.authInfo.AccessToken, nil +} + +func (c *Client) getBaseURL() string { + return baseURLENVMapping[c.env] +} + +func (c *Client) requestHttpViaNats(data model.CommunicationRequestHttp) (*model.CommunicationHttpResponse, error) { + b := pjson.ToBytes(data) + msg, err := c.natsClient.Request(subject.Communication.RequestHTTP, b) + if err != nil { + return nil, fmt.Errorf("viettelffm.Client.requestHttpViaNats err: %v, url %s", err, data.Payload.URL) + } + var r model.CommunicationHttpResponse + if err = pjson.Unmarshal(msg.Data, &r); err != nil { + return nil, fmt.Errorf("viettelffm.Client.requestHttpViaNats parse data err: %v, url %s, data %s", err, data.Payload.URL, string(msg.Data)) + } + if r.Response == nil { + return nil, fmt.Errorf("viettelffm.Client.requestHttpViaNats empty reponse") + } + return &r, nil +} diff --git a/util/httputil/const.go b/util/httputil/const.go index c708838..90eeb6c 100644 --- a/util/httputil/const.go +++ b/util/httputil/const.go @@ -1,7 +1,8 @@ package httputil const ( - HeaderKeyContentType = "Content-Type" + HeaderKeyContentType = "Content-Type" + HeaderKeyAuthorization = "Authorization" HeaderValueApplicationJSON = "application/json" HeaderValueApplicationURLEncoded = "application/x-www-form-urlencoded" From 178652fcefec5cd18108acbb3f2380706807b78e Mon Sep 17 00:00:00 2001 From: Sinh Date: Tue, 18 Jun 2024 16:02:52 +0700 Subject: [PATCH 3/3] feat: refactor logistics functions in Viettel FFM module - Add a new type `CancelORPayload` to the file `model.go` - Add a new constant `pathCancelOR` in the `viettel_ffm.go` file - Change the method from `POST` to `PUT` in the `UpdateORLogisticInfo` function in `viettel_ffm.go` - Add a new function `CancelOR` in the `viettel_ffm.go` file Signed-off-by: Sinh --- partnerapi/viettelffm/model.go | 4 ++++ partnerapi/viettelffm/viettel_ffm.go | 35 ++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/partnerapi/viettelffm/model.go b/partnerapi/viettelffm/model.go index b247f52..3b9496a 100644 --- a/partnerapi/viettelffm/model.go +++ b/partnerapi/viettelffm/model.go @@ -16,6 +16,10 @@ type UpdateLogisticInfoPayload struct { TrackingCode string `json:"tracking_code"` } +type CancelORPayload struct { + OrID int `json:"or_id"` +} + type ORPayload struct { OrProductLines []ORProductLine `json:"or_product_lines"` AmountPaid float64 `json:"amount_paid"` diff --git a/partnerapi/viettelffm/viettel_ffm.go b/partnerapi/viettelffm/viettel_ffm.go index daefd13..e83ce32 100644 --- a/partnerapi/viettelffm/viettel_ffm.go +++ b/partnerapi/viettelffm/viettel_ffm.go @@ -27,6 +27,7 @@ const ( pathAuth = "/realms/wms/protocol/openid-connect/token" pathUpdateORLogisticInfo = "/wms-core/api/v1/obms/outbound-request/outbound-request-partner/%s/bill" pathCreateOR = "/wms-core/api/v1/obms/outbound-request/outbound-request-partner" + pathCancelOR = "/wms-core/api/v1/obms/outbound-request/cancel" logTarget = "viettel-ffm" ) @@ -96,12 +97,42 @@ func (c *Client) CreateOR(p ORPayload) (*ORResult, error) { return &data, nil } -func (c *Client) UpdateOutboundRequestLogisticInfo(p UpdateLogisticInfoPayload) error { +func (c *Client) UpdateORLogisticInfo(p UpdateLogisticInfoPayload) error { apiURL := c.getBaseURL() + pathUpdateORLogisticInfo token, err := c.getToken() if err != nil { return err } + natsPayload := model.CommunicationRequestHttp{ + ResponseImmediately: true, + Payload: model.HttpRequest{ + URL: apiURL, + Method: http.MethodPut, + Data: pjson.ToJSONString(p), + Header: map[string]string{ + httputil.HeaderKeyAuthorization: fmt.Sprintf("Bearer %s", token), + httputil.HeaderKeyContentType: httputil.HeaderValueApplicationJSON, + }, + }, + LogTarget: logTarget, + } + r, err := c.requestHttpViaNats(natsPayload) + if err != nil { + return err + } + res := r.Response + if res.StatusCode >= http.StatusBadRequest { + return fmt.Errorf("viettelffm.Client.UpdateOutboundRequestLogisticInfo - requestHttpViaNats %s", res.Body) + } + return nil +} + +func (c *Client) CancelOR(p CancelORPayload) error { + apiURL := c.getBaseURL() + pathCancelOR + token, err := c.getToken() + if err != nil { + return err + } natsPayload := model.CommunicationRequestHttp{ ResponseImmediately: true, Payload: model.HttpRequest{ @@ -121,7 +152,7 @@ func (c *Client) UpdateOutboundRequestLogisticInfo(p UpdateLogisticInfoPayload) } res := r.Response if res.StatusCode >= http.StatusBadRequest { - return fmt.Errorf("viettelffm.Client.UpdateOutboundRequestLogisticInfo - requestHttpViaNats %s", res.Body) + return fmt.Errorf("viettelffm.Client.CancelOR - requestHttpViaNats %s", res.Body) } return nil }