mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-21 02:17:20 +02:00
Clans search method
This commit is contained in:
1 parent
ed770e8c30
commit
5b88704edf
13 files changed
+179
-1
No files matched your search
@@ -19,6 +19,13 @@ namespace WotBlitzStatistics.GraphQl.Query
|
||||
// return _wargamingSearcher.GetPlayerAccountInfo(accountId);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Finds Wargaming accounts by nick
|
||||
/// </summary>
|
||||
/// <param name="accountNick">Search string.</param>
|
||||
/// <param name="realmType">Wargaming Realm.</param>
|
||||
/// <param name="language">Language for the output data.</param>
|
||||
/// <returns></returns>
|
||||
public Task<AccountsSearchResponse> FindAccounts(
|
||||
string accountNick,
|
||||
RealmType? realmType,
|
||||
@@ -26,5 +33,20 @@ namespace WotBlitzStatistics.GraphQl.Query
|
||||
{
|
||||
return _wargamingSearcher.FindAccounts(accountNick, realmType ?? RealmType.Ru, language ?? RequestLanguage.En);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds clans by search string
|
||||
/// </summary>
|
||||
/// <param name="searchString">Search string.</param>
|
||||
/// <param name="realmType">Wargaming Realm.</param>
|
||||
/// <param name="language">Language for the output data.</param>
|
||||
/// <returns></returns>
|
||||
public Task<ClanSearchResponse> FindClans(
|
||||
string searchString,
|
||||
RealmType? realmType,
|
||||
RequestLanguage? language)
|
||||
{
|
||||
return _wargamingSearcher.FindClans(searchString, realmType ?? RealmType.Ru, language ?? RequestLanguage.En);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -10,5 +10,10 @@ namespace WotBlitzStatistics.Logic
|
||||
string accountNick,
|
||||
RealmType realmType,
|
||||
RequestLanguage language);
|
||||
|
||||
Task<ClanSearchResponse> FindClans(
|
||||
string searchString,
|
||||
RealmType realmType,
|
||||
RequestLanguage language);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using AutoMapper;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
namespace WotBlitzStatistics.Logic.Mappers
|
||||
{
|
||||
public class ClanSearchResponseProfile: Profile
|
||||
{
|
||||
public ClanSearchResponseProfile()
|
||||
{
|
||||
CreateMap<WotClanListResponse, ClanSearchResponseItem>()
|
||||
.ForMember(
|
||||
d => d.ClanId,
|
||||
o => o.MapFrom(s => s.ClanId.Value));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,5 +30,18 @@ namespace WotBlitzStatistics.Logic
|
||||
Accounts = _mapper.Map<List<WotAccountListResponse>, List<AccountsSearchResponseItem>>(response)
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ClanSearchResponse> FindClans(
|
||||
string searchString,
|
||||
RealmType realmType,
|
||||
RequestLanguage language)
|
||||
{
|
||||
var response = await _wargamingApiClient.FindClans(searchString, realmType, language);
|
||||
return new ClanSearchResponse
|
||||
{
|
||||
ClansCount = response.Count,
|
||||
Clans = _mapper.Map<List<WotClanListResponse>, List<ClanSearchResponseItem>>(response)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,18 @@
|
||||
|
||||
namespace WotBlitzStatisticsPro.Common.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Response contains a list of found accounts
|
||||
/// </summary>
|
||||
public class AccountsSearchResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Count of found accounts
|
||||
/// </summary>
|
||||
public int AccountsCount { get; set; }
|
||||
/// <summary>
|
||||
/// Found accounts list
|
||||
/// </summary>
|
||||
public ICollection<AccountsSearchResponseItem> Accounts { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace WotBlitzStatisticsPro.Common.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Account search result item
|
||||
/// </summary>
|
||||
public class AccountsSearchResponseItem
|
||||
{
|
||||
///<summary>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Common.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Response with list of found clans
|
||||
/// </summary>
|
||||
public class ClanSearchResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Count of clans in the list
|
||||
/// </summary>
|
||||
public int ClansCount { get; set; }
|
||||
/// <summary>
|
||||
/// List of clans
|
||||
/// </summary>
|
||||
public ICollection<ClanSearchResponseItem> Clans { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace WotBlitzStatisticsPro.Common.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Found clans list item
|
||||
/// </summary>
|
||||
public class ClanSearchResponseItem
|
||||
{
|
||||
///<summary>
|
||||
/// Clan Id
|
||||
///</summary>
|
||||
public long ClanId { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Clan Tag
|
||||
///</summary>
|
||||
public string Tag { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Clan Name
|
||||
///</summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Clan created at. (UNIX Epoch time)
|
||||
///</summary>
|
||||
public int CreatedAt { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Clan members count
|
||||
///</summary>
|
||||
public int MembersCount { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -10,6 +10,10 @@ namespace WotBlitzStatisticsPro.WgApiClient
|
||||
RealmType realmType = RealmType.Ru,
|
||||
RequestLanguage language = RequestLanguage.En);
|
||||
|
||||
Task<List<WotClanListResponse>> FindClans(string searchString,
|
||||
RealmType realmType = RealmType.Ru,
|
||||
RequestLanguage language = RequestLanguage.En);
|
||||
|
||||
Task<AccountInfo> GetPlayerAccountInfo(long accountId,
|
||||
RealmType realmType = RealmType.Ru,
|
||||
RequestLanguage language = RequestLanguage.En);
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace WotBlitzStatisticsPro.WgApiClient.Model
|
||||
{
|
||||
public class WotClanListResponse
|
||||
{
|
||||
///<summary>
|
||||
/// Clan Id
|
||||
///</summary>
|
||||
[JsonProperty("clan_id")]
|
||||
public long? ClanId { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Clan Tag
|
||||
///</summary>
|
||||
[JsonProperty("tag")]
|
||||
public string Tag { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Clan Name
|
||||
///</summary>
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Clan created at. (UNIX Epoch time)
|
||||
///</summary>
|
||||
[JsonProperty("created_at")]
|
||||
public int CreatedAt { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Clan members count
|
||||
///</summary>
|
||||
[JsonProperty("members_count")]
|
||||
public int MembersCount { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,17 @@ namespace WotBlitzStatisticsPro.WgApiClient
|
||||
$"search={nickName}").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// https://api.wotblitz.ru/wotb/clans/list/?application_id=adc1387489cf9fc8d9a1d85dbd27763d&search=xxx
|
||||
public async Task<List<WotClanListResponse>> FindClans(string searchString,
|
||||
RealmType realmType = RealmType.Ru,
|
||||
RequestLanguage language = RequestLanguage.En)
|
||||
{
|
||||
return await GetFromBlitzApi<List<WotClanListResponse>>(
|
||||
realmType,
|
||||
language,
|
||||
"clans/list/",
|
||||
$"search={searchString}").ConfigureAwait(false);
|
||||
|
||||
}
|
||||
|
||||
public async Task<AccountInfo> GetPlayerAccountInfo(long accountId,
|
||||
RealmType realmType = RealmType.Ru,
|
||||
|
||||
Reference in new issue
Block a user