diff --git a/WotBlitzStatistics.GraphQl/Query/WotBlitzStatisticsQuery.cs b/WotBlitzStatistics.GraphQl/Query/WotBlitzStatisticsQuery.cs index 99d206e..44c1060 100644 --- a/WotBlitzStatistics.GraphQl/Query/WotBlitzStatisticsQuery.cs +++ b/WotBlitzStatistics.GraphQl/Query/WotBlitzStatisticsQuery.cs @@ -19,6 +19,13 @@ namespace WotBlitzStatistics.GraphQl.Query // return _wargamingSearcher.GetPlayerAccountInfo(accountId); //} + /// + /// Finds Wargaming accounts by nick + /// + /// Search string. + /// Wargaming Realm. + /// Language for the output data. + /// public Task FindAccounts( string accountNick, RealmType? realmType, @@ -26,5 +33,20 @@ namespace WotBlitzStatistics.GraphQl.Query { return _wargamingSearcher.FindAccounts(accountNick, realmType ?? RealmType.Ru, language ?? RequestLanguage.En); } + + /// + /// Finds clans by search string + /// + /// Search string. + /// Wargaming Realm. + /// Language for the output data. + /// + public Task FindClans( + string searchString, + RealmType? realmType, + RequestLanguage? language) + { + return _wargamingSearcher.FindClans(searchString, realmType ?? RealmType.Ru, language ?? RequestLanguage.En); + } } } diff --git a/WotBlitzStatistics.GraphQl/WotBlitzStatistics.GraphQl.csproj b/WotBlitzStatistics.GraphQl/WotBlitzStatistics.GraphQl.csproj index 13b388e..8d87c1b 100644 --- a/WotBlitzStatistics.GraphQl/WotBlitzStatistics.GraphQl.csproj +++ b/WotBlitzStatistics.GraphQl/WotBlitzStatistics.GraphQl.csproj @@ -2,6 +2,8 @@ netcoreapp3.1 + true + $(NoWarn);1591 diff --git a/WotBlitzStatistics.Logic/IWargamingSearch.cs b/WotBlitzStatistics.Logic/IWargamingSearch.cs index 9df0e50..1acccd9 100644 --- a/WotBlitzStatistics.Logic/IWargamingSearch.cs +++ b/WotBlitzStatistics.Logic/IWargamingSearch.cs @@ -10,5 +10,10 @@ namespace WotBlitzStatistics.Logic string accountNick, RealmType realmType, RequestLanguage language); + + Task FindClans( + string searchString, + RealmType realmType, + RequestLanguage language); } } \ No newline at end of file diff --git a/WotBlitzStatistics.Logic/Mappers/ClanSearchResponseProfile.cs b/WotBlitzStatistics.Logic/Mappers/ClanSearchResponseProfile.cs new file mode 100644 index 0000000..a934983 --- /dev/null +++ b/WotBlitzStatistics.Logic/Mappers/ClanSearchResponseProfile.cs @@ -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() + .ForMember( + d => d.ClanId, + o => o.MapFrom(s => s.ClanId.Value)); + + } + } +} \ No newline at end of file diff --git a/WotBlitzStatistics.Logic/WargamingSearch.cs b/WotBlitzStatistics.Logic/WargamingSearch.cs index 057f789..5d2c229 100644 --- a/WotBlitzStatistics.Logic/WargamingSearch.cs +++ b/WotBlitzStatistics.Logic/WargamingSearch.cs @@ -30,5 +30,18 @@ namespace WotBlitzStatistics.Logic Accounts = _mapper.Map, List>(response) }; } + + public async Task 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>(response) + }; + } } } \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Common/Model/AccountsSearchResponse.cs b/WotBlitzStatisticsPro.Common/Model/AccountsSearchResponse.cs index 6163799..e001128 100644 --- a/WotBlitzStatisticsPro.Common/Model/AccountsSearchResponse.cs +++ b/WotBlitzStatisticsPro.Common/Model/AccountsSearchResponse.cs @@ -2,9 +2,18 @@ namespace WotBlitzStatisticsPro.Common.Model { + /// + /// Response contains a list of found accounts + /// public class AccountsSearchResponse { + /// + /// Count of found accounts + /// public int AccountsCount { get; set; } + /// + /// Found accounts list + /// public ICollection Accounts { get; set; } } } \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Common/Model/AccountsSearchResponseItem.cs b/WotBlitzStatisticsPro.Common/Model/AccountsSearchResponseItem.cs index 482a6bc..d51d006 100644 --- a/WotBlitzStatisticsPro.Common/Model/AccountsSearchResponseItem.cs +++ b/WotBlitzStatisticsPro.Common/Model/AccountsSearchResponseItem.cs @@ -1,5 +1,8 @@ namespace WotBlitzStatisticsPro.Common.Model { + /// + /// Account search result item + /// public class AccountsSearchResponseItem { /// diff --git a/WotBlitzStatisticsPro.Common/Model/ClanSearchResponse.cs b/WotBlitzStatisticsPro.Common/Model/ClanSearchResponse.cs new file mode 100644 index 0000000..d07f209 --- /dev/null +++ b/WotBlitzStatisticsPro.Common/Model/ClanSearchResponse.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace WotBlitzStatisticsPro.Common.Model +{ + /// + /// Response with list of found clans + /// + public class ClanSearchResponse + { + /// + /// Count of clans in the list + /// + public int ClansCount { get; set; } + /// + /// List of clans + /// + public ICollection Clans { get; set; } + } +} \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Common/Model/ClanSearchResponseItem.cs b/WotBlitzStatisticsPro.Common/Model/ClanSearchResponseItem.cs new file mode 100644 index 0000000..b331f5e --- /dev/null +++ b/WotBlitzStatisticsPro.Common/Model/ClanSearchResponseItem.cs @@ -0,0 +1,34 @@ +namespace WotBlitzStatisticsPro.Common.Model +{ + /// + /// Found clans list item + /// + public class ClanSearchResponseItem + { + /// + /// Clan Id + /// + public long ClanId { get; set; } + + /// + /// Clan Tag + /// + public string Tag { get; set; } + + /// + /// Clan Name + /// + public string Name { get; set; } + + /// + /// Clan created at. (UNIX Epoch time) + /// + public int CreatedAt { get; set; } + + /// + /// Clan members count + /// + public int MembersCount { get; set; } + + } +} \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Common/WotBlitzStatisticsPro.Common.csproj b/WotBlitzStatisticsPro.Common/WotBlitzStatisticsPro.Common.csproj index f45bdfc..3ecd41e 100644 --- a/WotBlitzStatisticsPro.Common/WotBlitzStatisticsPro.Common.csproj +++ b/WotBlitzStatisticsPro.Common/WotBlitzStatisticsPro.Common.csproj @@ -2,6 +2,7 @@ netstandard2.1 + true diff --git a/WotBlitzStatisticsPro.WgApiClient/IWargamingApiClient.cs b/WotBlitzStatisticsPro.WgApiClient/IWargamingApiClient.cs index 52cf08a..a883c9e 100644 --- a/WotBlitzStatisticsPro.WgApiClient/IWargamingApiClient.cs +++ b/WotBlitzStatisticsPro.WgApiClient/IWargamingApiClient.cs @@ -10,6 +10,10 @@ namespace WotBlitzStatisticsPro.WgApiClient RealmType realmType = RealmType.Ru, RequestLanguage language = RequestLanguage.En); + Task> FindClans(string searchString, + RealmType realmType = RealmType.Ru, + RequestLanguage language = RequestLanguage.En); + Task GetPlayerAccountInfo(long accountId, RealmType realmType = RealmType.Ru, RequestLanguage language = RequestLanguage.En); diff --git a/WotBlitzStatisticsPro.WgApiClient/Model/WotClanListResponse.cs b/WotBlitzStatisticsPro.WgApiClient/Model/WotClanListResponse.cs new file mode 100644 index 0000000..f0476fb --- /dev/null +++ b/WotBlitzStatisticsPro.WgApiClient/Model/WotClanListResponse.cs @@ -0,0 +1,38 @@ +using Newtonsoft.Json; + +namespace WotBlitzStatisticsPro.WgApiClient.Model +{ + public class WotClanListResponse + { + /// + /// Clan Id + /// + [JsonProperty("clan_id")] + public long? ClanId { get; set; } + + /// + /// Clan Tag + /// + [JsonProperty("tag")] + public string Tag { get; set; } + + /// + /// Clan Name + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// Clan created at. (UNIX Epoch time) + /// + [JsonProperty("created_at")] + public int CreatedAt { get; set; } + + /// + /// Clan members count + /// + [JsonProperty("members_count")] + public int MembersCount { get; set; } + + } +} \ No newline at end of file diff --git a/WotBlitzStatisticsPro.WgApiClient/WargamingApiClient.cs b/WotBlitzStatisticsPro.WgApiClient/WargamingApiClient.cs index fb848ff..4322c0c 100644 --- a/WotBlitzStatisticsPro.WgApiClient/WargamingApiClient.cs +++ b/WotBlitzStatisticsPro.WgApiClient/WargamingApiClient.cs @@ -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> FindClans(string searchString, + RealmType realmType = RealmType.Ru, + RequestLanguage language = RequestLanguage.En) + { + return await GetFromBlitzApi>( + realmType, + language, + "clans/list/", + $"search={searchString}").ConfigureAwait(false); + + } public async Task GetPlayerAccountInfo(long accountId, RealmType realmType = RealmType.Ru,