Dictionaries updater factory

This commit is contained in:
Mikhail Shabanov committed 2020-05-29 23:03:32 +02:00
1 parent cdf7ec5130
commit 32f7245d85
11 files changed
+279 -21

No files matched your search

@@ -0,0 +1,15 @@
using System.Threading.Tasks;
using WotBlitzStatisticsPro.Common.Model;
using WotBlitzStatisticsPro.WgApiClient.Model;
namespace WotBlitzStatisticsPro.WgApiClient
{
public interface IWargamingDictionariesApiClient
{
Task<(
WotEncyclopediaInfoResponse,
WotClanMembersDictionaryResponse)> GetStaticDictionariesAsync(
RealmType realmType = RealmType.Ru,
RequestLanguage language = RequestLanguage.En);
}
}
@@ -0,0 +1,20 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace WotBlitzStatisticsPro.WgApiClient.Model
{
public class WotClanMembersDictionaryResponse
{
/// <summary>
/// Clan roles list
/// </summary>
[JsonProperty("clans_roles")]
public Dictionary<string, string> ClanRoles { get; set; }
/// <summary>
/// Clan settings list
/// </summary>
[JsonProperty("settings")]
public Dictionary<string, string> Settings { get; set; }
}
}
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace WotBlitzStatisticsPro.WgApiClient.Model
{
public class WotEncyclopediaInfoResponse
{
///<summary>
/// Game client version
///</summary>
[JsonProperty("game_version")]
public string GameVersion { get; set; }
///<summary>
/// List of supported languages
///</summary>
[JsonProperty("languages")]
public Dictionary<string, string> Languages { get; set; }
///<summary>
/// Encyclopedia last update time
///</summary>
[JsonProperty("tanks_updated_at")]
public int? TanksUpdatedAt { get; set; }
///<summary>
/// Cru clan role
///</summary>
[JsonProperty("vehicle_crew_roles")]
public Dictionary<string, string> VehicleCrewRoles { get; set; }
///<summary>
/// Vehicle nations dictionary
///</summary>
[JsonProperty("vehicle_nations")]
public Dictionary<string, string> VehicleNations { get; set; }
///<summary>
/// Vehicle types dictionary
///</summary>
[JsonProperty("vehicle_types")]
public Dictionary<string, string> VehicleTypes { get; set; }
///<summary>
/// Achievements sections
///</summary>
[JsonProperty("achievement_sections")]
public Dictionary<string, WotEncyclopediaInfoAchievementSection> AchievementSections { get; set; }
}
public class WotEncyclopediaInfoAchievementSection
{
///<summary>
/// Achievements section name
///</summary>
[JsonProperty("name")]
public string Name { get; set; }
///<summary>
/// Achievement section order
///</summary>
[JsonProperty("order")]
public long? Order { get; set; }
}
}
@@ -7,15 +7,18 @@ using WotBlitzStatisticsPro.WgApiClient.Model;
namespace WotBlitzStatisticsPro.WgApiClient
{
public class WargamingApiClient : WagramingApiClientBase, IWargamingApiClient
{
public class WargamingApiClient : WagramingApiClientBase,
IWargamingApiClient,
IWargamingDictionariesApiClient
{
public WargamingApiClient(
HttpClient httpClient,
IWargamingApiSettings wargamingApiSettings) : base(httpClient, wargamingApiSettings)
{
}
public async Task<List<WotAccountListResponse>> FindAccounts(string nickName,
#region Search methods
public async Task<List<WotAccountListResponse>> FindAccounts(string nickName,
RealmType realmType = RealmType.Ru,
RequestLanguage language = RequestLanguage.En)
{
@@ -37,8 +40,40 @@ namespace WotBlitzStatisticsPro.WgApiClient
$"search={searchString}").ConfigureAwait(false);
}
#endregion
public async Task<AccountInfo> GetPlayerAccountInfo(long accountId,
#region Encyclopedia methods
public async Task<(
WotEncyclopediaInfoResponse,
WotClanMembersDictionaryResponse)> GetStaticDictionariesAsync(
RealmType realmType = RealmType.Ru,
RequestLanguage language = RequestLanguage.En)
{
var encyclopedia = await GetFromBlitzApi<WotEncyclopediaInfoResponse>(
realmType,
language,
"encyclopedia/info/"
).ConfigureAwait(false);
var clanGlossaryResponse = await GetFromBlitzApi<WotClanMembersDictionaryResponse>(
realmType,
language,
"clans/glossary/");
return (encyclopedia, clanGlossaryResponse);
}
#endregion
public async Task<AccountInfo> GetPlayerAccountInfo(long accountId,
RealmType realmType = RealmType.Ru,
RequestLanguage language = RequestLanguage.En)
{
@@ -83,7 +118,10 @@ namespace WotBlitzStatisticsPro.WgApiClient
return null;
}
// https://api.wotblitz.ru/wotb/encyclopedia/achievements/?application_id=adc1387489cf9fc8d9a1d85dbd27763d
// https://api.wotblitz.ru/wotb/encyclopedia/achievements/?application_id=adc1387489cf9fc8d9a1d85dbd27763d
}
}
}