mirror of
https://github.com/Neur0toxine/waba-coreapp-mock.git
synced 2024-11-21 20:46:10 +03:00
simple mock
This commit is contained in:
parent
09a012bf04
commit
6825c32bcf
6
.gitignore
vendored
6
.gitignore
vendored
@ -12,4 +12,8 @@
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
vendor/
|
||||
|
||||
# Other files
|
||||
.idea/
|
||||
waba-coreapp-mock
|
||||
|
2
README.md
Normal file
2
README.md
Normal file
@ -0,0 +1,2 @@
|
||||
Very inaccurate and not really useful WhatsApp Coreapp mock. Maybe I will make something better in the future.
|
||||
Cannot promise though.
|
33
go.mod
Normal file
33
go.mod
Normal file
@ -0,0 +1,33 @@
|
||||
module github.com/Neur0toxine/waba-coreapp-mock
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.7.7
|
||||
github.com/go-playground/validator/v10 v10.10.1
|
||||
github.com/labstack/gommon v0.3.1
|
||||
github.com/mkideal/cli v0.2.7
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/mkideal/expr v0.1.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/ugorji/go/codec v1.2.7 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.1 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
|
||||
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
google.golang.org/protobuf v1.28.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
140
go.sum
Normal file
140
go.sum
Normal file
@ -0,0 +1,140 @@
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs=
|
||||
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
|
||||
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
|
||||
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
|
||||
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/go-playground/validator/v10 v10.10.1 h1:uA0+amWMiglNZKZ9FJRKUAe9U3RX91eVn1JYXMWt7ig=
|
||||
github.com/go-playground/validator/v10 v10.10.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
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/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/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
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.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
|
||||
github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o=
|
||||
github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mkideal/cli v0.2.7 h1:mB/XrMzuddmTJ8f7KY1c+KzfYoM149tYGAnzmqRdvOU=
|
||||
github.com/mkideal/cli v0.2.7/go.mod h1:efaTeFI4jdPqzAe0bv3myLB2NW5yzMBLvWB70a6feco=
|
||||
github.com/mkideal/expr v0.1.0 h1:fzborV9TeSUmLm0aEQWTWcexDURFFo4v5gHSc818Kl8=
|
||||
github.com/mkideal/expr v0.1.0/go.mod h1:vL1DsSb87ZtU6IEjOtUfxw98z0FQbzS8xlGtnPkKdzg=
|
||||
github.com/mkideal/pkg v0.1.3/go.mod h1:u/enAxPeRcYSsxtu1NUifWSeOTU/31VsCaOPg54SMJ4=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
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/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
|
||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
||||
github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=
|
||||
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/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-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/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/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 h1:EH1Deb8WZJ0xc0WK//leUHXcX9aLE5SymusoTmMZye8=
|
||||
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
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=
|
27
main.go
Normal file
27
main.go
Normal file
@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/mkideal/cli"
|
||||
)
|
||||
|
||||
type CLI struct {
|
||||
cli.Helper2
|
||||
Address string `cli:"*addr,address" usage:"Address to listen"`
|
||||
Verbose bool `cli:"v,verbose" usage:"Enable verbose logging"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
os.Exit(cli.Run(new(CLI), func(ctx *cli.Context) error {
|
||||
argv := ctx.Argv().(*CLI)
|
||||
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
if argv.Verbose {
|
||||
gin.SetMode(gin.DebugMode)
|
||||
}
|
||||
|
||||
return NewServer().Run(argv.Address)
|
||||
}))
|
||||
}
|
293
models.go
Normal file
293
models.go
Normal file
@ -0,0 +1,293 @@
|
||||
package main
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type (
|
||||
BlockingType string
|
||||
ContactStatus string
|
||||
MessageType string
|
||||
RecipientType string
|
||||
ContactAddressType string
|
||||
ContactEmailType string
|
||||
ContactPhoneType string
|
||||
ContactURLType string
|
||||
TemplateLanguagePolicy string
|
||||
TemplateComponentType string
|
||||
TemplateComponentSubtype string
|
||||
TemplateParameterType string
|
||||
TemplateButtonPosition *int
|
||||
InteractiveMessageType string
|
||||
InteractiveHeaderType string
|
||||
InteractiveButtonType string
|
||||
)
|
||||
|
||||
const (
|
||||
BlockingWait BlockingType = "wait"
|
||||
BlockingNoWait BlockingType = "no_wait"
|
||||
)
|
||||
|
||||
const (
|
||||
ContactStatusValid ContactStatus = "valid"
|
||||
ContactStatusProcessing ContactStatus = "processing"
|
||||
ContactStatusInvalid ContactStatus = "invalid"
|
||||
ContactStatusFailed ContactStatus = "failed"
|
||||
)
|
||||
|
||||
const (
|
||||
ContactAddressHome ContactAddressType = "HOME"
|
||||
ContactAddressWork ContactAddressType = "WORK"
|
||||
)
|
||||
|
||||
const (
|
||||
ContactEmailHome ContactEmailType = "HOME"
|
||||
ContactEmailWork ContactEmailType = "WORK"
|
||||
)
|
||||
|
||||
const (
|
||||
ContactPhoneCell ContactPhoneType = "CELL"
|
||||
ContactPhoneMain ContactPhoneType = "MAIN"
|
||||
ContactPhoneIphone ContactPhoneType = "IPHONE"
|
||||
ContactPhoneHome ContactPhoneType = "HOME"
|
||||
ContactPhoneWork ContactPhoneType = "WORK"
|
||||
)
|
||||
|
||||
const (
|
||||
ContactURLHome ContactURLType = "HOME"
|
||||
ContactURLWork ContactURLType = "WORK"
|
||||
)
|
||||
|
||||
type BaseResponse struct {
|
||||
Meta *Metadata `json:"meta,omitempty"`
|
||||
Errors []Error `json:"errors,omitempty"`
|
||||
}
|
||||
|
||||
type Error struct {
|
||||
Code int `json:"code,omitempty"`
|
||||
Details string `json:"details,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
}
|
||||
|
||||
type Metadata struct {
|
||||
Success bool `json:"success,omitempty"`
|
||||
APIStatus string `json:"api_status,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
HTTPCode int `json:"http_code,omitempty"`
|
||||
DeveloperMessage string `json:"developer_message,omitempty"`
|
||||
}
|
||||
|
||||
type ContactsRequest struct {
|
||||
Blocking BlockingType `json:"blocking,omitempty" validate:"required,oneof=wait no_wait"`
|
||||
Contacts []string `json:"contacts,omitempty" validate:"required,min=1"`
|
||||
ForceCheck bool `json:"force_check,omitempty"`
|
||||
}
|
||||
|
||||
type ContactsResponse struct {
|
||||
BaseResponse
|
||||
Contacts []Contact `json:"contacts"`
|
||||
}
|
||||
|
||||
type Contact struct {
|
||||
WaID string `json:"wa_id"`
|
||||
Input string `json:"input"`
|
||||
Status ContactStatus `json:"status"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
RecipientType RecipientType `json:"recipient_type,omitempty" validate:"required,eq=individual"`
|
||||
To string `json:"to" validate:"required,min=1"`
|
||||
Type MessageType `json:"type,omitempty" validate:"required,oneof=audio contact document image location sticker template text voice video interactive button"`
|
||||
Preview bool `json:"preview,omitempty"`
|
||||
Text *MessageText `json:"text,omitempty"`
|
||||
Audio *MessageMedia `json:"audio,omitempty"`
|
||||
Document *MessageMedia `json:"document,omitempty"`
|
||||
Image *MessageMedia `json:"image,omitempty"`
|
||||
Sticker *MessageMedia `json:"sticker,omitempty"`
|
||||
Video *MessageMedia `json:"video,omitempty"`
|
||||
Contacts []MessageContact `json:"contacts,omitempty"`
|
||||
Location *MessageLocation `json:"location,omitempty"`
|
||||
Template *MessageTemplate `json:"template,omitempty"`
|
||||
Interactive *MessageInteractive `json:"interactive,omitempty"`
|
||||
}
|
||||
|
||||
type MessagesResponse struct {
|
||||
BaseResponse
|
||||
Messages []IDModel `json:"messages,omitempty"`
|
||||
}
|
||||
|
||||
type IDModel struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type MessageText struct {
|
||||
Body string `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
type MessageMedia struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Link string `json:"link,omitempty"`
|
||||
Caption string `json:"caption,omitempty"`
|
||||
Filename string `json:"filename,omitempty"`
|
||||
Provider *MediaProvider `json:"provider,omitempty"`
|
||||
MIMEType string `json:"mime_type,omitempty"`
|
||||
SHA256 string `json:"sha256,omitempty"`
|
||||
}
|
||||
|
||||
type MediaProvider struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Config *MediaProviderConfig `json:"config,omitempty"`
|
||||
}
|
||||
|
||||
type MediaProviderConfig struct {
|
||||
Bearer string `json:"bearer,omitempty"`
|
||||
Basic *MediaProviderConfigBasic `json:"basic,omitempty"`
|
||||
}
|
||||
|
||||
type MediaProviderConfigBasic struct {
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
}
|
||||
|
||||
type MessageContact struct {
|
||||
Addresses []ContactAddress `json:"addresses,omitempty"`
|
||||
Birthday string `json:"birthday,omitempty"`
|
||||
Emails []ContactEmail `json:"emails,omitempty"`
|
||||
Name *ContactName `json:"name,omitempty"`
|
||||
Org *ContactOrg `json:"org,omitempty"`
|
||||
Phones []ContactPhone `json:"phones,omitempty"`
|
||||
Urls []ContactURL `json:"urls,omitempty"`
|
||||
}
|
||||
|
||||
type ContactAddress struct {
|
||||
Street string `json:"street,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
Zip string `json:"zip,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
CountryCode string `json:"country_code,omitempty"`
|
||||
Type ContactAddressType `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
type ContactEmail struct {
|
||||
Email string `json:"email,omitempty"`
|
||||
Type ContactEmailType `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
type ContactName struct {
|
||||
FormattedName string `json:"formatted_name,omitempty"`
|
||||
FirstName string `json:"first_name,omitempty"`
|
||||
LastName string `json:"last_name,omitempty"`
|
||||
MiddleName string `json:"middle_name,omitempty"`
|
||||
Suffix string `json:"suffix,omitempty"`
|
||||
Prefix string `json:"prefix,omitempty"`
|
||||
}
|
||||
|
||||
type ContactOrg struct {
|
||||
Company string `json:"company,omitempty"`
|
||||
Department string `json:"department,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
}
|
||||
|
||||
type ContactPhone struct {
|
||||
Phone string `json:"phone,omitempty"`
|
||||
Type ContactPhoneType `json:"type,omitempty"`
|
||||
WaID string `json:"wa_id,omitempty"`
|
||||
}
|
||||
|
||||
type ContactURL struct {
|
||||
URL string `json:"url,omitempty"`
|
||||
Type ContactURLType `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
type MessageLocation struct {
|
||||
Longitude json.Number `json:"longitude,omitempty"`
|
||||
Latitude json.Number `json:"latitude,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Address string `json:"address,omitempty"`
|
||||
}
|
||||
|
||||
type MessageTemplate struct {
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Language TemplateLanguage `json:"language,omitempty"`
|
||||
Components []TemplateComponent `json:"components,omitempty"`
|
||||
}
|
||||
|
||||
type TemplateLanguage struct {
|
||||
Policy TemplateLanguagePolicy `json:"policy,omitempty"`
|
||||
Code string `json:"code,omitempty"`
|
||||
}
|
||||
|
||||
type TemplateComponent struct {
|
||||
Type TemplateComponentType `json:"type,omitempty"`
|
||||
Subtype TemplateComponentSubtype `json:"subtype,omitempty"`
|
||||
Parameters []TemplateParameter `json:"parameters,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
}
|
||||
|
||||
type TemplateParameter struct {
|
||||
Type TemplateParameterType `json:"type,omitempty"`
|
||||
SubType TemplateComponentSubtype `json:"sub_type,omitempty"`
|
||||
Index TemplateButtonPosition `json:"index,omitempty"`
|
||||
Caption string `json:"caption,omitempty"`
|
||||
Link string `json:"link,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
Payload string `json:"payload,omitempty"`
|
||||
}
|
||||
|
||||
type MessageInteractive struct {
|
||||
Type InteractiveMessageType `json:"type,omitempty"`
|
||||
Header *InteractiveHeader `json:"header,omitempty"`
|
||||
Body *Text `json:"body,omitempty"`
|
||||
Footer *Text `json:"footer,omitempty"`
|
||||
Action *InteractiveAction `json:"action,omitempty"`
|
||||
ListReply *InteractiveSectionRow `json:"list_reply,omitempty"`
|
||||
ButtonReply *InteractiveButtonReply `json:"button_reply,omitempty"`
|
||||
}
|
||||
|
||||
type Text struct {
|
||||
Text string `json:"text,omitempty"`
|
||||
}
|
||||
|
||||
type InteractiveHeader struct {
|
||||
Type InteractiveHeaderType `json:"type,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
Video *MessageMedia `json:"video,omitempty"`
|
||||
Image *MessageMedia `json:"image,omitempty"`
|
||||
Document *MessageMedia `json:"document,omitempty"`
|
||||
}
|
||||
|
||||
type InteractiveButton struct {
|
||||
Type InteractiveButtonType `json:"type,omitempty"`
|
||||
Reply *InteractiveButtonReply `json:"reply,omitempty"`
|
||||
}
|
||||
|
||||
type InteractiveButtonReply struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
}
|
||||
|
||||
type InteractiveSection struct {
|
||||
Title string `json:"title,omitempty"`
|
||||
Rows []InteractiveSectionRow `json:"rows,omitempty"`
|
||||
ProductItems []InteractiveSectionProduct `json:"product_items,omitempty"`
|
||||
}
|
||||
|
||||
type InteractiveSectionRow struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
type InteractiveSectionProduct struct {
|
||||
ProductRetailerID string `json:"product_retailer_id,omitempty"`
|
||||
}
|
||||
|
||||
type InteractiveAction struct {
|
||||
Button string `json:"button,omitempty"`
|
||||
Buttons []InteractiveButton `json:"buttons,omitempty"`
|
||||
CatalogID string `json:"catalog_id,omitempty"`
|
||||
Sections []InteractiveSection `json:"sections,omitempty"`
|
||||
ProductRetailerID string `json:"product_retailer_id,omitempty"`
|
||||
}
|
34
random_string.go
Normal file
34
random_string.go
Normal file
@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
const (
|
||||
letterIdxBits = 6 // 6 bits to represent a letter index
|
||||
letterIdxMask = 1<<letterIdxBits - 1 // All 1-bits, as many as letterIdxBits
|
||||
letterIdxMax = 63 / letterIdxBits // # of letter indices fitting in 63 bits
|
||||
)
|
||||
|
||||
var src = rand.NewSource(time.Now().UnixNano())
|
||||
|
||||
func RandomString(n int) string {
|
||||
b := make([]byte, n)
|
||||
// A src.Int63() generates 63 random bits, enough for letterIdxMax characters!
|
||||
for i, cache, remain := n-1, src.Int63(), letterIdxMax; i >= 0; {
|
||||
if remain == 0 {
|
||||
cache, remain = src.Int63(), letterIdxMax
|
||||
}
|
||||
if idx := int(cache & letterIdxMask); idx < len(letterBytes) {
|
||||
b[i] = letterBytes[idx]
|
||||
i--
|
||||
}
|
||||
cache >>= letterIdxBits
|
||||
remain--
|
||||
}
|
||||
|
||||
return *(*string)(unsafe.Pointer(&b))
|
||||
}
|
117
server.go
Normal file
117
server.go
Normal file
@ -0,0 +1,117 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"regexp"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/labstack/gommon/log"
|
||||
)
|
||||
|
||||
var (
|
||||
validate = validator.New()
|
||||
NotDigitsRegex = regexp.MustCompile("\\D+")
|
||||
)
|
||||
|
||||
type Mock struct {
|
||||
ContactsSuccess bool `json:"contacts_success"`
|
||||
MessagesSuccess bool `json:"messages_success"`
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
g *gin.Engine
|
||||
mock Mock
|
||||
}
|
||||
|
||||
func NewServer() (s *Server) {
|
||||
s = &Server{g: gin.New()}
|
||||
s.g.GET("/mock", s.mockData)
|
||||
s.g.POST("/mock", s.updateMockData)
|
||||
api := s.g.Group("/v1")
|
||||
{
|
||||
api.POST("/contacts", s.contactsHandler)
|
||||
api.POST("/messages", s.messagesHandler)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Server) Run(addr ...string) error {
|
||||
return s.g.Run(addr...)
|
||||
}
|
||||
|
||||
func (s *Server) baseResponseOk() BaseResponse {
|
||||
return BaseResponse{
|
||||
Meta: &Metadata{
|
||||
Success: true,
|
||||
APIStatus: "stable",
|
||||
Version: "v2.31.5",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) bindRequest(c *gin.Context, req interface{}) error {
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
log.Printf("error: %s\n", err)
|
||||
return err
|
||||
}
|
||||
if err := validate.Struct(req); err != nil {
|
||||
log.Printf("error: %s\n", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) mockData(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, s.mock)
|
||||
}
|
||||
|
||||
func (s *Server) updateMockData(c *gin.Context) {
|
||||
var mock Mock
|
||||
if err := s.bindRequest(c, &mock); err != nil {
|
||||
c.AbortWithStatus(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
s.mock = mock
|
||||
c.JSON(http.StatusOK, s.mock)
|
||||
}
|
||||
|
||||
func (s *Server) contactsHandler(c *gin.Context) {
|
||||
var req ContactsRequest
|
||||
if err := s.bindRequest(c, &req); err != nil || !s.mock.ContactsSuccess {
|
||||
c.AbortWithStatus(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
res := ContactsResponse{
|
||||
BaseResponse: s.baseResponseOk(),
|
||||
Contacts: make([]Contact, len(req.Contacts)),
|
||||
}
|
||||
|
||||
for i, contact := range req.Contacts {
|
||||
res.Contacts[i] = Contact{
|
||||
WaID: NotDigitsRegex.ReplaceAllString(contact, ""),
|
||||
Input: contact,
|
||||
Status: ContactStatusValid,
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
func (s *Server) messagesHandler(c *gin.Context) {
|
||||
var req Message
|
||||
if err := s.bindRequest(c, &req); err != nil || !s.mock.MessagesSuccess {
|
||||
c.AbortWithStatus(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Received new message: %#v\n", req)
|
||||
|
||||
c.JSON(http.StatusOK, MessagesResponse{
|
||||
BaseResponse: s.baseResponseOk(),
|
||||
Messages: []IDModel{{
|
||||
ID: RandomString(27),
|
||||
}},
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user