-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package api // import "github.com/SevereCloud/vksdk/v2/api" | ||
|
||
// CallsStartResponse struct. | ||
type CallsStartResponse struct { | ||
JoinLink string `json:"join_link"` | ||
CallID string `json:"call_id"` | ||
} | ||
|
||
// CallsStart method. | ||
// | ||
// https://vk.com/dev/calls.start | ||
func (vk *VK) CallsStart(params Params) (response CallsStartResponse, err error) { | ||
err = vk.RequestUnmarshal("calls.start", &response, params) | ||
return | ||
} | ||
|
||
// CallsForceFinish method. | ||
// | ||
// https://vk.com/dev/calls.forceFinish | ||
func (vk *VK) CallsForceFinish(params Params) (response int, err error) { | ||
err = vk.RequestUnmarshal("calls.forceFinish", &response, params) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package api_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/SevereCloud/vksdk/v2/api" | ||
) | ||
|
||
func TestVK_CallsStart(t *testing.T) { | ||
t.Parallel() | ||
|
||
needUserToken(t) | ||
|
||
startCall, err := vkUser.CallsStart(nil) | ||
noError(t, err) | ||
|
||
_, err = vkUser.CallsForceFinish(api.Params{ | ||
"call_id": startCall.CallID, | ||
}) | ||
noError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package params | ||
|
||
import "github.com/SevereCloud/vksdk/v2/api" | ||
|
||
// CallsStartBuilder builder. | ||
// | ||
// https://vk.com/dev/calls.start | ||
type CallsStartBuilder struct { | ||
api.Params | ||
} | ||
|
||
// NewCallsStartBuilder func. | ||
func NewCallsStartBuilder() *CallsStartBuilder { | ||
return &CallsStartBuilder{api.Params{}} | ||
} | ||
|
||
// GroupID parameter. | ||
func (b *CallsStartBuilder) GroupID(v int) *CallsStartBuilder { | ||
b.Params["group_id"] = v | ||
return b | ||
} | ||
|
||
// CallsForceFinishBuilder builder. | ||
// | ||
// https://vk.com/dev/calls.forceFinish | ||
type CallsForceFinishBuilder struct { | ||
api.Params | ||
} | ||
|
||
// NewCallsForceFinishBuilder func. | ||
func NewCallsForceFinishBuilder() *CallsForceFinishBuilder { | ||
return &CallsForceFinishBuilder{api.Params{}} | ||
} | ||
|
||
// CallID parameter. | ||
func (b *CallsForceFinishBuilder) CallID(v string) *CallsForceFinishBuilder { | ||
b.Params["call_id"] = v | ||
return b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package params_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/SevereCloud/vksdk/v2/api/params" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCallsStartBuilder(t *testing.T) { | ||
t.Parallel() | ||
|
||
b := params.NewCallsStartBuilder() | ||
|
||
b.GroupID(1) | ||
|
||
assert.Equal(t, b.Params["group_id"], 1) | ||
} | ||
|
||
func TestCallsForceFinishBuilder(t *testing.T) { | ||
t.Parallel() | ||
|
||
b := params.NewCallsForceFinishBuilder() | ||
|
||
b.CallID("text") | ||
|
||
assert.Equal(t, b.Params["call_id"], "text") | ||
} |