2020-04-14 11:16:51 +02:00
|
|
|
using System.Collections.Generic;
|
2020-02-15 16:00:42 +03:00
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using WotBlitzStatisticsPro.WgApiClient.Model;
|
|
|
|
|
|
|
|
|
|
namespace WotBlitzStatisticsPro.WgApiClient
|
|
|
|
|
{
|
|
|
|
|
public class WargamingApiClient : WagramingApiClientBase, IWargamingApiClient
|
|
|
|
|
{
|
|
|
|
|
public WargamingApiClient(
|
|
|
|
|
HttpClient httpClient,
|
|
|
|
|
IWargamingApiSettings wargamingApiSettings) : base(httpClient, wargamingApiSettings)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-14 11:16:51 +02:00
|
|
|
public async Task<List<WotAccountListResponse>> FindAccounts(string nickName,
|
2020-02-15 16:00:42 +03:00
|
|
|
RealmType realmType = RealmType.Ru,
|
|
|
|
|
RequestLanguage language = RequestLanguage.En)
|
|
|
|
|
{
|
2020-04-14 11:16:51 +02:00
|
|
|
return await GetFromBlitzApi<List<WotAccountListResponse>>(
|
|
|
|
|
realmType,
|
|
|
|
|
language,
|
|
|
|
|
"account/list/",
|
|
|
|
|
$"search={nickName}").ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// https://api.wotblitz.ru/wotb/clans/list/?application_id=adc1387489cf9fc8d9a1d85dbd27763d&search=xxx
|
2020-02-15 16:00:42 +03:00
|
|
|
|
|
|
|
|
public async Task<AccountInfo> GetPlayerAccountInfo(long accountId,
|
|
|
|
|
RealmType realmType = RealmType.Ru,
|
|
|
|
|
RequestLanguage language = RequestLanguage.En)
|
|
|
|
|
{
|
|
|
|
|
var account = await GetFromBlitzApi<Dictionary<string, AccountInfo>>(
|
|
|
|
|
realmType,
|
|
|
|
|
language,
|
|
|
|
|
"account/info/",
|
2020-02-25 00:46:02 +03:00
|
|
|
$"account_id={accountId}").ConfigureAwait(false);
|
2020-02-15 16:00:42 +03:00
|
|
|
return account[accountId.ToString()];
|
|
|
|
|
}
|
2020-02-25 00:46:02 +03:00
|
|
|
|
|
|
|
|
public async Task<ClanAccountInfo> GetPlayerClanInfo(long accountId,
|
|
|
|
|
RealmType realmType = RealmType.Ru,
|
|
|
|
|
RequestLanguage language = RequestLanguage.En)
|
|
|
|
|
{
|
|
|
|
|
var clanInfo = await GetFromBlitzApi<Dictionary<string, ClanAccountInfo>>(
|
|
|
|
|
realmType,
|
|
|
|
|
language,
|
|
|
|
|
"clans/accountinfo/",
|
|
|
|
|
$"account_id={accountId}").ConfigureAwait(false);
|
|
|
|
|
if (clanInfo.ContainsKey(accountId.ToString()))
|
|
|
|
|
{
|
|
|
|
|
return clanInfo[accountId.ToString()];
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2020-03-06 17:33:40 +01:00
|
|
|
|
|
|
|
|
public async Task<ClanInfo> GetClanInfo(
|
|
|
|
|
long clanId,
|
|
|
|
|
RealmType realmType = RealmType.Ru,
|
|
|
|
|
RequestLanguage language = RequestLanguage.En)
|
|
|
|
|
{
|
|
|
|
|
var clanInfo = await GetFromBlitzApi<Dictionary<string, ClanInfo>>(
|
|
|
|
|
realmType,
|
|
|
|
|
language,
|
|
|
|
|
"clans/info/",
|
|
|
|
|
$"clan_id={clanId}").ConfigureAwait(false);
|
|
|
|
|
if (clanInfo.ContainsKey(clanId.ToString()))
|
|
|
|
|
{
|
|
|
|
|
return clanInfo[clanId.ToString()];
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-19 22:00:47 +01:00
|
|
|
// https://api.wotblitz.ru/wotb/encyclopedia/achievements/?application_id=adc1387489cf9fc8d9a1d85dbd27763d
|
|
|
|
|
|
2020-02-15 16:00:42 +03:00
|
|
|
}
|
|
|
|
|
}
|