From 0789e72134536a7a6fbe79767ecb0ff733fa9dfa Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Mon, 10 Sep 2018 11:33:42 +0300 Subject: [PATCH 1/2] add name field to channel --- README.md | 1 + v1/client.go | 2 ++ v1/client_test.go | 16 ++++++++-------- v1/types.go | 3 ++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a96f6f9..c8f5cb5 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ func main() { var client = v1.New("https://token.url", "cb8ccf05e38a47543ad8477d49bcba99be73bff503ea6") ch := Channel{ Type: "telegram", + Name: "Telegram" Settings: ChannelSettings{ SpamAllowed: false, Status: Status{ diff --git a/v1/client.go b/v1/client.go index 8894ff0..82d7899 100644 --- a/v1/client.go +++ b/v1/client.go @@ -26,6 +26,7 @@ func New(url string, token string) *MgClient { // // request := ActivateRequest{ // Type: "telegram", +// Name: "Telegram", // Settings: ChannelSettings{ // SpamAllowed: false, // Status: Status{ @@ -77,6 +78,7 @@ func (c *MgClient) ActivateTransportChannel(request Channel) (ActivateResponse, // request := ActivateRequest{ // ID: 3053450384, // Type: "telegram", +// Name: "Telegram", // Settings: ChannelSettings{ // SpamAllowed: false, // Status: Status{ diff --git a/v1/client_test.go b/v1/client_test.go index 2b0d1ba..32f0122 100644 --- a/v1/client_test.go +++ b/v1/client_test.go @@ -24,6 +24,7 @@ func TestMgClient_ActivateTransportChannel(t *testing.T) { ch := Channel{ ID: channelId, Type: "telegram", + Name: "Telegram", Settings: ChannelSettings{ SpamAllowed: false, Status: Status{ @@ -52,6 +53,7 @@ func TestMgClient_ActivateNewTransportChannel(t *testing.T) { c := client() ch := Channel{ Type: "telegram", + Name: "Telegram", Settings: ChannelSettings{ SpamAllowed: false, Status: Status{ @@ -91,7 +93,8 @@ func TestMgClient_ActivateNewTransportChannel(t *testing.T) { func TestMgClient_UpdateTransportChannel(t *testing.T) { c := client() ch := Channel{ - ID: channelId, + ID: channelId, + Name: "Somename", Settings: ChannelSettings{ SpamAllowed: false, Status: Status{ @@ -121,13 +124,10 @@ func TestMgClient_Messages(t *testing.T) { t.Logf("%v", ext) snd := SendData{ - Message: SendMessage{ - Message{ - ExternalID: ext, - Type: "text", - Text: "hello!", - }, - time.Now(), + Message: Message{ + ExternalID: ext, + Type: "text", + Text: "hello!", }, User: User{ ExternalID: "6", diff --git a/v1/types.go b/v1/types.go index d996a6d..2c1e0df 100644 --- a/v1/types.go +++ b/v1/types.go @@ -24,6 +24,7 @@ type MgClient struct { type Channel struct { ID uint64 `json:"id,omitempty"` Type string `json:"type,omitempty"` + Name string `json:"name,omitempty"` Settings ChannelSettings `json:"settings,omitempty,brackets"` } @@ -101,7 +102,7 @@ type UpdateMessage struct { // SendData struct type SendData struct { - Message SendMessage `json:"message"` + Message Message `json:"message"` User User `json:"user"` Channel uint64 `json:"channel"` ExternalChatID string `json:"external_chat_id"` From 5643dd7db7fcc193d7deb6c327bc8706342509c5 Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Mon, 10 Sep 2018 12:06:57 +0300 Subject: [PATCH 2/2] update channel name example --- README.md | 2 +- v1/client.go | 4 ++-- v1/client_test.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c8f5cb5..8ff63ad 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ func main() { var client = v1.New("https://token.url", "cb8ccf05e38a47543ad8477d49bcba99be73bff503ea6") ch := Channel{ Type: "telegram", - Name: "Telegram" + Name: "@my_shopping_bot" Settings: ChannelSettings{ SpamAllowed: false, Status: Status{ diff --git a/v1/client.go b/v1/client.go index 82d7899..3dbe78e 100644 --- a/v1/client.go +++ b/v1/client.go @@ -26,7 +26,7 @@ func New(url string, token string) *MgClient { // // request := ActivateRequest{ // Type: "telegram", -// Name: "Telegram", +// Name: "@my_shopping_bot", // Settings: ChannelSettings{ // SpamAllowed: false, // Status: Status{ @@ -78,7 +78,7 @@ func (c *MgClient) ActivateTransportChannel(request Channel) (ActivateResponse, // request := ActivateRequest{ // ID: 3053450384, // Type: "telegram", -// Name: "Telegram", +// Name: "@my_shopping_bot", // Settings: ChannelSettings{ // SpamAllowed: false, // Status: Status{ diff --git a/v1/client_test.go b/v1/client_test.go index 32f0122..91a4870 100644 --- a/v1/client_test.go +++ b/v1/client_test.go @@ -24,7 +24,7 @@ func TestMgClient_ActivateTransportChannel(t *testing.T) { ch := Channel{ ID: channelId, Type: "telegram", - Name: "Telegram", + Name: "@my_shopping_bot", Settings: ChannelSettings{ SpamAllowed: false, Status: Status{ @@ -53,7 +53,7 @@ func TestMgClient_ActivateNewTransportChannel(t *testing.T) { c := client() ch := Channel{ Type: "telegram", - Name: "Telegram", + Name: "@my_shopping_bot", Settings: ChannelSettings{ SpamAllowed: false, Status: Status{ @@ -94,7 +94,7 @@ func TestMgClient_UpdateTransportChannel(t *testing.T) { c := client() ch := Channel{ ID: channelId, - Name: "Somename", + Name: "@my_shopping_bot_2", Settings: ChannelSettings{ SpamAllowed: false, Status: Status{