remove reduntant package
This commit is contained in:
parent
9166c63a0c
commit
ef0905e3ac
2
go.sum
2
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=
|
||||
|
31
v1/client.go
31
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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
package types
|
||||
package v1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -4,8 +4,6 @@ import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/retailcrm/mg-transport-api-client-go/v1/types"
|
||||
)
|
||||
|
||||
//noinspection ALL
|
||||
@ -422,7 +420,7 @@ 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"`
|
||||
Template []TemplateItem `json:"template"`
|
||||
}
|
||||
|
||||
var ErrInvalidOriginator = errors.New("invalid originator")
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user