Skip to content

Commit

Permalink
Add fields for method "market.search" (#1576)
Browse files Browse the repository at this point in the history
Bound issue: #1222 

- Removed field *Tags* from args of method
- Added fields *Status* and *NeedVariants*
- Added unit test for method *market.search*

[Source of args](https://dev.vk.com/ru/method/market.search)
  • Loading branch information
Rahovski authored Aug 14, 2023
1 parent f6fd60e commit a3efd52
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 9 deletions.
74 changes: 74 additions & 0 deletions VkNet.Tests/Categories/Market/MarketSearchTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using FluentAssertions;
using VkNet.Tests.Infrastructure;
using Xunit;

namespace VkNet.Tests.Categories.Market
{
public class MarketSearchTest : CategoryBaseTest
{
protected override string Folder => "Market";

[Fact]
public void MarketSearch()
{
Url = "https://api.vk.com/method/market.search";

ReadCategoryJsonPath(nameof(Api.Markets.Search));

var result = Api.Markets.Search(new()
{
OwnerId = -85689507,
PriceFrom = 5000,
Sort = Enums.ProductSort.ByCost,
Offset = 0,
Count = 2,
Status = "0",
NeedVariants = true
});

result.Should().
NotBeNull();

result.Count.
Should().
Be(2);

result[0].Title.
Should().
Be("Bastet Snowboard");

result[0].Price.
Amount.
Should().
Be(5000000);

result[0].Category.
Name.
Should().
Be("Доски для сноубординга");

result[0].Availability.
Should().
Be(0);

result[1].Title.
Should().
Be("Katana NIKIFILINI");

result[1].Price.
Amount.
Should().
Be(2290000);

result[1].OwnerId.
Should().
Be(-85689507);

result[1].Category.
Section.
Name.
Should().
Be("Спорт и отдых");
}
}
}
74 changes: 74 additions & 0 deletions VkNet.Tests/TestData/Categories/Market/Search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"response": {
"count": 60,
"view_type": 1,
"items": [
{
"availability": 0,
"category": {
"id": 40834,
"name": "Доски для сноубординга",
"section": {
"id": 10005,
"name": "Спорт и отдых"
}
},
"description": "Ростовка: 140,145,150,155\nЖесткость: 5/10 \nГеометрия: full twintip\nПрогиб: camber-rocker-camber\nФорма загибов: radius2flat\n\nПромеры (для модели 145см)\n\nNose/Waist/Tail: 279/240/279мм\nRadius: multy 6.8 - 7.5m\nStance: 530mm\nSetback: 0mm",
"id": 1139824,
"owner_id": -85689507,
"price": {
"amount": "5000000",
"currency": {
"id": 643,
"name": "RUB",
"title": ""
},
"text": "50000 ₽"
},
"title": "Bastet Snowboard",
"is_owner": false,
"is_adult": false,
"thumb_photo": "https://sun6-22.userapi.com/impf/c824604/v824604807/a1fb5/3Oj1mwWVXFo.jpg?size=400x0&crop=0,0.22,1,0.604&quality=95&sign=b8a1e62d66739826a7b1a0e176d9f6c3&c_uniq_tag=TmaNzf066Mdev_XG1xHcpcv8h2mFbAUBa-Arb2ygLEg",
"cart_quantity": 0,
"item_rating": {
"rating": 0,
"reviews_count": 0,
"reviews_count_text": "Нет отзывов"
}
},
{
"availability": 0,
"category": {
"id": 30417,
"name": "Скейтборды и лонгборды",
"section": {
"id": 10005,
"name": "Спорт и отдых"
}
},
"description": "Длина: 46\nШирина: 9.5\nКонкейв: U-образный\nФлекс: мягкий, средний, жесткий\nТейлы: 15, 16, 17м\nПолиуретановая защита по всему периметру\nДизайн: Катя Войнова",
"id": 6996709,
"owner_id": -85689507,
"price": {
"amount": "2290000",
"currency": {
"id": 643,
"name": "RUB",
"title": ""
},
"text": "22900 ₽"
},
"title": "Katana NIKIFILINI",
"is_owner": false,
"is_adult": false,
"thumb_photo": "https://sun6-20.userapi.com/impg/GRnTmi_N0zOsy5X0KV3j3LQt7ovJId9uvcSdmQ/ETUzAN1xI6w.jpg?crop=0,0.219,1,0.563&size=400x0&quality=95&sign=22a0dd58b06c1a394b061a572a616a39&c_uniq_tag=BmN1PRZ9K_wUa1YgIFafbImOBWRxf76fGe8rdPohUHA",
"cart_quantity": 0,
"item_rating": {
"rating": 0,
"reviews_count": 0,
"reviews_count_text": "Нет отзывов"
}
}
]
}
}
9 changes: 6 additions & 3 deletions VkNet/Categories/MarketsCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ public VkCollection<Market> Search(MarketSearchParams @params) => _vk.Call<VkCol
{
"price_to", @params.PriceTo
},
{
"tags", @params.Tags
},
{
"sort", @params.Sort
},
Expand All @@ -97,6 +94,12 @@ public VkCollection<Market> Search(MarketSearchParams @params) => _vk.Call<VkCol
},
{
"extended", @params.Extended
},
{
"status", @params.Status
},
{
"need_variants", @params.NeedVariants
}
});

Expand Down
17 changes: 11 additions & 6 deletions VkNet/Model/RequestParams/Market/MarketSearchParams.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using VkNet.Enums;

Expand Down Expand Up @@ -35,11 +35,6 @@ public class MarketSearchParams
/// </summary>
public long? PriceTo { get; set; }

/// <summary>
/// Перечисленные через запятую идентификаторы меток.
/// </summary>
public IEnumerable<long> Tags { get; set; }

/// <summary>
/// Вид сортировки.
/// </summary>
Expand All @@ -66,4 +61,14 @@ public class MarketSearchParams
/// ''photos'''.
/// </summary>
public bool? Extended { get; set; }

/// <summary>
/// Фильтр по активности товара. "0" - только активные, "2" - неактивные, "0,2" - активные и неактивные
/// </summary>
public string Status { get; set; }

/// <summary>
/// 0 - не нужно получать дополнительные варианты товара. 1 - нужно получать доп. варианты товара
/// </summary>
public bool? NeedVariants { get; set; }
}

0 comments on commit a3efd52

Please sign in to comment.