Integrate tnc #1

Merged
luuvansinh merged 2 commits from integrate-tnc into develop 2022-08-30 09:09:04 +00:00
5 changed files with 10 additions and 24 deletions
Showing only changes of commit 4f0da1a456 - Show all commits

View File

@ -1,9 +0,0 @@
package constant
const natsCommunicationPrefix = "communication_"
const (
NatsCommunicationSubjectRequestHTTP = natsCommunicationPrefix + "request_http"
NatsCommunicationSubjectResponseHTTP = natsCommunicationPrefix + "response_http"
NatsCommunicationSubjectWebhookTNC = natsCommunicationPrefix + "webhook_tnc"
)

7
go.mod
View File

@ -4,7 +4,9 @@ go 1.17
require ( require (
github.com/Selly-Modules/logger v0.0.1 github.com/Selly-Modules/logger v0.0.1
github.com/Selly-Modules/natsio v1.0.1-0.20220818104747-572120c26a1d github.com/Selly-Modules/natsio v1.0.1
github.com/nats-io/nats.go v1.13.0
github.com/thoas/go-funk v0.9.1
) )
require ( require (
@ -14,14 +16,11 @@ require (
github.com/elastic/go-windows v1.0.0 // indirect github.com/elastic/go-windows v1.0.0 // indirect
github.com/jcchavezs/porto v0.1.0 // indirect github.com/jcchavezs/porto v0.1.0 // indirect
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/nats-io/nats.go v1.13.0 // indirect
github.com/nats-io/nkeys v0.3.0 // indirect github.com/nats-io/nkeys v0.3.0 // indirect
github.com/nats-io/nuid v1.0.1 // indirect github.com/nats-io/nuid v1.0.1 // indirect
github.com/pkg/errors v0.8.1 // indirect github.com/pkg/errors v0.8.1 // indirect
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect
github.com/santhosh-tekuri/jsonschema v1.2.4 // indirect github.com/santhosh-tekuri/jsonschema v1.2.4 // indirect
github.com/thoas/go-funk v0.9.1 // indirect
go.elastic.co/apm v1.13.1 // indirect go.elastic.co/apm v1.13.1 // indirect
go.elastic.co/apm/module/apmzap v1.13.1 // indirect go.elastic.co/apm/module/apmzap v1.13.1 // indirect
go.elastic.co/fastjson v1.1.0 // indirect go.elastic.co/fastjson v1.1.0 // indirect

7
go.sum
View File

@ -1,9 +1,7 @@
github.com/Selly-Modules/logger v0.0.1 h1:dwLLtW53FfVBlklhdtFRB63eP0ofIh0IUQ/Gjgi0r5k= github.com/Selly-Modules/logger v0.0.1 h1:dwLLtW53FfVBlklhdtFRB63eP0ofIh0IUQ/Gjgi0r5k=
github.com/Selly-Modules/logger v0.0.1/go.mod h1:RWhSQ3F01an8KD00VjzRBZOMcE5eV2Cy0/l4ZkeieyU= github.com/Selly-Modules/logger v0.0.1/go.mod h1:RWhSQ3F01an8KD00VjzRBZOMcE5eV2Cy0/l4ZkeieyU=
github.com/Selly-Modules/natsio v1.0.0 h1:2GHm7upYn0CmqKPwfg2AXNmaAHuL7V9l36M4BgOmQ4M= github.com/Selly-Modules/natsio v1.0.1 h1:0HoP00hP0Fz5h03p23Al3aARZwg+JSKpOrBo5Oh7pwY=
github.com/Selly-Modules/natsio v1.0.0/go.mod h1:NG55g9ip18nvN5tfP6PcSEKec10/lOeIOZC8HqBVNlQ= github.com/Selly-Modules/natsio v1.0.1/go.mod h1:NG55g9ip18nvN5tfP6PcSEKec10/lOeIOZC8HqBVNlQ=
github.com/Selly-Modules/natsio v1.0.1-0.20220818104747-572120c26a1d h1:NnRejDZPFqvtphr2rtfwi0rGx+oN8yD8RwttViVddjY=
github.com/Selly-Modules/natsio v1.0.1-0.20220818104747-572120c26a1d/go.mod h1:NG55g9ip18nvN5tfP6PcSEKec10/lOeIOZC8HqBVNlQ=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
@ -42,7 +40,6 @@ github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/minio/highwayhash v1.0.1 h1:dZ6IIu8Z14VlC0VpfKofAhCy74wu/Qb5gcn52yWoz/0= github.com/minio/highwayhash v1.0.1 h1:dZ6IIu8Z14VlC0VpfKofAhCy74wu/Qb5gcn52yWoz/0=
github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY=

View File

@ -8,10 +8,10 @@ import (
"github.com/Selly-Modules/logger" "github.com/Selly-Modules/logger"
"github.com/Selly-Modules/natsio" "github.com/Selly-Modules/natsio"
"github.com/Selly-Modules/natsio/model" "github.com/Selly-Modules/natsio/model"
"github.com/Selly-Modules/natsio/subject"
"github.com/nats-io/nats.go" "github.com/nats-io/nats.go"
"github.com/thoas/go-funk" "github.com/thoas/go-funk"
"github.com/Selly-Modules/3pl/constant"
"github.com/Selly-Modules/3pl/util/base64" "github.com/Selly-Modules/3pl/util/base64"
"github.com/Selly-Modules/3pl/util/pjson" "github.com/Selly-Modules/3pl/util/pjson"
) )
@ -70,7 +70,7 @@ func (c *Client) CreateOrder(p CreateOrderPayload) (*CommonResponse, error) {
Data: pjson.ToJSONString(body), Data: pjson.ToJSONString(body),
}, },
} }
msg, err := c.requestNats(constant.NatsCommunicationSubjectRequestHTTP, natsPayload) msg, err := c.requestNats(subject.Communication.RequestHTTP, natsPayload)
if err != nil { if err != nil {
logger.Error("globalcare.Client.CreateOrder", logger.LogData{ logger.Error("globalcare.Client.CreateOrder", logger.LogData{
"err": err.Error(), "err": err.Error(),
@ -99,7 +99,7 @@ func (c *Client) GetOrder(orderCode string) (*CommonResponse, error) {
Method: http.MethodGet, Method: http.MethodGet,
}, },
} }
msg, err := c.requestNats(constant.NatsCommunicationSubjectRequestHTTP, natsPayload) msg, err := c.requestNats(subject.Communication.RequestHTTP, natsPayload)
if err != nil { if err != nil {
logger.Error("globalcare.Client.GetOrder", logger.LogData{ logger.Error("globalcare.Client.GetOrder", logger.LogData{
"err": err.Error(), "err": err.Error(),

View File

@ -9,9 +9,9 @@ import (
"github.com/Selly-Modules/logger" "github.com/Selly-Modules/logger"
"github.com/Selly-Modules/natsio" "github.com/Selly-Modules/natsio"
"github.com/Selly-Modules/natsio/model" "github.com/Selly-Modules/natsio/model"
"github.com/Selly-Modules/natsio/subject"
"github.com/nats-io/nats.go" "github.com/nats-io/nats.go"
"github.com/Selly-Modules/3pl/constant"
"github.com/Selly-Modules/3pl/util/pjson" "github.com/Selly-Modules/3pl/util/pjson"
) )
@ -288,9 +288,8 @@ func (c *Client) getRequestHeader() map[string]string {
} }
func (c *Client) requestHttpViaNats(data model.CommunicationRequestHttp) (*nats.Msg, error) { func (c *Client) requestHttpViaNats(data model.CommunicationRequestHttp) (*nats.Msg, error) {
s := constant.NatsCommunicationSubjectRequestHTTP
b := pjson.ToBytes(data) b := pjson.ToBytes(data)
return c.natsClient.Request(s, b) return c.natsClient.Request(subject.Communication.RequestHTTP, b)
} }
func (c *Client) getBaseURL() string { func (c *Client) getBaseURL() string {