1
0
mirror of synced 2024-11-25 14:36:03 +03:00

remove reduntant package

This commit is contained in:
Pavel 2020-04-07 17:27:04 +03:00
parent 9166c63a0c
commit ef0905e3ac
5 changed files with 22 additions and 26 deletions

2
go.sum
View File

@ -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/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 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 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 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.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=

View File

@ -11,7 +11,6 @@ import (
"time" "time"
"github.com/google/go-querystring/query" "github.com/google/go-querystring/query"
"github.com/retailcrm/mg-transport-api-client-go/v1/types"
) )
// New initialize client // 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)) // fmt.Printf("Status: %v, Templates found: %v", status, len(data))
func (c *MgClient) TransportTemplates() ([]types.TemplateItem, int, error) { func (c *MgClient) TransportTemplates() ([]TemplateItem, int, error) {
var resp []types.TemplateItem var resp []TemplateItem
data, status, err := c.GetRequest("/templates", []byte{}) data, status, err := c.GetRequest("/templates", []byte{})
if err != nil { if err != nil {
@ -102,18 +101,18 @@ func (c *MgClient) TransportTemplates() ([]types.TemplateItem, int, error) {
// request := v1.ActivateTemplateRequest{ // request := v1.ActivateTemplateRequest{
// Code: "code", // Code: "code",
// Name: "name", // Name: "name",
// Type: types.TemplateTypeText, // Type: v1.TemplateTypeText,
// Template: []types.TemplateItem{ // Template: []v1.TemplateItem{
// { // {
// Type: types.TemplateItemTypeText, // Type: v1.TemplateItemTypeText,
// Text: "Hello, ", // Text: "Hello, ",
// }, // },
// { // {
// Type: types.TemplateItemTypeVar, // Type: v1.TemplateItemTypeVar,
// VarType: types.TemplateVarName, // VarType: v1.TemplateVarName,
// }, // },
// { // {
// Type: types.TemplateItemTypeText, // Type: v1.TemplateItemTypeText,
// Text: "!", // Text: "!",
// }, // },
// }, // },
@ -143,21 +142,21 @@ func (c *MgClient) ActivateTemplate(channelID uint64, request ActivateTemplateRe
// Example: // Example:
// var client = New("https://token.url", "cb8ccf05e38a47543ad8477d4999be73bff503ea6") // var client = New("https://token.url", "cb8ccf05e38a47543ad8477d4999be73bff503ea6")
// //
// request := types.Template{ // request := v1.Template{
// Code: "templateCode", // Code: "templateCode",
// ChannelID: 1, // ChannelID: 1,
// Name: "templateName", // Name: "templateName",
// Template: []types.TemplateItem{ // Template: []v1.TemplateItem{
// { // {
// Type: types.TemplateItemTypeText, // Type: v1.TemplateItemTypeText,
// Text: "Welcome, ", // Text: "Welcome, ",
// }, // },
// { // {
// Type: types.TemplateItemTypeVar, // Type: v1.TemplateItemTypeVar,
// VarType: types.TemplateVarName, // VarType: v1.TemplateVarName,
// }, // },
// { // {
// Type: types.TemplateItemTypeText, // Type: v1.TemplateItemTypeText,
// Text: "!", // Text: "!",
// }, // },
// }, // },
@ -168,7 +167,7 @@ func (c *MgClient) ActivateTemplate(channelID uint64, request ActivateTemplateRe
// if err != nil { // if err != nil {
// fmt.Printf("%#v", err) // 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) outgoing, _ := json.Marshal(&request)
data, status, err := c.PutRequest(fmt.Sprintf("/channels/%d/templates/%s", request.ChannelID, request.Code), outgoing) data, status, err := c.PutRequest(fmt.Sprintf("/channels/%d/templates/%s", request.ChannelID, request.Code), outgoing)

View File

@ -1,4 +1,4 @@
package types package v1
import ( import (
"encoding/json" "encoding/json"

View File

@ -4,8 +4,6 @@ import (
"errors" "errors"
"net/http" "net/http"
"time" "time"
"github.com/retailcrm/mg-transport-api-client-go/v1/types"
) )
//noinspection ALL //noinspection ALL
@ -419,10 +417,10 @@ type TransportRequestMeta struct {
} }
type ActivateTemplateRequest struct { type ActivateTemplateRequest struct {
Code string `binding:"required,min=1,max=512" json:"code"` Code string `binding:"required,min=1,max=512" json:"code"`
Name string `binding:"required,min=1,max=512" json:"name"` Name string `binding:"required,min=1,max=512" json:"name"`
Type string `binding:"required" json:"type"` Type string `binding:"required" json:"type"`
Template []types.TemplateItem `json:"template"` Template []TemplateItem `json:"template"`
} }
var ErrInvalidOriginator = errors.New("invalid originator") var ErrInvalidOriginator = errors.New("invalid originator")

View File

@ -3,8 +3,9 @@ package v1
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/stretchr/testify/assert"
"testing" "testing"
"github.com/stretchr/testify/assert"
) )
func TestSendData_MarshalJSON(t *testing.T) { func TestSendData_MarshalJSON(t *testing.T) {