viettel-ffm #19
|
@ -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"`
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue