From bbce989bce09265bd71bbb08f77c768456a386cd Mon Sep 17 00:00:00 2001 From: Suvorov Daniil Date: Thu, 3 Dec 2020 20:52:34 +0300 Subject: [PATCH 1/5] Add VkClient to vkapps.Params --- vkapps/params.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vkapps/params.go b/vkapps/params.go index dc6b52d2..d15d9708 100644 --- a/vkapps/params.go +++ b/vkapps/params.go @@ -123,6 +123,14 @@ const ( MobileIPhoneMessenger Platform = "mobile_iphone_messenger" ) +// Client from which the service is launched. +type Client string + +// Possible values. +const ( + ClientOk = "ok" +) + // Params service launch parameters. type Params struct { VkUserID int `schema:"vk_user_id"` @@ -137,6 +145,7 @@ type Params struct { VkViewerGroupRole Role `schema:"vk_viewer_group_role"` VkPlatform Platform `schema:"vk_platform"` VkTs string `schema:"vk_ts"` + VkClient Client `schema:"vk_client"` Sign string `schema:"sign"` } From 70c8510a6e52594bd1af998c048e8493a7bc9552 Mon Sep 17 00:00:00 2001 From: Suvorov Daniil Date: Thu, 3 Dec 2020 20:52:34 +0300 Subject: [PATCH 2/5] Add CallEndState possible values --- object/messages.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/object/messages.go b/object/messages.go index 5271debd..dc2648b1 100644 --- a/object/messages.go +++ b/object/messages.go @@ -681,6 +681,15 @@ type MessagesMessageAttachment struct { Podcast PodcastsEpisode `json:"podcast"` } +// State in which call ended up. +// +// TODO: v3 type CallEndState. +const ( + CallEndStateCanceledByInitiator = "canceled_by_initiator" + CallEndStateCanceledByReceiver = "canceled_by_receiver" + CallEndStateReached = "reached" +) + // MessageCall struct. type MessageCall struct { InitiatorID int `json:"initiator_id"` From df458e295952134aeae06382799f18638d0bea79 Mon Sep 17 00:00:00 2001 From: Suvorov Daniil Date: Thu, 3 Dec 2020 20:52:34 +0300 Subject: [PATCH 3/5] Add messages.getIntentUsers method --- api/messages.go | 15 +++++++++++ api/messages_test.go | 13 +++++++++ api/params/messages.go | 54 +++++++++++++++++++++++++++++++++++++ api/params/messages_test.go | 22 +++++++++++++++ 4 files changed, 104 insertions(+) diff --git a/api/messages.go b/api/messages.go index cfc7cf7c..0a8f5613 100644 --- a/api/messages.go +++ b/api/messages.go @@ -322,6 +322,21 @@ func (vk *VK) MessagesGetImportantMessages(params Params) (response MessagesGetI return } +// MessagesGetIntentUsersResponse struct. +type MessagesGetIntentUsersResponse struct { + Count int `json:"count"` + Items []int `json:"items"` + Profiles []object.MessagesMessage `json:"profiles,omitempty"` +} + +// MessagesGetIntentUsers method. +// +// https://vk.com/dev/messages.getIntentUsers +func (vk *VK) MessagesGetIntentUsers(params Params) (response MessagesGetIntentUsersResponse, err error) { + err = vk.RequestUnmarshal("messages.getIntentUsers", &response, params) + return +} + // MessagesGetInviteLinkResponse struct. type MessagesGetInviteLinkResponse struct { Link string `json:"link"` diff --git a/api/messages_test.go b/api/messages_test.go index 90797081..2a8c1e50 100644 --- a/api/messages_test.go +++ b/api/messages_test.go @@ -5,6 +5,7 @@ import ( "time" "github.com/SevereCloud/vksdk/v2/api" + "github.com/SevereCloud/vksdk/v2/api/params" "github.com/stretchr/testify/assert" ) @@ -306,6 +307,18 @@ func TestVK_MessagesGetImportantMessages(t *testing.T) { noError(t, err) } +func TestVK_MessagesGetIntentUsers(t *testing.T) { + t.Parallel() + + needGroupToken(t) + + _, err := vkGroup.MessagesGetIntentUsers(api.Params{ + "intent": params.PromoNewsletter, + "subscribe_id": 0, + }) + noError(t, err) +} + func TestVK_MessagesGetInviteLink(t *testing.T) { t.Parallel() diff --git a/api/params/messages.go b/api/params/messages.go index d6e82a5c..0ca92bea 100644 --- a/api/params/messages.go +++ b/api/params/messages.go @@ -701,6 +701,60 @@ func (b *MessagesGetHistoryAttachmentsBuilder) MaxForwardsLevel(v int) *Messages return b } +// MessagesGetIntentUsersBuilder builder. +// +// https://vk.com/dev/messages.getIntentUsers +type MessagesGetIntentUsersBuilder struct { + api.Params +} + +// NewMessagesGetIntentUsersBuilder func. +func NewMessagesGetIntentUsersBuilder() *MessagesGetIntentUsersBuilder { + return &MessagesGetIntentUsersBuilder{api.Params{}} +} + +// Intent parameter. +func (b *MessagesGetIntentUsersBuilder) Intent(v string) *MessagesGetIntentUsersBuilder { + b.Params["intent"] = v + return b +} + +// SubscribeID parameter. +func (b *MessagesGetIntentUsersBuilder) SubscribeID(v int) *MessagesGetIntentUsersBuilder { + b.Params["subscribe_id"] = v + return b +} + +// Offset parameter. +func (b *MessagesGetIntentUsersBuilder) Offset(v int) *MessagesGetIntentUsersBuilder { + b.Params["offset"] = v + return b +} + +// Count parameter. +func (b *MessagesGetIntentUsersBuilder) Count(v int) *MessagesGetIntentUsersBuilder { + b.Params["count"] = v + return b +} + +// Extended parameter. +func (b *MessagesGetIntentUsersBuilder) Extended(v bool) *MessagesGetIntentUsersBuilder { + b.Params["extended"] = v + return b +} + +// NameCase parameter. +func (b *MessagesGetIntentUsersBuilder) NameCase(v []string) *MessagesGetIntentUsersBuilder { + b.Params["name_case"] = v + return b +} + +// Fields parameter. +func (b *MessagesGetIntentUsersBuilder) Fields(v []string) *MessagesGetIntentUsersBuilder { + b.Params["fields"] = v + return b +} + // MessagesGetInviteLinkBuilder builder. // // https://vk.com/dev/messages.getInviteLink diff --git a/api/params/messages_test.go b/api/params/messages_test.go index b3d7a353..b1d61e63 100644 --- a/api/params/messages_test.go +++ b/api/params/messages_test.go @@ -289,6 +289,28 @@ func TestMessagesGetHistoryAttachmentsBuilder(t *testing.T) { assert.Equal(t, b.Params["max_forwards_level"], 1) } +func TestMessagesGetIntentUsersBuilder(t *testing.T) { + t.Parallel() + + b := params.NewMessagesGetIntentUsersBuilder() + + b.Intent("test") + b.SubscribeID(1) + b.Offset(1) + b.Count(1) + b.Extended(true) + b.NameCase([]string{"test"}) + b.Fields([]string{"test"}) + + assert.Equal(t, b.Params["intent"], "test") + assert.Equal(t, b.Params["subscribe_id"], 1) + assert.Equal(t, b.Params["offset"], 1) + assert.Equal(t, b.Params["count"], 1) + assert.Equal(t, b.Params["extended"], true) + assert.Equal(t, b.Params["name_case"], []string{"test"}) + assert.Equal(t, b.Params["fields"], []string{"test"}) +} + func TestMessagesGetInviteLinkBuilder(t *testing.T) { t.Parallel() From bfeed414327dafea907fc977d924a09cd173efcb Mon Sep 17 00:00:00 2001 From: Suvorov Daniil Date: Sat, 5 Dec 2020 15:35:07 +0300 Subject: [PATCH 4/5] docs: up version --- doc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc.go b/doc.go index 8234f5cf..7bb83d0c 100644 --- a/doc.go +++ b/doc.go @@ -7,6 +7,6 @@ package vksdk // Module constants. const ( - Version = "2.8.0" + Version = "2.9.0" API = "5.126" ) From 46fc34621235505912e55230d183cfea776ccef7 Mon Sep 17 00:00:00 2001 From: Suvorov Daniil Date: Sat, 5 Dec 2020 15:38:13 +0300 Subject: [PATCH 5/5] Add ErrUnknown* --- api/errors.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/errors.go b/api/errors.go index ff335546..a852e7d9 100644 --- a/api/errors.go +++ b/api/errors.go @@ -165,6 +165,15 @@ const ( // User was banned. ErrUserBanned ErrorType = 37 + // Unknown application. + ErrUnknownApplication ErrorType = 38 + + // Unknown user. + ErrUnknownUser ErrorType = 39 + + // Unknown group. + ErrUnknownGroup ErrorType = 40 + // One of the parameters specified was missing or invalid // // Check the required parameters list and their format on a method