-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vknet#1500 Implement calls.forceFinish method
- Loading branch information
Showing
9 changed files
with
137 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,26 @@ | ||
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(); | ||
} | ||
} |
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,23 @@ | ||
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); | ||
} |
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,12 @@ | ||
using VkNet.Model; | ||
|
||
namespace VkNet.Abstractions; | ||
|
||
/// <summary> | ||
/// Методы для работы со звонками | ||
/// </summary> | ||
public interface ICallsCategory : ICallsCategoryAsync | ||
{ | ||
/// <inheritdoc cref="ICallsCategoryAsync.ForceFinishAsync"/> | ||
bool ForceFinish(CallsForceFinishParams @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,16 @@ | ||
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); | ||
} |
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,32 @@ | ||
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 | ||
} | ||
}); | ||
} | ||
} |
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