Skip to content

Commit

Permalink
Implement store.removeStickersFromFavorite method (#1501)
Browse files Browse the repository at this point in the history
  • Loading branch information
smtyper committed Nov 16, 2024
1 parent 2177257 commit 51a7326
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 1 deletion.
16 changes: 16 additions & 0 deletions VkNet.Tests/Categories/Store/StoreCategoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,20 @@ public void GetStickersKeywords()
sticker.IsAllowed.Should()
.BeTrue();
}

[Fact]
public void RemoveStickersFromFavorite()
{
Url = "https://api.vk.com/method/store.removeStickersFromFavorite";

ReadCategoryJsonPath(nameof(RemoveStickersFromFavorite));

var result = Api.Store.RemoveStickersFromFavorite(new()
{
StickerIds = ["126", "70"]
});

result.Should()
.BeTrue();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"response": 1
}
20 changes: 19 additions & 1 deletion VkNet/Abstractions/Category/Async/IStoreCategoryAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IStoreCategoryAsync
/// <param name="params">Параметры запроса</param>
/// <param name="token">Токен отмены операции.</param>
/// <returns>
/// После успешного выполнения возвращает 1.
/// После успешного выполнения возвращает true.
/// </returns>
/// <remarks>
/// Страница документации ВКонтакте https://dev.vk.com/ru/method/store.addStickersToFavorite
Expand All @@ -40,6 +40,9 @@ Task<bool> AddStickersToFavoriteAsync(StoreAddStickerToFavoriteParams @params,
/// <param name="params">Параметры запроса</param>
/// <param name="token">Токен отмены операции</param>
/// <returns>После успешного выполнения возвращает список объектов Product</returns>
/// <remarks>
/// Страница документации ВКонтакте https://dev.vk.com/ru/method/store.getProducts
/// </remarks>
Task<VkCollection<Product>> GetProductsAsync(StoreGetProductsParams @params,
CancellationToken token = default);

Expand All @@ -49,6 +52,21 @@ Task<VkCollection<Product>> GetProductsAsync(StoreGetProductsParams @params,
/// <param name="params">Параметры запроса</param>
/// <param name="token">Токен отмены операции</param>
/// <returns>Возвращается объект StickersKeywords</returns>
/// <remarks>
/// Страница документации ВКонтакте https://dev.vk.com/ru/method/store.getStickersKeywords
/// </remarks>
Task<StickersKeywords> GetStickersKeywordsAsync(StoreGetStickersKeywordsParams @params,
CancellationToken token = default);

/// <summary>
/// Удаляет стикер из избранных.
/// </summary>
/// <param name="params">Параметры запроса</param>
/// <param name="token">Токен отмены операции</param>
/// <returns>После успешного выполнения возвращает true</returns>
/// <remarks>
/// Страница документации ВКонтакте https://dev.vk.com/ru/method/store.removeStickersFromFavorite
/// </remarks>
Task<bool> RemoveStickersFromFavoriteAsync(StoreRemoveStickersFromFavoriteParams @params,
CancellationToken token = default);
}
3 changes: 3 additions & 0 deletions VkNet/Abstractions/Category/IStoreCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ public interface IStoreCategory : IStoreCategoryAsync

/// <inheritdoc cref="IStoreCategoryAsync.GetStickersKeywordsAsync"/>
StickersKeywords GetStickersKeywords(StoreGetStickersKeywordsParams @params);

/// <inheritdoc cref="IStoreCategoryAsync.RemoveStickersFromFavoriteAsync"/>
bool RemoveStickersFromFavorite(StoreRemoveStickersFromFavoriteParams @params);
}
5 changes: 5 additions & 0 deletions VkNet/Categories/Async/StoreCategoryAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public Task<VkCollection<Product>> GetProductsAsync(StoreGetProductsParams @para
public Task<StickersKeywords> GetStickersKeywordsAsync(StoreGetStickersKeywordsParams @params, CancellationToken token = default) =>
TypeHelper.TryInvokeMethodAsync(() =>
GetStickersKeywords(@params), token);

/// <inheritdoc />
public Task<bool> RemoveStickersFromFavoriteAsync(StoreRemoveStickersFromFavoriteParams @params, CancellationToken token = default) =>
TypeHelper.TryInvokeMethodAsync(() =>
RemoveStickersFromFavorite(@params), token);
}
9 changes: 9 additions & 0 deletions VkNet/Categories/StoreCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,13 @@ public StickersKeywords GetStickersKeywords(StoreGetStickersKeywordsParams @para
"need_stickers", @params.NeedStickers
}
});

/// <inheritdoc />
public bool RemoveStickersFromFavorite(StoreRemoveStickersFromFavoriteParams @params) =>
_vk.Call<bool>("store.removeStickersFromFavorite", new()
{
{
"sticker_ids", @params.StickerIds
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;

namespace VkNet.Model;

/// <summary>
/// Список параметров для метода store.removeStickersFromFavorite
/// </summary>
[Serializable]
public class StoreRemoveStickersFromFavoriteParams
{
/// <summary>
/// Идентификаторы стикеров
/// </summary>
public List<string> StickerIds { get; set; }
}

0 comments on commit 51a7326

Please sign in to comment.