From ef0905e3acfaf57d590b97e9c55fe54390fbc9da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB?= Date: Tue, 7 Apr 2020 17:27:04 +0300 Subject: [PATCH] remove reduntant package --- go.sum | 2 -- v1/client.go | 31 +++++++++++++++---------------- v1/{types => }/template.go | 2 +- v1/types.go | 10 ++++------ v1/types_test.go | 3 ++- 5 files changed, 22 insertions(+), 26 deletions(-) rename v1/{types => }/template.go (99%) diff --git a/go.sum b/go.sum index 0ed215e..b13bde2 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,6 @@ github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= 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.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= diff --git a/v1/client.go b/v1/client.go index 23c5429..93bfb52 100644 --- a/v1/client.go +++ b/v1/client.go @@ -11,7 +11,6 @@ import ( "time" "github.com/google/go-querystring/query" - "github.com/retailcrm/mg-transport-api-client-go/v1/types" ) // New initialize client @@ -75,8 +74,8 @@ func (c *MgClient) TransportChannels(request Channels) ([]ChannelListItem, int, // } // // fmt.Printf("Status: %v, Templates found: %v", status, len(data)) -func (c *MgClient) TransportTemplates() ([]types.TemplateItem, int, error) { - var resp []types.TemplateItem +func (c *MgClient) TransportTemplates() ([]TemplateItem, int, error) { + var resp []TemplateItem data, status, err := c.GetRequest("/templates", []byte{}) if err != nil { @@ -102,18 +101,18 @@ func (c *MgClient) TransportTemplates() ([]types.TemplateItem, int, error) { // request := v1.ActivateTemplateRequest{ // Code: "code", // Name: "name", -// Type: types.TemplateTypeText, -// Template: []types.TemplateItem{ +// Type: v1.TemplateTypeText, +// Template: []v1.TemplateItem{ // { -// Type: types.TemplateItemTypeText, +// Type: v1.TemplateItemTypeText, // Text: "Hello, ", // }, // { -// Type: types.TemplateItemTypeVar, -// VarType: types.TemplateVarName, +// Type: v1.TemplateItemTypeVar, +// VarType: v1.TemplateVarName, // }, // { -// Type: types.TemplateItemTypeText, +// Type: v1.TemplateItemTypeText, // Text: "!", // }, // }, @@ -143,21 +142,21 @@ func (c *MgClient) ActivateTemplate(channelID uint64, request ActivateTemplateRe // Example: // var client = New("https://token.url", "cb8ccf05e38a47543ad8477d4999be73bff503ea6") // -// request := types.Template{ +// request := v1.Template{ // Code: "templateCode", // ChannelID: 1, // Name: "templateName", -// Template: []types.TemplateItem{ +// Template: []v1.TemplateItem{ // { -// Type: types.TemplateItemTypeText, +// Type: v1.TemplateItemTypeText, // Text: "Welcome, ", // }, // { -// Type: types.TemplateItemTypeVar, -// VarType: types.TemplateVarName, +// Type: v1.TemplateItemTypeVar, +// VarType: v1.TemplateVarName, // }, // { -// Type: types.TemplateItemTypeText, +// Type: v1.TemplateItemTypeText, // Text: "!", // }, // }, @@ -168,7 +167,7 @@ func (c *MgClient) ActivateTemplate(channelID uint64, request ActivateTemplateRe // if err != nil { // fmt.Printf("%#v", err) // } -func (c *MgClient) UpdateTemplate(request types.Template) (int, error) { +func (c *MgClient) UpdateTemplate(request Template) (int, error) { outgoing, _ := json.Marshal(&request) data, status, err := c.PutRequest(fmt.Sprintf("/channels/%d/templates/%s", request.ChannelID, request.Code), outgoing) diff --git a/v1/types/template.go b/v1/template.go similarity index 99% rename from v1/types/template.go rename to v1/template.go index f4fee4b..4af7c21 100644 --- a/v1/types/template.go +++ b/v1/template.go @@ -1,4 +1,4 @@ -package types +package v1 import ( "encoding/json" diff --git a/v1/types.go b/v1/types.go index 5bb2cab..dc2ae8e 100644 --- a/v1/types.go +++ b/v1/types.go @@ -4,8 +4,6 @@ import ( "errors" "net/http" "time" - - "github.com/retailcrm/mg-transport-api-client-go/v1/types" ) //noinspection ALL @@ -419,10 +417,10 @@ type TransportRequestMeta struct { } type ActivateTemplateRequest struct { - Code string `binding:"required,min=1,max=512" json:"code"` - Name string `binding:"required,min=1,max=512" json:"name"` - Type string `binding:"required" json:"type"` - Template []types.TemplateItem `json:"template"` + Code string `binding:"required,min=1,max=512" json:"code"` + Name string `binding:"required,min=1,max=512" json:"name"` + Type string `binding:"required" json:"type"` + Template []TemplateItem `json:"template"` } var ErrInvalidOriginator = errors.New("invalid originator") diff --git a/v1/types_test.go b/v1/types_test.go index bb205fe..6f233af 100644 --- a/v1/types_test.go +++ b/v1/types_test.go @@ -3,8 +3,9 @@ package v1 import ( "encoding/json" "fmt" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestSendData_MarshalJSON(t *testing.T) {