Merge pull request #2 from Selly-Modules/integrate-global-care
Integrate global care
This commit is contained in:
commit
b627377b17
|
@ -1,9 +0,0 @@
|
|||
package constant
|
||||
|
||||
const natsCommunicationPrefix = "communication_"
|
||||
|
||||
const (
|
||||
NatsCommunicationSubjectRequestHTTP = natsCommunicationPrefix + "request_http"
|
||||
NatsCommunicationSubjectResponseHTTP = natsCommunicationPrefix + "response_http"
|
||||
NatsCommunicationSubjectWebhookTNC = natsCommunicationPrefix + "webhook_tnc"
|
||||
)
|
12
go.mod
12
go.mod
|
@ -4,7 +4,9 @@ go 1.17
|
|||
|
||||
require (
|
||||
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.2-0.20220826163751-df340fefda0a
|
||||
github.com/nats-io/nats.go v1.13.0
|
||||
github.com/thoas/go-funk v0.9.1
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -14,21 +16,19 @@ require (
|
|||
github.com/elastic/go-windows v1.0.0 // indirect
|
||||
github.com/jcchavezs/porto v0.1.0 // 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/nuid v1.0.1 // indirect
|
||||
github.com/pkg/errors v0.8.1 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // 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/module/apmzap v1.13.1 // indirect
|
||||
go.elastic.co/fastjson v1.1.0 // indirect
|
||||
go.mongodb.org/mongo-driver v1.10.1 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
go.uber.org/zap v1.18.1 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
|
||||
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
|
||||
golang.org/x/mod v0.3.0 // indirect
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
|
||||
|
|
35
go.sum
35
go.sum
|
@ -1,9 +1,7 @@
|
|||
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/natsio v1.0.0 h1:2GHm7upYn0CmqKPwfg2AXNmaAHuL7V9l36M4BgOmQ4M=
|
||||
github.com/Selly-Modules/natsio v1.0.0/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/Selly-Modules/natsio v1.0.2-0.20220826163751-df340fefda0a h1:QmJ8iqksbU+1vUa2SijsAMSLnw1C5X4R8PYjuNPNCCE=
|
||||
github.com/Selly-Modules/natsio v1.0.2-0.20220826163751-df340fefda0a/go.mod h1:q9dqmiMyl9MUVYZsvAWDI85083rnLEGAEFfYajLOLUU=
|
||||
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/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||
|
@ -26,10 +24,12 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
|
|||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/jcchavezs/porto v0.1.0 h1:Xmxxn25zQMmgE7/yHYmh19KcItG81hIwfbEEFnd6w/Q=
|
||||
|
@ -37,15 +37,15 @@ github.com/jcchavezs/porto v0.1.0/go.mod h1:fESH0gzDHiutHRdX2hv27ojnOVFco37hg1W6
|
|||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4=
|
||||
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak=
|
||||
github.com/klauspost/compress v1.13.4 h1:0zhec2I8zGnjWcKyLl6i3gPqKANCCn5e9xmviEEeX6s=
|
||||
github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
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/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/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/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||
github.com/nats-io/jwt v1.2.2 h1:w3GMTO969dFg+UOKTmmyuu7IGdusK+7Ytlt//OYH/uU=
|
||||
github.com/nats-io/jwt v1.2.2/go.mod h1:/xX356yQA6LuXI9xWW7mZNpxgF2mBmGecH+Fj34sP5Q=
|
||||
github.com/nats-io/jwt/v2 v2.0.3 h1:i/O6cmIsjpcQyWDYNcq2JyZ3/VTF8SJ4JWluI5OhpvI=
|
||||
|
@ -61,8 +61,9 @@ github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV
|
|||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 h1:c8R11WC8m7KNMkTv/0+Be8vvwo4I3/Ut9AC2FW8fX3U=
|
||||
|
@ -77,6 +78,11 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
|
|||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M=
|
||||
github.com/thoas/go-funk v0.9.1/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
|
||||
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.elastic.co/apm v1.13.1 h1:ICIcUcQOImg/bve9mQVyLCvm1cSUZ1afdwK6ACnxczU=
|
||||
go.elastic.co/apm v1.13.1/go.mod h1:dylGv2HKR0tiCV+wliJz1KHtDyuD8SPe69oV7VyK6WY=
|
||||
|
@ -84,6 +90,8 @@ go.elastic.co/apm/module/apmzap v1.13.1 h1:Soa4vNYYabPvOW1vm1A00C0UcEmfEzcx3YBjA
|
|||
go.elastic.co/apm/module/apmzap v1.13.1/go.mod h1:Tu8/TwffpBoNGmI05VcL1Ye2AC8oXrlMKNaKD1TIQy0=
|
||||
go.elastic.co/fastjson v1.1.0 h1:3MrGBWWVIxe/xvsbpghtkFoPciPhOCmjsR/HfwEeQR4=
|
||||
go.elastic.co/fastjson v1.1.0/go.mod h1:boNGISWMjQsUPy/t6yqt2/1Wx4YNPSe+mZjlyw9vKKI=
|
||||
go.mongodb.org/mongo-driver v1.10.1 h1:NujsPveKwHaWuKUer/ceo9DzEe7HIj1SlJ6uvXZG0S4=
|
||||
go.mongodb.org/mongo-driver v1.10.1/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
|
||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
|
@ -99,8 +107,9 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
|||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI=
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI=
|
||||
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
|
@ -113,20 +122,25 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
|
|||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 h1:NusfzzA6yGQ+ua51ck7E3omNUX/JuqbFSaRGqU8CcLI=
|
||||
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
|
@ -157,7 +171,8 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M=
|
||||
howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
package globalcare
|
||||
|
||||
import (
|
||||
"crypto"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/Selly-Modules/logger"
|
||||
"github.com/Selly-Modules/natsio"
|
||||
"github.com/Selly-Modules/natsio/model"
|
||||
"github.com/Selly-Modules/natsio/subject"
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/thoas/go-funk"
|
||||
|
||||
"github.com/Selly-Modules/3pl/constant"
|
||||
"github.com/Selly-Modules/3pl/util/base64"
|
||||
"github.com/Selly-Modules/3pl/util/pjson"
|
||||
)
|
||||
|
@ -27,7 +32,7 @@ type Client struct {
|
|||
// NewClient generate Client
|
||||
// using privateKey to decrypt data from Global Care
|
||||
// using publicKey to encrypt data before send to Global Care
|
||||
func NewClient(env ENV, privateKey, publicKey string) (*Client, error) {
|
||||
func NewClient(env ENV, privateKey, publicKey string, natsClient natsio.Server) (*Client, error) {
|
||||
validENVs := []ENV{EnvProd, EnvDev, EnvStaging}
|
||||
if !funk.Contains(validENVs, env) {
|
||||
return nil, fmt.Errorf("globalcare.NewClient - invalid_env: %s", env)
|
||||
|
@ -43,11 +48,13 @@ func NewClient(env ENV, privateKey, publicKey string) (*Client, error) {
|
|||
return &Client{
|
||||
privateKey: privKey,
|
||||
publicKey: pubKey,
|
||||
env: env,
|
||||
natsClient: natsClient,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateOrder ...
|
||||
func (c *Client) CreateOrder(p CreateOrderPayload) (*CommonResponse, error) {
|
||||
func (c *Client) CreateOrder(p CreateOrderPayload) (*CreateOrderResponseDecoded, error) {
|
||||
url := c.getBaseURL() + apiPathCreateOrder
|
||||
data := createOrderData{
|
||||
ProductCode: productCodeDefault,
|
||||
|
@ -58,9 +65,14 @@ func (c *Client) CreateOrder(p CreateOrderPayload) (*CommonResponse, error) {
|
|||
InsuredInfo: p.InsuredInfo,
|
||||
}
|
||||
|
||||
dataString := base64.Encode(pjson.ToBytes(data))
|
||||
sign, err := c.signData(dataString)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("globalcare.Client.CreateOrder - sign_err %v", err)
|
||||
}
|
||||
body := CommonRequestBody{
|
||||
Signature: "", // TODO:implement
|
||||
Data: base64.Encode(pjson.ToBytes(data)),
|
||||
Signature: sign,
|
||||
Data: dataString,
|
||||
}
|
||||
natsPayload := model.CommunicationRequestHttp{
|
||||
ResponseImmediately: true,
|
||||
|
@ -68,9 +80,12 @@ func (c *Client) CreateOrder(p CreateOrderPayload) (*CommonResponse, error) {
|
|||
URL: url,
|
||||
Method: http.MethodPost,
|
||||
Data: pjson.ToJSONString(body),
|
||||
Header: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
}
|
||||
msg, err := c.requestNats(constant.NatsCommunicationSubjectRequestHTTP, natsPayload)
|
||||
msg, err := c.requestNats(subject.Communication.RequestHTTP, natsPayload)
|
||||
if err != nil {
|
||||
logger.Error("globalcare.Client.CreateOrder", logger.LogData{
|
||||
"err": err.Error(),
|
||||
|
@ -83,14 +98,38 @@ func (c *Client) CreateOrder(p CreateOrderPayload) (*CommonResponse, error) {
|
|||
res CommonResponse
|
||||
)
|
||||
if err = pjson.Unmarshal(msg.Data, &r); err != nil {
|
||||
log.Printf("globalcare.Client.CreateOrder - pjson.Unmarshal %v, %s\n", err, string(msg.Data))
|
||||
return nil, err
|
||||
}
|
||||
err = r.ParseResponseData(&res)
|
||||
return &res, err
|
||||
if err = r.ParseResponseData(&res); err != nil {
|
||||
log.Printf("globalcare.Client.CreateOrder - ParseResponseData %v, %s\n", err, string(msg.Data))
|
||||
return nil, err
|
||||
}
|
||||
if r.Response == nil {
|
||||
log.Println("globalcare.Client.CreateOrder - nil response")
|
||||
return nil, fmt.Errorf("globalcare.Client.CreateOrder create_order_empty_response")
|
||||
}
|
||||
|
||||
if r.Response.StatusCode >= http.StatusBadRequest {
|
||||
log.Println("globalcare.Client.CreateOrder - bad request", res)
|
||||
info, err := res.DecodeError()
|
||||
if err != nil {
|
||||
log.Println("globalcare.Client.CreateOrder - decode err", err)
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.New(info.Message)
|
||||
}
|
||||
info, err := res.DecodeCreateOrderSuccess()
|
||||
if err != nil {
|
||||
log.Println("globalcare.Client.CreateOrder - DecodeCreateOrderSuccess err:", err, string(msg.Data))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, err
|
||||
}
|
||||
|
||||
// GetOrder ...
|
||||
func (c *Client) GetOrder(orderCode string) (*CommonResponse, error) {
|
||||
func (c *Client) GetOrder(orderCode string) (*GetOrderResponseDecoded, error) {
|
||||
url := c.getBaseURL() + fmt.Sprintf(apiPathGetOrder, orderCode)
|
||||
natsPayload := model.CommunicationRequestHttp{
|
||||
ResponseImmediately: true,
|
||||
|
@ -99,7 +138,7 @@ func (c *Client) GetOrder(orderCode string) (*CommonResponse, error) {
|
|||
Method: http.MethodGet,
|
||||
},
|
||||
}
|
||||
msg, err := c.requestNats(constant.NatsCommunicationSubjectRequestHTTP, natsPayload)
|
||||
msg, err := c.requestNats(subject.Communication.RequestHTTP, natsPayload)
|
||||
if err != nil {
|
||||
logger.Error("globalcare.Client.GetOrder", logger.LogData{
|
||||
"err": err.Error(),
|
||||
|
@ -114,8 +153,25 @@ func (c *Client) GetOrder(orderCode string) (*CommonResponse, error) {
|
|||
if err = pjson.Unmarshal(msg.Data, &r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = r.ParseResponseData(&res)
|
||||
return &res, err
|
||||
if err = r.ParseResponseData(&res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if r.Response == nil {
|
||||
return nil, fmt.Errorf("globalcare.Client.GetOrder get_order_empty_response")
|
||||
}
|
||||
|
||||
if r.Response.StatusCode >= http.StatusBadRequest {
|
||||
info, err := res.DecodeError()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.New(info.Message)
|
||||
}
|
||||
info, err := res.DecodeGetOrderSuccess()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &info, err
|
||||
}
|
||||
|
||||
func (c *Client) requestNats(subject string, data interface{}) (*nats.Msg, error) {
|
||||
|
@ -126,3 +182,18 @@ func (c *Client) requestNats(subject string, data interface{}) (*nats.Msg, error
|
|||
func (c *Client) getBaseURL() string {
|
||||
return baseURLENVMapping[c.env]
|
||||
}
|
||||
|
||||
func (c *Client) signData(s string) (string, error) {
|
||||
msgHash := sha256.New()
|
||||
_, err := msgHash.Write([]byte(s))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
msgHashSum := msgHash.Sum(nil)
|
||||
signature, err := rsa.SignPKCS1v15(rand.Reader, c.privateKey, crypto.SHA256, msgHashSum)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return base64.Encode(signature), nil
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package globalcare
|
||||
|
||||
import "time"
|
||||
|
||||
// CommonRequestBody ...
|
||||
type CommonRequestBody struct {
|
||||
Signature string `json:"signature"`
|
||||
|
@ -41,3 +43,13 @@ type InsuredInfo struct {
|
|||
YearsOfInsurance string `json:"yearsOfInsurance"`
|
||||
BeginDate string `json:"beginDate"`
|
||||
}
|
||||
|
||||
// Webhook ...
|
||||
type Webhook struct {
|
||||
Status int `json:"status"`
|
||||
OrderCode string `json:"orderCode"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
Note string `json:"note"`
|
||||
CertLink string `json:"certLink"`
|
||||
PartnerOrderCode string `json:"partnerOrderCode"`
|
||||
}
|
||||
|
|
|
@ -1,8 +1,92 @@
|
|||
package globalcare
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/Selly-Modules/3pl/util/base64"
|
||||
)
|
||||
|
||||
// CommonResponse ...
|
||||
type CommonResponse struct {
|
||||
Data string `json:"data"`
|
||||
Signature string `json:"signature"`
|
||||
}
|
||||
|
||||
// DecodeCreateOrderSuccess ...
|
||||
func (r *CommonResponse) DecodeCreateOrderSuccess() (res CreateOrderResponseDecoded, err error) {
|
||||
err = r.Decode(&res)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// DecodeGetOrderSuccess ...
|
||||
func (r *CommonResponse) DecodeGetOrderSuccess() (res GetOrderResponseDecoded, err error) {
|
||||
err = r.Decode(&res)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// DecodeError ...
|
||||
func (r *CommonResponse) DecodeError() (res ResponseError, err error) {
|
||||
err = r.Decode(&res)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// Decode ...
|
||||
func (r *CommonResponse) Decode(resultPointer interface{}) error {
|
||||
b := base64.Decode(r.Data)
|
||||
return json.Unmarshal(b, resultPointer)
|
||||
}
|
||||
|
||||
// CreateOrderResponseDecoded ...
|
||||
type CreateOrderResponseDecoded struct {
|
||||
StatusCode int `json:"statusCode"`
|
||||
Result CreateOrderResult `json:"result"`
|
||||
}
|
||||
|
||||
// CreateOrderResult ...
|
||||
type CreateOrderResult struct {
|
||||
OrderCode string `json:"orderCode"`
|
||||
PaymentLink string `json:"paymentLink"`
|
||||
Fees int `json:"fees"`
|
||||
StatusId int `json:"statusId"`
|
||||
}
|
||||
|
||||
// ResponseError ...
|
||||
type ResponseError struct {
|
||||
StatusCode int `json:"statusCode"`
|
||||
Message string `json:"message"`
|
||||
Result interface{} `json:"result"`
|
||||
}
|
||||
|
||||
// GetOrderResponseDecoded ...
|
||||
type GetOrderResponseDecoded struct {
|
||||
StatusCode int `json:"statusCode"`
|
||||
Result GetOrderResult `json:"result"`
|
||||
}
|
||||
|
||||
// GetOrderResult ...
|
||||
type GetOrderResult struct {
|
||||
ProviderTitle string `json:"providerTitle"`
|
||||
BeginDate string `json:"beginDate"`
|
||||
EndDate string `json:"endDate"`
|
||||
Amount string `json:"amount"`
|
||||
CertLink string `json:"certLink"`
|
||||
StatusId int `json:"statusId"`
|
||||
StatusTitle string `json:"statusTitle"`
|
||||
Buyer BuyerInfo `json:"buyer"`
|
||||
InsuredInfo InsuranceInfo `json:"insuredInfo"`
|
||||
}
|
||||
|
||||
// InsuranceInfo ...
|
||||
type InsuranceInfo struct {
|
||||
TypeId int `json:"typeId"`
|
||||
TypeName string `json:"typeName"`
|
||||
CarOccupantAccidentInsurance int `json:"carOccupantAccidentInsurance"`
|
||||
}
|
||||
|
||||
// BuyerInfo ...
|
||||
type BuyerInfo struct {
|
||||
BuyerName string `json:"buyerName"`
|
||||
BuyerPrivateId interface{} `json:"buyerPrivateId"`
|
||||
BuyerPhone string `json:"buyerPhone"`
|
||||
BuyerAddress string `json:"buyerAddress"`
|
||||
BuyerEmail string `json:"buyerEmail"`
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
package globalcare
|
|
@ -37,6 +37,10 @@ const (
|
|||
baseURLProd = "https://ext-api.tnclog.vn"
|
||||
)
|
||||
|
||||
const (
|
||||
ErrCodeExistPartnerCode = "exist_partner_code"
|
||||
)
|
||||
|
||||
var (
|
||||
baseURLENVMapping = map[ENV]string{
|
||||
EnvProd: baseURLProd,
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package tnc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Error ...
|
||||
type Error struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"errorMessage"`
|
||||
}
|
||||
|
||||
// Error ...
|
||||
func (e Error) Error() string {
|
||||
return fmt.Sprintf("tnc_err: code %s, messsage %s", e.Code, e.Message)
|
||||
}
|
||||
|
||||
// IsErrExistPartnerCode ...
|
||||
func IsErrExistPartnerCode(err error) bool {
|
||||
e, ok := err.(Error)
|
||||
return ok && e.Code == ErrCodeExistPartnerCode
|
||||
}
|
|
@ -5,13 +5,7 @@ type OutboundRequestRes struct {
|
|||
OrID int `json:"orId"`
|
||||
OrCode string `json:"orCode"`
|
||||
PartnerORCode string `json:"partnerORCode"`
|
||||
Error *ErrRes `json:"error"`
|
||||
}
|
||||
|
||||
// ErrRes ...
|
||||
type ErrRes struct {
|
||||
Code string `json:"code"`
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
Error *Error `json:"error"`
|
||||
}
|
||||
|
||||
type authRes struct {
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"github.com/Selly-Modules/logger"
|
||||
"github.com/Selly-Modules/natsio"
|
||||
"github.com/Selly-Modules/natsio/model"
|
||||
"github.com/Selly-Modules/natsio/subject"
|
||||
"github.com/nats-io/nats.go"
|
||||
|
||||
"github.com/Selly-Modules/3pl/constant"
|
||||
"github.com/Selly-Modules/3pl/util/pjson"
|
||||
)
|
||||
|
||||
|
@ -66,7 +66,7 @@ func (c *Client) CreateOutboundRequest(p OutboundRequestPayload) (*OutboundReque
|
|||
}
|
||||
var (
|
||||
r model.CommunicationHttpResponse
|
||||
errRes ErrRes
|
||||
errRes Error
|
||||
dataRes []OutboundRequestRes
|
||||
)
|
||||
if err = pjson.Unmarshal(msg.Data, &r); err != nil {
|
||||
|
@ -80,7 +80,7 @@ func (c *Client) CreateOutboundRequest(p OutboundRequestPayload) (*OutboundReque
|
|||
if err = r.ParseResponseData(&errRes); err != nil {
|
||||
return nil, fmt.Errorf("tnc.Client.CreateOutboundRequest: parse_response_err: %v", err)
|
||||
}
|
||||
return nil, fmt.Errorf("tnc.Client.CreateOutboundRequest: failed code %s, message %s", errRes.Code, errRes.ErrorMessage)
|
||||
return nil, errRes
|
||||
}
|
||||
if err = r.ParseResponseData(&dataRes); err != nil {
|
||||
return nil, fmt.Errorf("tnc.Client.CreateOutboundRequest: parse_response_data: %v", err)
|
||||
|
@ -91,7 +91,7 @@ func (c *Client) CreateOutboundRequest(p OutboundRequestPayload) (*OutboundReque
|
|||
item := &dataRes[0]
|
||||
e := item.Error
|
||||
if e != nil {
|
||||
return nil, fmt.Errorf("tnc.Client.CreateOutboundRequest: failed, code %s - message %s", e.Code, e.ErrorMessage)
|
||||
return nil, errRes
|
||||
}
|
||||
|
||||
return item, err
|
||||
|
@ -119,7 +119,7 @@ func (c *Client) UpdateOutboundRequestLogisticInfo(p UpdateORLogisticInfoPayload
|
|||
}
|
||||
var (
|
||||
r model.CommunicationHttpResponse
|
||||
errRes ErrRes
|
||||
errRes Error
|
||||
)
|
||||
if err = pjson.Unmarshal(msg.Data, &r); err != nil {
|
||||
return fmt.Errorf("tnc.Client.UpdateOutboundRequestLogisticInfo: parse_data %v", err)
|
||||
|
@ -132,7 +132,7 @@ func (c *Client) UpdateOutboundRequestLogisticInfo(p UpdateORLogisticInfoPayload
|
|||
if err = r.ParseResponseData(&errRes); err != nil {
|
||||
return fmt.Errorf("tnc.Client.UpdateOutboundRequestLogisticInfo: parse_response_err: %v", err)
|
||||
}
|
||||
return fmt.Errorf("tnc.Client.UpdateOutboundRequestLogisticInfo: failed code %s, message %s", errRes.Code, errRes.ErrorMessage)
|
||||
return errRes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ func (c *Client) GetOutboundRequestByID(requestID int) (*OutboundRequestInfo, er
|
|||
}
|
||||
var (
|
||||
r model.CommunicationHttpResponse
|
||||
errRes ErrRes
|
||||
errRes Error
|
||||
outboundRequest OutboundRequestInfo
|
||||
)
|
||||
if err = pjson.Unmarshal(msg.Data, &r); err != nil {
|
||||
|
@ -172,7 +172,7 @@ func (c *Client) GetOutboundRequestByID(requestID int) (*OutboundRequestInfo, er
|
|||
if err = r.ParseResponseData(&errRes); err != nil {
|
||||
return nil, fmt.Errorf("tnc.Client.GetOutboundRequestByID: parse_response_err: %v", err)
|
||||
}
|
||||
return nil, fmt.Errorf("tnc.Client.GetOutboundRequestByID: failed code %s, message %s", errRes.Code, errRes.ErrorMessage)
|
||||
return nil, errRes
|
||||
}
|
||||
if err = r.ParseResponseData(&outboundRequest); err != nil {
|
||||
return nil, fmt.Errorf("tnc.Client.GetOutboundRequestByID: parse_response_data: %v", err)
|
||||
|
@ -203,7 +203,7 @@ func (c *Client) CancelOutboundRequest(requestID int, note string) error {
|
|||
}
|
||||
var (
|
||||
r model.CommunicationHttpResponse
|
||||
errRes ErrRes
|
||||
errRes Error
|
||||
)
|
||||
if err = pjson.Unmarshal(msg.Data, &r); err != nil {
|
||||
return fmt.Errorf("tnc.Client.CancelOutboundRequest: parse_data %v", err)
|
||||
|
@ -216,7 +216,7 @@ func (c *Client) CancelOutboundRequest(requestID int, note string) error {
|
|||
if err = r.ParseResponseData(&errRes); err != nil {
|
||||
return fmt.Errorf("tnc.Client.CancelOutboundRequest: parse_response_err: %v", err)
|
||||
}
|
||||
return fmt.Errorf("tnc.Client.CancelOutboundRequest: failed code %s, message %s", errRes.Code, errRes.ErrorMessage)
|
||||
return errRes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ func (c *Client) auth() (*authRes, error) {
|
|||
}
|
||||
var (
|
||||
r model.CommunicationHttpResponse
|
||||
errRes ErrRes
|
||||
errRes Error
|
||||
data authRes
|
||||
)
|
||||
if err = pjson.Unmarshal(msg.Data, &r); err != nil {
|
||||
|
@ -266,7 +266,7 @@ func (c *Client) auth() (*authRes, error) {
|
|||
if err = r.ParseResponseData(&errRes); err != nil {
|
||||
return nil, fmt.Errorf("tnc.Client.auth: parse_response_err: %v", err)
|
||||
}
|
||||
return nil, fmt.Errorf("tnc.Client.auth: failed code %s, message %s", errRes.Code, errRes.ErrorMessage)
|
||||
return nil, errRes
|
||||
}
|
||||
if err = r.ParseResponseData(&data); err != nil {
|
||||
return nil, fmt.Errorf("tnc.Client.auth: parse_response_data: %v", err)
|
||||
|
@ -288,9 +288,8 @@ func (c *Client) getRequestHeader() map[string]string {
|
|||
}
|
||||
|
||||
func (c *Client) requestHttpViaNats(data model.CommunicationRequestHttp) (*nats.Msg, error) {
|
||||
s := constant.NatsCommunicationSubjectRequestHTTP
|
||||
b := pjson.ToBytes(data)
|
||||
return c.natsClient.Request(s, b)
|
||||
return c.natsClient.Request(subject.Communication.RequestHTTP, b)
|
||||
}
|
||||
|
||||
func (c *Client) getBaseURL() string {
|
||||
|
|
Loading…
Reference in New Issue