feat: achievements queries added

This commit is contained in:
Mikhail Shabanov committed 2021-03-23 13:44:03 +01:00
1 parent b4e28506ba
commit 310f46b1e7
18 files changed
+505 -45

No files matched your search

@@ -0,0 +1,46 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using WotBlitzStatisticsPro.Common;
using WotBlitzStatisticsPro.Common.Model;
using WotBlitzStatisticsPro.WgApiClient.Model;
namespace WotBlitzStatisticsPro.WgApiClient
{
public class WargamingAchievementsApiClient: WagramingApiClientBase,
IWargamingAchievementsApiClient
{
public WargamingAchievementsApiClient(HttpClient httpClient, IWargamingApiSettings wargamingApiSettings) : base(httpClient, wargamingApiSettings)
{
}
public async Task<WotAccountAchievementResponse?> GetAccountAchievements(long accountId, RealmType realmType = RealmType.Ru,
RequestLanguage language = RequestLanguage.En)
{
var accountAchievements = await GetFromBlitzApi<Dictionary<string, WotAccountAchievementResponse>>(
realmType,
language,
"account/achievements/",
$"account_id={accountId}").ConfigureAwait(false);
return accountAchievements?[accountId.ToString()];
}
public async Task<WotAccountAchievementResponse?> GetTankAchievements(long accountId, long tankId, RealmType realmType = RealmType.Ru,
RequestLanguage language = RequestLanguage.En)
{
var accountAchievements = await GetFromBlitzApi<Dictionary<string, WotAccountAchievementResponse[]>>(
realmType,
language,
"tanks/achievements/",
$"account_id={accountId}",
$"tank_id={tankId}").ConfigureAwait(false);
if (accountAchievements?[accountId.ToString()] != null &&
accountAchievements?[accountId.ToString()].Length == 1)
{
return accountAchievements?[accountId.ToString()][0];
}
return null;
}
}
}