Skip to content

Commit

Permalink
Merge branch 'dev-v2.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
SevereCloud committed Dec 6, 2020
2 parents d3d9a51 + 46fc346 commit 691e87e
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 1 deletion.
9 changes: 9 additions & 0 deletions api/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions api/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
13 changes: 13 additions & 0 deletions api/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/SevereCloud/vksdk/v2/api"
"github.com/SevereCloud/vksdk/v2/api/params"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -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()

Expand Down
54 changes: 54 additions & 0 deletions api/params/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions api/params/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ package vksdk

// Module constants.
const (
Version = "2.8.0"
Version = "2.9.0"
API = "5.126"
)
9 changes: 9 additions & 0 deletions object/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
9 changes: 9 additions & 0 deletions vkapps/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
}

Expand Down

0 comments on commit 691e87e

Please sign in to comment.