2020-11-17 11:01:35 +01:00
|
|
|
using System;
|
2021-05-15 17:36:35 +02:00
|
|
|
using System.Collections.Generic;
|
2020-11-17 11:01:35 +01:00
|
|
|
using System.Threading.Tasks;
|
2021-03-19 19:49:58 +01:00
|
|
|
using HotChocolate.Types;
|
2020-04-14 11:16:51 +02:00
|
|
|
using WotBlitzStatisticsPro.Common.Model;
|
2020-05-23 11:43:14 +02:00
|
|
|
using WotBlitzStatisticsPro.Logic;
|
2020-02-15 16:00:42 +03:00
|
|
|
|
2020-05-23 11:43:14 +02:00
|
|
|
namespace WotBlitzStatisticsPro.GraphQl.Query
|
2020-02-15 16:00:42 +03:00
|
|
|
{
|
2021-03-19 19:49:58 +01:00
|
|
|
[ExtendObjectType(Name = "Query")]
|
2020-02-15 16:00:42 +03:00
|
|
|
public class WotBlitzStatisticsQuery
|
|
|
|
|
{
|
2020-05-21 17:53:01 +02:00
|
|
|
// 571050560 - mboga Eu
|
|
|
|
|
// 90277267 - Mboga Ru
|
|
|
|
|
|
2020-05-18 17:29:54 +02:00
|
|
|
private readonly IWargamingSearch _wargamingSearcher;
|
2020-10-25 19:05:08 +01:00
|
|
|
private readonly IWargamingAccounts _wargamingAccounts;
|
2020-02-15 16:00:42 +03:00
|
|
|
|
2020-10-25 19:05:08 +01:00
|
|
|
public WotBlitzStatisticsQuery(IWargamingSearch wargamingSearcher,
|
|
|
|
|
IWargamingAccounts wargamingAccounts)
|
2020-02-15 16:00:42 +03:00
|
|
|
{
|
2020-05-18 17:29:54 +02:00
|
|
|
_wargamingSearcher = wargamingSearcher;
|
2020-10-25 19:05:08 +01:00
|
|
|
_wargamingAccounts = wargamingAccounts;
|
2020-02-15 16:00:42 +03:00
|
|
|
}
|
|
|
|
|
|
2020-05-19 14:22:47 +02:00
|
|
|
/// <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>
|
2021-05-15 17:36:35 +02:00
|
|
|
public Task<ICollection<AccountsSearchResponseItem>> Players(
|
2020-05-18 17:29:54 +02:00
|
|
|
string accountNick,
|
|
|
|
|
RealmType? realmType,
|
|
|
|
|
RequestLanguage? language)
|
2020-02-15 16:00:42 +03:00
|
|
|
{
|
2020-05-18 17:29:54 +02:00
|
|
|
return _wargamingSearcher.FindAccounts(accountNick, realmType ?? RealmType.Ru, language ?? RequestLanguage.En);
|
2020-02-15 16:00:42 +03:00
|
|
|
}
|
2020-05-19 14:22:47 +02:00
|
|
|
|
|
|
|
|
/// <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>
|
2021-05-15 17:36:35 +02:00
|
|
|
public Task<ICollection<ClanSearchResponseItem>?> Clans(
|
2020-05-19 14:22:47 +02:00
|
|
|
string searchString,
|
|
|
|
|
RealmType? realmType,
|
|
|
|
|
RequestLanguage? language)
|
|
|
|
|
{
|
|
|
|
|
return _wargamingSearcher.FindClans(searchString, realmType ?? RealmType.Ru, language ?? RequestLanguage.En);
|
|
|
|
|
}
|
2020-10-25 19:05:08 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gathers all account information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="realmType">Account region</param>
|
|
|
|
|
/// <param name="accountId">AccountId</param>
|
|
|
|
|
/// <param name="requestLanguage">Request language</param>
|
|
|
|
|
public Task<AccountInfoResponse> AccountInfo(
|
|
|
|
|
long accountId,
|
|
|
|
|
RealmType? realmType,
|
|
|
|
|
RequestLanguage? requestLanguage
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
return _wargamingAccounts.GatherAccountInformation(realmType ?? RealmType.Ru, accountId, requestLanguage ?? RequestLanguage.En);
|
|
|
|
|
}
|
2020-11-17 11:01:35 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Account statistics history for period since "startDate"
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="accountId">AccountId</param>
|
|
|
|
|
/// <param name="startDate">Date from history started</param>
|
|
|
|
|
/// <param name="realmType">Account region</param>
|
|
|
|
|
/// <param name="requestLanguage">Request language</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public Task<AccountInfoHistoryResponse> AccountInfoHistory(
|
|
|
|
|
long accountId,
|
|
|
|
|
DateTime startDate,
|
|
|
|
|
RealmType? realmType,
|
|
|
|
|
RequestLanguage? requestLanguage)
|
|
|
|
|
{
|
|
|
|
|
return _wargamingAccounts.GetAccountInfoHistory(realmType ?? RealmType.Ru, accountId, startDate,
|
|
|
|
|
requestLanguage ?? RequestLanguage.En);
|
|
|
|
|
}
|
2021-01-05 13:04:13 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tank statistics history for period since "startDate"
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="accountId">AccountId</param>
|
|
|
|
|
/// <param name="tankId">TankId</param>
|
|
|
|
|
/// <param name="startDate">Date from history started</param>
|
|
|
|
|
/// <param name="realmType">Account region</param>
|
|
|
|
|
/// <param name="requestLanguage">Request language</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public Task<TankInfoHistoryResponse> TankInfoHistory(
|
|
|
|
|
long accountId,
|
|
|
|
|
long tankId,
|
|
|
|
|
DateTime startDate,
|
|
|
|
|
RealmType? realmType,
|
|
|
|
|
RequestLanguage? requestLanguage)
|
|
|
|
|
{
|
|
|
|
|
return _wargamingAccounts.GetTankInfoHistory(realmType ?? RealmType.Ru, accountId, tankId, startDate,
|
|
|
|
|
requestLanguage ?? RequestLanguage.En);
|
|
|
|
|
}
|
2020-02-15 16:00:42 +03:00
|
|
|
}
|
|
|
|
|
}
|