From ffb7d8467fbee3b93c3fe84062d02de0ae52d4c6 Mon Sep 17 00:00:00 2001 From: surdeus Date: Sun, 19 May 2024 23:00:41 +0500 Subject: [PATCH] rename --- amocrm.go | 14 +++++----- btest.sh | 3 +++ cmd/test/main.go | 61 +++++++----------------------------------- companies/companies.go | 2 +- contacts/contacts.go | 2 +- go.mod | 10 +++---- go.sum | 19 ++++++------- leads/leads.go | 44 +++++++++++++++--------------- webhooks/webhook.go | 4 +-- 9 files changed, 58 insertions(+), 101 deletions(-) create mode 100755 btest.sh diff --git a/amocrm.go b/amocrm.go index 3ee3abc..fd1a0e8 100644 --- a/amocrm.go +++ b/amocrm.go @@ -4,12 +4,12 @@ import ( "fmt" "time" "errors" - "vultras.su/core/amo/api" - "vultras.su/core/amo/companies" - "vultras.su/core/amo/contacts" - "vultras.su/core/amo/leads" - "vultras.su/core/amo/users" - "vultras.su/core/amo/events" + "surdeus.su/core/amo/api" + "surdeus.su/core/amo/companies" + "surdeus.su/core/amo/contacts" + "surdeus.su/core/amo/leads" + "surdeus.su/core/amo/users" + "surdeus.su/core/amo/events" ) type IAmoClient interface { @@ -104,7 +104,7 @@ func (client *Client) GetEvents(req events.EventsRequest) ([]events.Event, error if resp.Links.Next.Href == "" { break } - time.Sleep(time.Millisecond*300) + time.Sleep(time.Millisecond * 300) abs = true res = resp.Links.Next.Href } diff --git a/btest.sh b/btest.sh new file mode 100755 index 0000000..b5a4164 --- /dev/null +++ b/btest.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# +go build -o ./exe/ ./cmd/test diff --git a/cmd/test/main.go b/cmd/test/main.go index 46a302d..234bfd7 100644 --- a/cmd/test/main.go +++ b/cmd/test/main.go @@ -1,61 +1,19 @@ package main import ( - "vultras.su/core/amo" - "vultras.su/core/amo/api" - "vultras.su/core/amo/webhooks" - "vultras.su/core/amo/events" - "vultras.su/core/bond" - "vultras.su/core/bond/statuses" + "surdeus.su/core/amo" + "surdeus.su/core/amo/api" + //"surdeus.su/core/amo/webhooks" + "surdeus.su/core/amo/events" + //"surdeus.su/core/ss" + //"surdeus.su/core/ss/statuses" //"os" "fmt" - "io" - "encoding/json" + //"io" + //"encoding/json" "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() { //fmt.Println(opts) client, err := amo.NewAmoClient("secret.json") @@ -63,9 +21,8 @@ func main() { panic(err) } client.Api.Debug = true - gclient = client - company, err := client.GetCompany("80828925", "") + company, err := client.GetCompany(80828925, "") if err != nil && err != api.NoContentErr { panic(err) } diff --git a/companies/companies.go b/companies/companies.go index 1d75658..fcdbf7e 100644 --- a/companies/companies.go +++ b/companies/companies.go @@ -1,6 +1,6 @@ package companies -import "vultras.su/core/amo/common" +import "surdeus.su/core/amo/common" type Company struct { Id int `json:"id"` diff --git a/contacts/contacts.go b/contacts/contacts.go index 814e97f..bdea6eb 100644 --- a/contacts/contacts.go +++ b/contacts/contacts.go @@ -1,6 +1,6 @@ package contacts -import "vultras.su/core/amo/common" +import "surdeus.su/core/amo/common" type Contact struct { Id int `json:"id"` diff --git a/go.mod b/go.mod index 84f551c..af90f77 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ -module vultras.su/core/amo +module surdeus.su/core/amo go 1.21.3 require ( - github.com/stretchr/testify v1.6.1 - vultras.su/core/bond v0.0.0-20240118183558-6fa4ef4cf402 + github.com/stretchr/testify v1.9.0 + surdeus.su/core/ss v0.1.1 ) 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 - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index cc7d419..62a5240 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,12 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 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.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 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/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -vultras.su/core/bond v0.0.0-20240114204709-a9c2c8810682 h1:NiT5kAwzjTO+C4/y2EyRI6N8DOl5YFLuyZEUqrYwfFE= -vultras.su/core/bond v0.0.0-20240114204709-a9c2c8810682/go.mod h1:d8O5wwQlZrVAeoV7qIwxXabB9RuqgopP7wEyRl3++Tc= -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= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +surdeus.su/core/ss v0.1.1 h1:CXYBVRk4fv+Z7Cu51Nw5wDs5CoaEf2VpjB7XmFqu3DQ= +surdeus.su/core/ss v0.1.1/go.mod h1:4gPfk0OjdJ1maKHyYiZwai7jIIwpVE5vgiBF2nubdrU= diff --git a/leads/leads.go b/leads/leads.go index 907fbb4..d51c8b7 100644 --- a/leads/leads.go +++ b/leads/leads.go @@ -1,30 +1,30 @@ package leads -import "vultras.su/core/amo/common" +import "surdeus.su/core/amo/common" type Lead struct { - Id int `json:"id"` - Name string `json:"name,omitempty"` - Price int `json:"price,omitempty"` - ResponsibleUserId int `json:"responsible_user_id,omitempty"` - GroupId int `json:"group_id,omitempty"` - StatusId int `json:"status_id,omitempty"` - PipelineId int `json:"pipeline_id,omitempty"` - LossReasonId int `json:"loss_reason_id,omitempty"` - SourceId interface{} `json:"source_id,omitempty"` - CreatedBy int `json:"created_by,omitempty"` - UpdatedBy int `json:"updated_by,omitempty"` - CreatedAt int `json:"created_at,omitempty"` - UpdatedAt int `json:"updated_at,omitempty"` - ClosedAt int `json:"closed_at,omitempty"` - ClosestTaskAt interface{} `json:"closest_task_at,omitempty"` - IsDeleted bool `json:"is_deleted,omitempty"` + Id int `json:"id"` + Name string `json:"name,omitempty"` + Price int `json:"price,omitempty"` + ResponsibleUserId int `json:"responsible_user_id,omitempty"` + GroupId int `json:"group_id,omitempty"` + StatusId int `json:"status_id,omitempty"` + PipelineId int `json:"pipeline_id,omitempty"` + LossReasonId int `json:"loss_reason_id,omitempty"` + SourceId interface{} `json:"source_id,omitempty"` + CreatedBy int `json:"created_by,omitempty"` + UpdatedBy int `json:"updated_by,omitempty"` + CreatedAt int `json:"created_at,omitempty"` + UpdatedAt int `json:"updated_at,omitempty"` + ClosedAt int `json:"closed_at,omitempty"` + ClosestTaskAt interface{} `json:"closest_task_at,omitempty"` + IsDeleted bool `json:"is_deleted,omitempty"` CustomFieldsValues []common.CustomFieldsValue `json:"custom_fields_values,omitempty"` - Score interface{} `json:"score,omitempty"` - AccountId int `json:"account_id,omitempty"` - IsPriceModifiedByRobot bool `json:"is_price_modified_by_robot,omitempty"` - Links Links `json:"_links,omitempty"` - Embedded Embedded `json:"_embedded,omitempty"` + Score interface{} `json:"score,omitempty"` + AccountId int `json:"account_id,omitempty"` + IsPriceModifiedByRobot bool `json:"is_price_modified_by_robot,omitempty"` + Links Links `json:"_links,omitempty"` + Embedded Embedded `json:"_embedded,omitempty"` } type Self struct { diff --git a/webhooks/webhook.go b/webhooks/webhook.go index 34f24e9..cfefcfe 100644 --- a/webhooks/webhook.go +++ b/webhooks/webhook.go @@ -1,8 +1,8 @@ package webhooks import ( - //"vultras.su/core/bond/urlenc" - "vultras.su/core/bond/jsons" + //"surdeus.su/core/ss/urlenc" + "surdeus.su/core/ss/jsons" /*"log" "net/url" "strings"*/