Develop #22
|
@ -18,7 +18,7 @@ func GetCommunication() Communication {
|
|||
|
||||
// RequestHttp ...
|
||||
func (c Communication) RequestHttp(p model.CommunicationRequestHttp) (r *model.CommunicationHttpResponse, err error) {
|
||||
msg, err := natsio.GetServer().Request(subject.CommunicationRequestHTTP, toBytes(p))
|
||||
msg, err := natsio.GetServer().Request(subject.Communication.RequestHTTP, toBytes(p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ func GetOrder() Order {
|
|||
|
||||
// UpdateORStatus ...
|
||||
func (o Order) UpdateORStatus(p model.OrderUpdateORStatus) error {
|
||||
msg, err := natsio.GetServer().Request(subject.OrderUpdateORStatus, toBytes(p))
|
||||
msg, err := natsio.GetServer().Request(subject.Order.UpdateORStatus, toBytes(p))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func (o Order) UpdateORStatus(p model.OrderUpdateORStatus) error {
|
|||
|
||||
// CancelDelivery ...
|
||||
func (o Order) CancelDelivery(p model.OrderCancelDelivery) error {
|
||||
msg, err := natsio.GetServer().Request(subject.OrderUpdateORStatus, toBytes(p))
|
||||
msg, err := natsio.GetServer().Request(subject.Order.UpdateORStatus, toBytes(p))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ func GetWarehouse() Warehouse {
|
|||
|
||||
// CreateOutboundRequest ...
|
||||
func (w Warehouse) CreateOutboundRequest(p model.OutboundRequestPayload) (*model.OutboundRequestResponse, error) {
|
||||
msg, err := natsio.GetServer().Request(subject.WarehouseCreateOutboundRequest, toBytes(p))
|
||||
msg, err := natsio.GetServer().Request(subject.Warehouse.CreateOutboundRequest, toBytes(p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func (w Warehouse) CreateOutboundRequest(p model.OutboundRequestPayload) (*model
|
|||
|
||||
// UpdateOutboundRequestLogisticInfo ...
|
||||
func (w Warehouse) UpdateOutboundRequestLogisticInfo(p model.UpdateOutboundRequestLogisticInfoPayload) error {
|
||||
msg, err := natsio.GetServer().Request(subject.WarehouseUpdateOutboundRequestLogistic, toBytes(p))
|
||||
msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateOutboundRequestLogistic, toBytes(p))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ func (w Warehouse) UpdateOutboundRequestLogisticInfo(p model.UpdateOutboundReque
|
|||
|
||||
// CancelOutboundRequest ...
|
||||
func (w Warehouse) CancelOutboundRequest(p model.CancelOutboundRequest) error {
|
||||
msg, err := natsio.GetServer().Request(subject.WarehouseCancelOutboundRequest, toBytes(p))
|
||||
msg, err := natsio.GetServer().Request(subject.Warehouse.CancelOutboundRequest, toBytes(p))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func (w Warehouse) CancelOutboundRequest(p model.CancelOutboundRequest) error {
|
|||
|
||||
// GetConfigByWarehouseID ...
|
||||
func (w Warehouse) GetConfigByWarehouseID(warehouseID string) (*model.WarehouseConfiguration, error) {
|
||||
msg, err := natsio.GetServer().Request(subject.WarehouseGetConfiguration, toBytes(warehouseID))
|
||||
msg, err := natsio.GetServer().Request(subject.Warehouse.GetConfiguration, toBytes(warehouseID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ type WarehouseSupplier struct {
|
|||
type WarehouseOrder struct {
|
||||
MinimumValue float64 `json:"minimumValue"`
|
||||
PaymentMethod WarehousePaymentMethod `json:"paymentMethod"`
|
||||
IsLimitNumberOfPurchases bool `json:"isLimitNumberOfPurchases" json:"isLimitNumberOfPurchases"`
|
||||
LimitNumberOfPurchases int64 `json:"limitNumberOfPurchases" json:"limitNumberOfPurchases"`
|
||||
IsLimitNumberOfPurchases bool `json:"isLimitNumberOfPurchases"`
|
||||
LimitNumberOfPurchases int64 `json:"limitNumberOfPurchases"`
|
||||
}
|
||||
|
||||
// WarehousePaymentMethod ...
|
||||
|
|
|
@ -3,7 +3,6 @@ package natsio
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/logrusorgru/aurora"
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
|
@ -49,7 +48,7 @@ func Connect(cfg Config) error {
|
|||
return errors.New(msg)
|
||||
}
|
||||
|
||||
fmt.Println(aurora.Green("*** CONNECTED TO NATS: " + cfg.URL))
|
||||
fmt.Printf("⚡️[natsio]: connected to %s \n", cfg.URL)
|
||||
|
||||
// Set client
|
||||
natsServer.instance = nc
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
package subject
|
||||
|
||||
const communicationPrefix = "communication_"
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
CommunicationRequestHTTP = communicationPrefix + "request_http"
|
||||
CommunicationResponseHTTP = communicationPrefix + "response_http"
|
||||
CommunicationWebhookTNC = communicationPrefix + "webhook_tnc"
|
||||
CommunicationWebhookGlobalCare = communicationPrefix + "webhook_global_care"
|
||||
)
|
||||
func getCommunicationValue(val string) string {
|
||||
return fmt.Sprintf("%s.%s", prefixes.Communication, val)
|
||||
}
|
||||
|
||||
var Communication = struct {
|
||||
RequestHTTP string
|
||||
ResponseHTTP string
|
||||
WebhookTNC string
|
||||
WebhookGlobalCare string
|
||||
}{
|
||||
RequestHTTP: getCommunicationValue("request_http"),
|
||||
ResponseHTTP: getCommunicationValue("response_http"),
|
||||
WebhookTNC: getCommunicationValue("webhook_tnc"),
|
||||
WebhookGlobalCare: getCommunicationValue("webhook_global_care"),
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package subject
|
||||
|
||||
var prefixes = struct {
|
||||
Communication string
|
||||
Order string
|
||||
Warehouse string
|
||||
}{
|
||||
Communication: "communication",
|
||||
Order: "order",
|
||||
Warehouse: "warehouse",
|
||||
}
|
|
@ -1,8 +1,17 @@
|
|||
package subject
|
||||
|
||||
const orderPrefix = "order_"
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
OrderUpdateORStatus = orderPrefix + "update_outbound_request_status"
|
||||
OrderCancelDelivery = orderPrefix + "cancel_delivery"
|
||||
)
|
||||
func getOrderValue(val string) string {
|
||||
return fmt.Sprintf("%s.%s", prefixes.Order, val)
|
||||
}
|
||||
|
||||
var Order = struct {
|
||||
UpdateORStatus string
|
||||
CancelDelivery string
|
||||
WebhookTNC string
|
||||
WebhookGlobalCare string
|
||||
}{
|
||||
UpdateORStatus: getOrderValue("update_outbound_request_status"),
|
||||
CancelDelivery: getOrderValue("cancel_delivery"),
|
||||
}
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
package subject
|
||||
|
||||
const warehousePrefix = "warehouse_"
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
WarehouseCreateOutboundRequest = warehousePrefix + "create_outbound_request"
|
||||
WarehouseUpdateOutboundRequestLogistic = warehousePrefix + "update_outbound_request_logistic_info"
|
||||
WarehouseCancelOutboundRequest = warehousePrefix + "cancel_outbound_request"
|
||||
WarehouseGetConfiguration = warehousePrefix + "get_configuration"
|
||||
)
|
||||
func getWarehouseValue(val string) string {
|
||||
return fmt.Sprintf("%s.%s", prefixes.Warehouse, val)
|
||||
}
|
||||
|
||||
var Warehouse = struct {
|
||||
CreateOutboundRequest string
|
||||
UpdateOutboundRequestLogistic string
|
||||
CancelOutboundRequest string
|
||||
GetConfiguration string
|
||||
}{
|
||||
CreateOutboundRequest: getWarehouseValue("create_outbound_request"),
|
||||
UpdateOutboundRequestLogistic: getWarehouseValue("update_outbound_request_logistic_info"),
|
||||
CancelOutboundRequest: getWarehouseValue("cancel_outbound_request"),
|
||||
GetConfiguration: getWarehouseValue("get_configuration"),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue