-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1500 В ответе метода calls.start есть незадокументированное поле "ok_join_link". Не очень понял, что это и для чего (одноклассники?), но на всякий случай добавил вместе с остальными полями.
- Loading branch information
Showing
12 changed files
with
235 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,45 @@ | ||
using FluentAssertions; | ||
using VkNet.Tests.Infrastructure; | ||
using Xunit; | ||
|
||
namespace VkNet.Tests.Categories.Calls; | ||
|
||
public class CallsCategoryTest : CategoryBaseTest | ||
{ | ||
protected override string Folder => "Calls"; | ||
|
||
[Fact] | ||
public void ForceFinish() | ||
{ | ||
Url = "https://api.vk.com/method/calls.forceFinish"; | ||
|
||
ReadCategoryJsonPath(nameof(ForceFinish)); | ||
|
||
var result = Api.Calls.ForceFinish(new() | ||
{ | ||
CallId = "10c5386e-10cb-43c6-999a-d01a37ee71e0" | ||
}); | ||
|
||
result.Should() | ||
.BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void Start() | ||
{ | ||
Url = "https://api.vk.com/method/calls.start"; | ||
|
||
ReadCategoryJsonPath(nameof(Start)); | ||
|
||
var result = Api.Calls.Start(new()); | ||
|
||
result.JoinLink.Should() | ||
.Be("https://vk.com/call/join/7BIRLBXzMD74J_JGR3G5wNZbZCkAT_ZtNFzJbHhIkMk"); | ||
|
||
result.OkJoinLink.Should() | ||
.Be("7BIRLBXzMD74J_JGR3G5wNZbZCkAT_ZtNFzJbHhIkMk"); | ||
|
||
result.CallId.Should() | ||
.Be("10c5386e-10cb-43c6-999a-d01a37ee71e0"); | ||
} | ||
} |
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,3 @@ | ||
{ | ||
"response": 1 | ||
} |
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,7 @@ | ||
{ | ||
"response": { | ||
"join_link": "https://vk.com/call/join/7BIRLBXzMD74J_JGR3G5wNZbZCkAT_ZtNFzJbHhIkMk", | ||
"ok_join_link": "7BIRLBXzMD74J_JGR3G5wNZbZCkAT_ZtNFzJbHhIkMk", | ||
"call_id": "10c5386e-10cb-43c6-999a-d01a37ee71e0" | ||
} | ||
} |
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,35 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using VkNet.Model; | ||
|
||
namespace VkNet.Abstractions; | ||
|
||
/// <summary> | ||
/// Методы для работы со звонками | ||
/// </summary> | ||
public interface ICallsCategoryAsync | ||
{ | ||
/// <summary> | ||
/// Принудительно завершить звонок | ||
/// </summary> | ||
/// <param name="params">Параметры запроса</param> | ||
/// <param name="token">Токен отмены операции</param> | ||
/// <returns>После успешного выполнения возвращает <c> true </c>.</returns> | ||
/// <remarks> | ||
/// Страница документации ВКонтакте https://dev.vk.com/ru/method/calls.forceFinish | ||
/// </remarks> | ||
Task<bool> ForceFinishAsync(CallsForceFinishParams @params, | ||
CancellationToken token = default); | ||
|
||
/// <summary> | ||
/// Создать новый звонок от имени пользователя или сообщества | ||
/// </summary> | ||
/// <param name="params">Параметры запроса</param> | ||
/// <param name="token">Токен отмены операции</param> | ||
/// <returns>После успешного выполнения возвращает объект CallStartResult</returns> | ||
/// <remarks> | ||
/// Страница документации ВКонтакте https://dev.vk.com/ru/method/calls.start | ||
/// </remarks> | ||
Task<CallStartResult> StartAsync(CallsStartParams @params, | ||
CancellationToken token = default); | ||
} |
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,15 @@ | ||
using VkNet.Model; | ||
|
||
namespace VkNet.Abstractions; | ||
|
||
/// <summary> | ||
/// Методы для работы со звонками | ||
/// </summary> | ||
public interface ICallsCategory : ICallsCategoryAsync | ||
{ | ||
/// <inheritdoc cref="ICallsCategoryAsync.ForceFinishAsync"/> | ||
bool ForceFinish(CallsForceFinishParams @params); | ||
|
||
/// <inheritdoc cref="ICallsCategoryAsync.StartAsync"/> | ||
CallStartResult Start(CallsStartParams @params); | ||
} |
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,21 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using VkNet.Abstractions; | ||
using VkNet.Model; | ||
using VkNet.Utils; | ||
|
||
namespace VkNet.Categories; | ||
|
||
/// <inheritdoc cref="ICallsCategory" /> | ||
public partial class CallsCategory | ||
{ | ||
/// <inheritdoc /> | ||
public Task<bool> ForceFinishAsync(CallsForceFinishParams @params, CancellationToken token = default) => | ||
TypeHelper.TryInvokeMethodAsync(() => | ||
ForceFinish(@params), token); | ||
|
||
/// <inheritdoc /> | ||
public Task<CallStartResult> StartAsync(CallsStartParams @params, CancellationToken token = default) => | ||
TypeHelper.TryInvokeMethodAsync(() => | ||
Start(@params), token); | ||
} |
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,41 @@ | ||
using VkNet.Abstractions; | ||
using VkNet.Exception; | ||
using VkNet.Model; | ||
|
||
namespace VkNet.Categories; | ||
|
||
/// <inheritdoc cref="ICallsCategory" /> | ||
public partial class CallsCategory : ICallsCategory | ||
{ | ||
private readonly IVkApiInvoke _vk; | ||
|
||
/// <summary> | ||
/// Инициализирует новый экземпляр класса <see cref="CallsCategory" /> | ||
/// </summary> | ||
public CallsCategory(IVkApiInvoke vk) => _vk = vk; | ||
|
||
/// <inheritdoc /> | ||
public bool ForceFinish(CallsForceFinishParams @params) | ||
{ | ||
if (@params.CallId.Length is not 36) | ||
{ | ||
throw new VkApiException(message: "Параметр call_id обязательный. Макс. длина = 36 Мин. длина = 36"); | ||
} | ||
|
||
return _vk.Call<bool>("calls.forceFinish", new() | ||
{ | ||
{ | ||
"call_id", @params.CallId | ||
} | ||
}); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public CallStartResult Start(CallsStartParams @params) => | ||
_vk.Call<CallStartResult>("calls.start", new() | ||
{ | ||
{ | ||
"group_id", @params.GroupId | ||
} | ||
}); | ||
} |
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,29 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
|
||
namespace VkNet.Model; | ||
|
||
/// <summary> | ||
/// Результат создания нового звонка | ||
/// </summary> | ||
[Serializable] | ||
public class CallStartResult | ||
{ | ||
/// <summary> | ||
/// Ссылка на звонок | ||
/// </summary> | ||
[JsonProperty("join_link")] | ||
public string JoinLink { get; set; } | ||
|
||
/// <summary> | ||
/// Ссылка на звонок (Ok) | ||
/// </summary> | ||
[JsonProperty("ok_join_link")] | ||
public string OkJoinLink { get; set; } | ||
|
||
/// <summary> | ||
/// Идентификатор созданного звонка | ||
/// </summary> | ||
[JsonProperty("call_id")] | ||
public string CallId { get; set; } | ||
} |
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,16 @@ | ||
using System; | ||
|
||
namespace VkNet.Model; | ||
|
||
/// <summary> | ||
/// Список параметров для метода calls.forceFinish | ||
/// </summary> | ||
[Serializable] | ||
public class CallsForceFinishParams | ||
{ | ||
/// <summary> | ||
/// Идентификатор звонка | ||
/// </summary> | ||
/// <remarks>Обязательный параметр Макс. длина = 36 Мин. длина = 36</remarks> | ||
public string CallId { get; set; } | ||
} |
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,14 @@ | ||
using System; | ||
|
||
namespace VkNet.Model; | ||
/// <summary> | ||
/// Список параметров для метода calls.start | ||
/// </summary> | ||
[Serializable] | ||
public class CallsStartParams | ||
{ | ||
/// <summary> | ||
/// Идентификатор сообщества | ||
/// </summary> | ||
public int? GroupId { get; set; } | ||
} |
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