This commit is contained in:
Andrey Parhomenko 2024-05-19 23:00:41 +05:00
parent d17141ac1a
commit ffb7d8467f
9 changed files with 58 additions and 101 deletions

View file

@ -4,12 +4,12 @@ import (
"fmt" "fmt"
"time" "time"
"errors" "errors"
"vultras.su/core/amo/api" "surdeus.su/core/amo/api"
"vultras.su/core/amo/companies" "surdeus.su/core/amo/companies"
"vultras.su/core/amo/contacts" "surdeus.su/core/amo/contacts"
"vultras.su/core/amo/leads" "surdeus.su/core/amo/leads"
"vultras.su/core/amo/users" "surdeus.su/core/amo/users"
"vultras.su/core/amo/events" "surdeus.su/core/amo/events"
) )
type IAmoClient interface { type IAmoClient interface {
@ -104,7 +104,7 @@ func (client *Client) GetEvents(req events.EventsRequest) ([]events.Event, error
if resp.Links.Next.Href == "" { if resp.Links.Next.Href == "" {
break break
} }
time.Sleep(time.Millisecond*300) time.Sleep(time.Millisecond * 300)
abs = true abs = true
res = resp.Links.Next.Href res = resp.Links.Next.Href
} }

3
btest.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
#
go build -o ./exe/ ./cmd/test

View file

@ -1,61 +1,19 @@
package main package main
import ( import (
"vultras.su/core/amo" "surdeus.su/core/amo"
"vultras.su/core/amo/api" "surdeus.su/core/amo/api"
"vultras.su/core/amo/webhooks" //"surdeus.su/core/amo/webhooks"
"vultras.su/core/amo/events" "surdeus.su/core/amo/events"
"vultras.su/core/bond" //"surdeus.su/core/ss"
"vultras.su/core/bond/statuses" //"surdeus.su/core/ss/statuses"
//"os" //"os"
"fmt" "fmt"
"io" //"io"
"encoding/json" //"encoding/json"
"time" "time"
) )
type Context = bond.Context
var (
gclient *amo.Client
)
var root = bond.Root(bond.Path().
Def(
"hook",
bond.Func(func(c *Context){
v := webhooks.Request{}
c.Scan(&v)
if c.ScanErr() != nil {
fmt.Println("scan-err:", c.ScanErr())
}
bts, err := json.MarshalIndent(v, "", "\t")
if err != nil {
fmt.Println("marsh-error:", err)
}
fmt.Println("request:", string(bts))
c.SetStatus(statuses.OK)
}),
).Def(
"auth",
bond.Func(func(c *Context){
fmt.Println("header:", c.R.Header)
fmt.Println("content-type:", c.ContentType())
bts, _ := io.ReadAll(c.R.Body)
fmt.Println("request:", string(bts))
c.SetStatus(statuses.OK)
return
v := map[string]any{}
c.Scan(&v)
if c.ScanErr() != nil {
fmt.Println("scan-err:", c.ScanErr())
}
fmt.Println("request:", v)
c.SetStatus(statuses.OK)
}),
))
func main() { func main() {
//fmt.Println(opts) //fmt.Println(opts)
client, err := amo.NewAmoClient("secret.json") client, err := amo.NewAmoClient("secret.json")
@ -63,9 +21,8 @@ func main() {
panic(err) panic(err)
} }
client.Api.Debug = true client.Api.Debug = true
gclient = client
company, err := client.GetCompany("80828925", "") company, err := client.GetCompany(80828925, "")
if err != nil && err != api.NoContentErr { if err != nil && err != api.NoContentErr {
panic(err) panic(err)
} }

View file

@ -1,6 +1,6 @@
package companies package companies
import "vultras.su/core/amo/common" import "surdeus.su/core/amo/common"
type Company struct { type Company struct {
Id int `json:"id"` Id int `json:"id"`

View file

@ -1,6 +1,6 @@
package contacts package contacts
import "vultras.su/core/amo/common" import "surdeus.su/core/amo/common"
type Contact struct { type Contact struct {
Id int `json:"id"` Id int `json:"id"`

10
go.mod
View file

@ -1,14 +1,14 @@
module vultras.su/core/amo module surdeus.su/core/amo
go 1.21.3 go 1.21.3
require ( require (
github.com/stretchr/testify v1.6.1 github.com/stretchr/testify v1.9.0
vultras.su/core/bond v0.0.0-20240118183558-6fa4ef4cf402 surdeus.su/core/ss v0.1.1
) )
require ( require (
github.com/davecgh/go-spew v1.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

19
go.sum
View file

@ -1,15 +1,12 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
vultras.su/core/bond v0.0.0-20240114204709-a9c2c8810682 h1:NiT5kAwzjTO+C4/y2EyRI6N8DOl5YFLuyZEUqrYwfFE= surdeus.su/core/ss v0.1.1 h1:CXYBVRk4fv+Z7Cu51Nw5wDs5CoaEf2VpjB7XmFqu3DQ=
vultras.su/core/bond v0.0.0-20240114204709-a9c2c8810682/go.mod h1:d8O5wwQlZrVAeoV7qIwxXabB9RuqgopP7wEyRl3++Tc= surdeus.su/core/ss v0.1.1/go.mod h1:4gPfk0OjdJ1maKHyYiZwai7jIIwpVE5vgiBF2nubdrU=
vultras.su/core/bond v0.0.0-20240118183558-6fa4ef4cf402 h1:XUEdQesLiMX8mK2ZQpJyfE0p+MfmgnOdM1Mt72F+FW4=
vultras.su/core/bond v0.0.0-20240118183558-6fa4ef4cf402/go.mod h1:d8O5wwQlZrVAeoV7qIwxXabB9RuqgopP7wEyRl3++Tc=

View file

@ -1,6 +1,6 @@
package leads package leads
import "vultras.su/core/amo/common" import "surdeus.su/core/amo/common"
type Lead struct { type Lead struct {
Id int `json:"id"` Id int `json:"id"`

View file

@ -1,8 +1,8 @@
package webhooks package webhooks
import ( import (
//"vultras.su/core/bond/urlenc" //"surdeus.su/core/ss/urlenc"
"vultras.su/core/bond/jsons" "surdeus.su/core/ss/jsons"
/*"log" /*"log"
"net/url" "net/url"
"strings"*/ "strings"*/