diff --git a/WotBlitzStatisticsPro.DataAccess/Model/Accounts/AccountInfoHistory.cs b/WotBlitzStatisticsPro.DataAccess/Model/Accounts/AccountInfoHistory.cs index 374e62b..d89d414 100644 --- a/WotBlitzStatisticsPro.DataAccess/Model/Accounts/AccountInfoHistory.cs +++ b/WotBlitzStatisticsPro.DataAccess/Model/Accounts/AccountInfoHistory.cs @@ -73,7 +73,7 @@ public long? MaxXp { get; set; } /// - /// Tank Id which created max experiense per battle + /// Tank Id which created max experience per battle /// public long? MaxXpTankId { get; set; } @@ -93,7 +93,7 @@ public long? SurvivedBattles { get; set; } /// - /// Total count of suvived and winned battles + /// Total count of survived and winned battles /// public long? WinAndSurvived { get; set; } diff --git a/WotBlitzStatisticsPro.DataAccess/Model/Accounts/TankInfo.cs b/WotBlitzStatisticsPro.DataAccess/Model/Accounts/TankInfo.cs new file mode 100644 index 0000000..8191d8e --- /dev/null +++ b/WotBlitzStatisticsPro.DataAccess/Model/Accounts/TankInfo.cs @@ -0,0 +1,7 @@ +namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts +{ + public class TankInfo + { + + } +} \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/GetTanksInfoOperation.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/GetTanksInfoOperation.cs index 2f3dbd6..53b75c8 100644 --- a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/GetTanksInfoOperation.cs +++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/GetTanksInfoOperation.cs @@ -1,15 +1,30 @@ using System; using System.Threading.Tasks; +using AutoMapper; using WotBlitzStatisticsPro.Logic.Pipeline; +using WotBlitzStatisticsPro.WgApiClient; namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations { public class GetTanksInfoOperation: IOperation { - public Task Invoke(AccountInformationPipelineContext context, Func next) - { - return next.Invoke(context); + private readonly IWargamingTanksApiClient _wargamingApi; + private readonly IMapper _mapper; + public GetTanksInfoOperation( + IWargamingTanksApiClient wargamingApi, + IMapper mapper) + { + _wargamingApi = wargamingApi; + _mapper = mapper; + } + + public async Task Invoke(AccountInformationPipelineContext context, Func next) + { + var tanksInfo = await + _wargamingApi.GetPlayerAccountTanksInfo(context.AccountId, context.RealmType, context.RequestLanguage); + + await next.Invoke(context); } } } \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Logic/WotBlitzStatisticsLogicInstaller.cs b/WotBlitzStatisticsPro.Logic/WotBlitzStatisticsLogicInstaller.cs index 4a1b96e..f64c707 100644 --- a/WotBlitzStatisticsPro.Logic/WotBlitzStatisticsLogicInstaller.cs +++ b/WotBlitzStatisticsPro.Logic/WotBlitzStatisticsLogicInstaller.cs @@ -24,6 +24,7 @@ namespace WotBlitzStatisticsPro.Logic services.AddAutoMapper(typeof(WotBlitzStatisticsLogicInstaller)); services.AddHttpClient(); services.AddHttpClient(); + services.AddHttpClient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/WotBlitzStatisticsPro.WgApiClient/IWargamingTanksApiClient.cs b/WotBlitzStatisticsPro.WgApiClient/IWargamingTanksApiClient.cs new file mode 100644 index 0000000..2798ffa --- /dev/null +++ b/WotBlitzStatisticsPro.WgApiClient/IWargamingTanksApiClient.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using WotBlitzStatisticsPro.Common.Model; +using WotBlitzStatisticsPro.WgApiClient.Model; + +namespace WotBlitzStatisticsPro.WgApiClient +{ + public interface IWargamingTanksApiClient + { + Task> GetPlayerAccountTanksInfo(long accountId, + RealmType realmType = RealmType.Ru, + RequestLanguage language = RequestLanguage.En); + } +} \ No newline at end of file diff --git a/WotBlitzStatisticsPro.WgApiClient/Model/WotAccountTanksFullStatistics.cs b/WotBlitzStatisticsPro.WgApiClient/Model/WotAccountTanksFullStatistics.cs new file mode 100644 index 0000000..1ab9df4 --- /dev/null +++ b/WotBlitzStatisticsPro.WgApiClient/Model/WotAccountTanksFullStatistics.cs @@ -0,0 +1,110 @@ +using Newtonsoft.Json; + +namespace WotBlitzStatisticsPro.WgApiClient.Model +{ + public class WotAccountTanksFullStatistics + { + /// + /// Battles count + /// + [JsonProperty("battles")] + public long? Battles { get; set; } + + /// + /// Base capture points + /// + [JsonProperty("capture_points")] + public long? CapturePoints { get; set; } + + /// + /// Damage dealt + /// + [JsonProperty("damage_dealt")] + public long? DamageDealt { get; set; } + + /// + /// Damage received + /// + [JsonProperty("damage_received")] + public long? DamageReceived { get; set; } + + /// + /// Base dropped capture points + /// + [JsonProperty("dropped_capture_points")] + public long? DroppedCapturePoints { get; set; } + + /// + /// Frags count + /// + [JsonProperty("frags")] + public long? Frags { get; set; } + + /// + /// Frags count after 8 tier + /// + [JsonProperty("frags8p")] + public long? Frags8P { get; set; } + + /// + /// Hits count + /// + [JsonProperty("hits")] + public long? Hits { get; set; } + + /// + /// Losses count + /// + [JsonProperty("losses")] + public long? Losses { get; set; } + + /// + /// Max frags per battle + /// + [JsonProperty("max_frags")] + public long? MaxFrags { get; set; } + + /// + /// Max XP per battle + /// + [JsonProperty("max_xp")] + public long? MaxXp { get; set; } + + /// + /// Shots count + /// + [JsonProperty("shots")] + public long? Shots { get; set; } + + /// + /// Spotted vehicles count + /// + [JsonProperty("spotted")] + public long? Spotted { get; set; } + + /// + /// Amount of survived battles + /// + [JsonProperty("survived_battles")] + public long? SurvivedBattles { get; set; } + + /// + /// Amount of survived and wined battles + /// + [JsonProperty("win_and_survived")] + public long? WinAndSurvived { get; set; } + + /// + /// Wins count + /// + [JsonProperty("wins")] + public long? Wins { get; set; } + + /// + /// Total experience + /// + [JsonProperty("xp")] + public long? Xp { get; set; } + + } +} \ No newline at end of file diff --git a/WotBlitzStatisticsPro.WgApiClient/Model/WotAccountTanksStatistics.cs b/WotBlitzStatisticsPro.WgApiClient/Model/WotAccountTanksStatistics.cs new file mode 100644 index 0000000..33128a7 --- /dev/null +++ b/WotBlitzStatisticsPro.WgApiClient/Model/WotAccountTanksStatistics.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; +using Newtonsoft.Json; +using WotBlitzStatisticsPro.Common.Model; + +namespace WotBlitzStatisticsPro.WgApiClient.Model +{ + public class WotAccountTanksStatistics + { + /// + /// Player account identifier + /// + [JsonProperty("account_id")] + public long AccountId { get; set; } + + [JsonProperty("battle_life_time")] + public int BattleLifeTimeInSeconds { get; set; } + + /// + /// Last battle + /// + [JsonProperty("last_battle_time")] + private int LastBattleTime { get; set; } + + [JsonProperty("in_garage")] + public bool? InGarage { get; set; } + + [JsonProperty("in_garage_updated")] + private int? InGarageUpdated { get; set; } + + /// + /// Mastery: + /// + /// 0 — None + /// 1 — Rank 3 + /// 2 — Rank 2 + /// 3 — Rank 1 + /// 4 — Mastery + /// + [JsonProperty("mark_of_mastery")] + private long _markOfMastery { get; set; } + public MarkOfMastery MarkOfMastery => (MarkOfMastery)_markOfMastery; + + /// + /// Tank identifier + /// + [JsonProperty("tank_id")] + public long TankId { get; set; } + + /// + /// Whole statistics + /// + [JsonProperty("all")] + public WotAccountTanksFullStatistics All { get; set; } + + [JsonProperty("frags")] + public Dictionary Frags { get; set; } + + } +} \ No newline at end of file diff --git a/WotBlitzStatisticsPro.WgApiClient/WargamingApiClient.cs b/WotBlitzStatisticsPro.WgApiClient/WargamingApiClient.cs index a67d87c..04470ad 100644 --- a/WotBlitzStatisticsPro.WgApiClient/WargamingApiClient.cs +++ b/WotBlitzStatisticsPro.WgApiClient/WargamingApiClient.cs @@ -10,7 +10,8 @@ namespace WotBlitzStatisticsPro.WgApiClient { public class WargamingApiClient : WagramingApiClientBase, IWargamingApiClient, - IWargamingDictionariesApiClient + IWargamingDictionariesApiClient, + IWargamingTanksApiClient { public WargamingApiClient( HttpClient httpClient, @@ -141,7 +142,21 @@ namespace WotBlitzStatisticsPro.WgApiClient // https://api.wotblitz.ru/wotb/encyclopedia/achievements/?application_id=adc1387489cf9fc8d9a1d85dbd27763d + #region Tanks methods + public async Task> GetPlayerAccountTanksInfo( + long accountId, + RealmType realmType = RealmType.Ru, + RequestLanguage language = RequestLanguage.En) + { + var tanks = await GetFromBlitzApi>>( + realmType, + language, + "tanks/stats/", + $"account_id={accountId}").ConfigureAwait(false); + return tanks[accountId.ToString()]; + } + #endregion } }