Added GraphQl Server and wg API client

This commit is contained in:
Michael Shabanov committed 2020-02-15 16:00:42 +03:00
1 parent a0ad7ca395
commit abc99c835c
25 files changed
+872 -1

No files matched your search

@@ -0,0 +1,19 @@
using HotChocolate.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WotBlitzStatisticsPro.Common.Model;
namespace WotBlitzStatistics.GraphQl.ObjectTypes
{
public class PlayerAccountInfoObjectType: ObjectType<PlayerAccountInfo>
{
protected override void Configure(IObjectTypeDescriptor<PlayerAccountInfo> descriptor)
{
base.Configure(descriptor);
// Add resolver for Clan, Tanks, Achievements
// https://hotchocolate.io/docs/schema-object-type
}
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace WotBlitzStatistics.GraphQl
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
@@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:63522",
"sslPort": 44333
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "graphql/playground",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WotBlitzStatistics.GraphQl": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "graphql/playground",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
@@ -0,0 +1,155 @@
using Newtonsoft.Json;
using System.Threading.Tasks;
using WotBlitzStatisticsPro.Common.Model;
using WotBlitzStatisticsPro.WgApiClient;
namespace WotBlitzStatistics.GraphQl.Query
{
public class WotBlitzStatisticsQuery
{
private readonly IWargamingApiClient _wargamingApiClient;
public WotBlitzStatisticsQuery(IWargamingApiClient wargamingApiClient)
{
_wargamingApiClient = wargamingApiClient;
}
public async Task<PlayerAccountInfo> GetPlayerInfo(long accountId)
{
var account = await _wargamingApiClient.GetPlayerAccountInfo(accountId);
// ToDo: think abount mappers or resolvers
var accountStub = JsonConvert.DeserializeObject<PlayerAccountInfo>(AccountJson);
accountStub.AccountId = accountId;
return accountStub;
}
private const string AccountJson =
@"
{
""AccountId"": 90277267,
""NickName"": ""Mboga [XXX_L]"",
""AccountCreatedAt"": ""2018-01-20T11:17:35+03:00"",
""LastBattleTime"": ""2020-02-07T20:03:34+03:00"",
""Battles"": 10842,
""Wn7"": 1283.4155297487303,
""AvgTier"": 7.364785095000922,
""Winrate"": 54.75926950747095,
""AvgDamage"": 1266.5282235749862,
""AvgXp"": 663.4533296439771,
""Achievements"": [
{
""AchievementId"": ""medalHalonen"",
""Section"": ""epic"",
""Name"": ""Halonen's Medal (medalHalonen)\r\nDestroy at least 3 enemy vehicles with a tank destroyer in one battle."",
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalHalonen.png"",
""Count"": 3
},
{
""AchievementId"": ""medalLehvaslaiho"",
""Section"": ""epic"",
""Name"": ""Lehväslaiho's Medal (medalLehvaslaiho)\r\nDestroy 2 enemy vehicles with a medium tank in one battle."",
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalLehvaslaiho.png"",
""Count"": 47
},
{
""AchievementId"": ""markOfMastery"",
""Section"": ""battle"",
""Name"": ""Mastery badge: \nAce Tanker (markOfMastery)\r\nProve your mastery in controlling a vehicle. Earn more XP in a battle than the average highest XP of 99% of players who have fought in this vehicle for the previous 7 days."",
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/markOfMastery.png"",
""Count"": 73
},
{
""AchievementId"": ""medalKolobanov"",
""Section"": ""epic"",
""Name"": ""Kolobanov's Medal (medalKolobanov)\r\nStand alone against 3 enemy vehicles and win."",
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalKolobanov.png"",
""Count"": 6
},
{
""AchievementId"": ""medalLafayettePool"",
""Section"": ""epic"",
""Name"": ""Pool's Medal (medalLafayettePool)\r\nDestroy 6 enemy vehicles in one battle."",
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalLafayettePool.png"",
""Count"": 7
},
{
""AchievementId"": ""medalOrlik"",
""Section"": ""epic"",
""Name"": ""Orlik's Medal (medalOrlik)\r\nDestroy at least 3 enemy vehicles with a light tank in one battle."",
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalOrlik.png"",
""Count"": 4
},
{
""AchievementId"": ""medalRadleyWalters"",
""Section"": ""epic"",
""Name"": ""Radley-Walters's Medal (medalRadleyWalters)\r\nDestroy 5 enemy vehicles in one battle."",
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalRadleyWalters.png"",
""Count"": 33
},
{
""AchievementId"": ""medalOskin"",
""Section"": ""epic"",
""Name"": ""Oskin's Medal (medalOskin)\r\nDestroy 3 enemy vehicles with a medium tank in one battle."",
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalOskin.png"",
""Count"": 6
},
{
""AchievementId"": ""medalNikolas"",
""Section"": ""epic"",
""Name"": ""Nicols's Medal (medalNikolas)\r\nDestroy at least 4 enemy vehicles with a medium tank in one battle."",
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalNikolas.png"",
""Count"": 1
}
],
""TopTanks"": [
{
""TankId"": 59905,
""MarkOfMastery"": 4,
""Battles"": 769,
""WinRate"": 57.737321196358907672301690507,
""AvgDamage"": 1378.6579973992197659297789337,
""AvgXp"": 764.92847854356306892067620286,
""Name"": ""T-54 first prototype"",
""Tier"": 8,
""TierRoman"": ""VIII"",
""Nation"": ""ussr"",
""Type"": ""mediumTank"",
""IsPremium"": true,
""PreviewImageUrl"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/uploaded/vehicles/hd_thumbnail/R112_T54_45.png""
},
{
""TankId"": 13345,
""MarkOfMastery"": 4,
""Battles"": 662,
""WinRate"": 55.287009063444108761329305136,
""AvgDamage"": 1344.1555891238670694864048338,
""AvgXp"": 776.1495468277945619335347432,
""Name"": ""T26E4 SuperPershing"",
""Tier"": 8,
""TierRoman"": ""VIII"",
""Nation"": ""usa"",
""Type"": ""mediumTank"",
""IsPremium"": true,
""PreviewImageUrl"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/uploaded/vehicles/hd_thumbnail/T26_E4_SuperPershing.png""
},
{
""TankId"": 9217,
""MarkOfMastery"": 4,
""Battles"": 439,
""WinRate"": 55.808656036446469248291571754,
""AvgDamage"": 1493.7220956719817767653758542,
""AvgXp"": 737.12072892938496583143507973,
""Name"": ""IS-6"",
""Tier"": 8,
""TierRoman"": ""VIII"",
""Nation"": ""ussr"",
""Type"": ""heavyTank"",
""IsPremium"": true,
""PreviewImageUrl"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/uploaded/vehicles/hd_thumbnail/Object252.png""
}
]
}
";
}
}
+59
View File
@@ -0,0 +1,59 @@
using HotChocolate;
using HotChocolate.AspNetCore;
using HotChocolate.AspNetCore.Voyager;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using WotBlitzStatistics.GraphQl.Query;
using WotBlitzStatisticsPro.Common.Model;
using WotBlitzStatisticsPro.WgApiClient;
namespace WotBlitzStatistics.GraphQl
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
var wgApiConfig = new WargamingApiSettings();
Configuration.GetSection("WargamingApi").Bind(wgApiConfig);
services.AddSingleton<IWargamingApiSettings>(wgApiConfig);
services.AddHttpClient<IWargamingApiClient, WargamingApiClient>();
// Add GraphQL Services
services.AddGraphQL(sp => SchemaBuilder.New()
.AddServices(sp)
// Adds the authorize directive and
// enable the authorization middleware.
.AddAuthorizeDirectiveType()
.AddQueryType<WotBlitzStatisticsQueryType>()
//.AddMutationType<MutationType>()
//.AddSubscriptionType<SubscriptionType>()
.AddType<PlayerAccountInfo>()
.AddType<PlayerAchievementInfo>()
.AddType<PlayerTankInfo>()
.AddEnumType<MarkOfMastery>()
.Create());
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app
.UseGraphQL("/graphql")
.UsePlayground("/graphql")
.UseVoyager("/graphql")
;
}
}
}
@@ -0,0 +1,9 @@
using WotBlitzStatisticsPro.WgApiClient;
namespace WotBlitzStatistics.GraphQl
{
public class WargamingApiSettings : IWargamingApiSettings
{
public string ApplicationId { get; set; }
}
}
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="HotChocolate.AspNetCore" Version="10.3.5" />
<PackageReference Include="HotChocolate.AspNetCore.Authorization" Version="10.3.5" />
<PackageReference Include="HotChocolate.AspNetCore.Playground" Version="10.3.5" />
<PackageReference Include="HotChocolate.AspNetCore.Voyager" Version="10.3.5" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WotBlitzStatisticsPro.Common\WotBlitzStatisticsPro.Common.csproj" />
<ProjectReference Include="..\WotBlitzStatisticsPro.WgApiClient\WotBlitzStatisticsPro.WgApiClient.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
@@ -0,0 +1,14 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"WargamingApi": {
"ApplicationId": "e6bb7a6cd1b7da3ca5697f97072d2176"
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Blazor.Hosting;
namespace WotBlitzStatisticsPro.UI.Wasm
{
public class Program
public static class Program
{
public static void Main(string[] args)
{
@@ -0,0 +1,17 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using WotBlitzStatisticsPro.WgApiClient.Model;
namespace WotBlitzStatisticsPro.WgApiClient
{
public interface IWargamingApiClient
{
Task<Dictionary<long, string>> FindAccounts(string nickName,
RealmType realmType = RealmType.Ru,
RequestLanguage language = RequestLanguage.En);
Task<AccountInfo> GetPlayerAccountInfo(long accountId,
RealmType realmType = RealmType.Ru,
RequestLanguage language = RequestLanguage.En);
}
}
@@ -0,0 +1,7 @@
namespace WotBlitzStatisticsPro.WgApiClient
{
public interface IWargamingApiSettings
{
string ApplicationId { get; set; }
}
}
@@ -0,0 +1,124 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace WotBlitzStatisticsPro.WgApiClient.Model
{
public class AccountFullStatistics
{
///<summary>
/// Battles count
///</summary>
[JsonProperty("battles")]
public long? Battles { get; set; }
///<summary>
/// Capture points
///</summary>
[JsonProperty("capture_points")]
public long? CapturePoints { get; set; }
///<summary>
/// Total damage amount
///</summary>
[JsonProperty("damage_dealt")]
public long? DamageDealt { get; set; }
///<summary>
/// Total amount of received damage
///</summary>
[JsonProperty("damage_received")]
public long? DamageReceived { get; set; }
///<summary>
/// Dropped capture points
///</summary>
[JsonProperty("dropped_capture_points")]
public long? DroppedCapturePoints { get; set; }
///<summary>
/// Total amount of frags
///</summary>
[JsonProperty("frags")]
public long? Frags { get; set; }
///<summary>
/// Total amount of fras grater ten 8 lvl
///</summary>
[JsonProperty("frags8p")]
public long? Frags8P { get; set; }
///<summary>
/// Total amount of hits
///</summary>
[JsonProperty("hits")]
public long? Hits { get; set; }
///<summary>
/// Total amount of losses
///</summary>
[JsonProperty("losses")]
public long? Losses { get; set; }
///<summary>
/// Max frags per battle
///</summary>
[JsonProperty("max_frags")]
public long? MaxFrags { get; set; }
///<summary>
/// Tank id, which kills max frags per battle
///</summary>
[JsonProperty("max_frags_tank_id")]
public long? MaxFragsTankId { get; set; }
///<summary>
/// Max experience per battle
///</summary>
[JsonProperty("max_xp")]
public long? MaxXp { get; set; }
///<summary>
/// Tank Id which created max experiense per battle
///</summary>
[JsonProperty("max_xp_tank_id")]
public long? MaxXpTankId { get; set; }
///<summary>
/// Totla shots count
///</summary>
[JsonProperty("shots")]
public long? Shots { get; set; }
///<summary>
/// Totla count of spotted vehicles
///</summary>
[JsonProperty("spotted")]
public long? Spotted { get; set; }
///<summary>
/// Total count of survived battles
///</summary>
[JsonProperty("survived_battles")]
public long? SurvivedBattles { get; set; }
///<summary>
/// Total count of suvived and winned battles
///</summary>
[JsonProperty("win_and_survived")]
public long? WinAndSurvived { get; set; }
///<summary>
/// Total wins count
///</summary>
[JsonProperty("wins")]
public long? Wins { get; set; }
///<summary>
/// Total amount of experience
///</summary>
[JsonProperty("xp")]
public long? Xp { get; set; }
}
}
@@ -0,0 +1,49 @@
using Newtonsoft.Json;
namespace WotBlitzStatisticsPro.WgApiClient.Model
{
public class AccountInfo
{
///<summary>
/// Player account identifier
///</summary>
[JsonProperty("account_id")]
public long? AccountId { get; set; }
///<summary>
/// Account creation date
///</summary>
[JsonProperty("created_at")]
public int? CreatedAt { get; set; }
///<summary>
/// Last battle time
///</summary>
[JsonProperty("last_battle_time")]
public int? LastBattleTime { get; set; }
///<summary>
/// Player's nick
///</summary>
[JsonProperty("nickname")]
public string Nickname { get; set; }
///<summary>
/// Player information update date
///</summary>
[JsonProperty("updated_at")]
public int? UpdatedAt { get; set; }
///<summary>
/// Private account data
///</summary>
[JsonProperty("private")]
public AccountPrivateInfo Private { get; set; }
///<summary>
/// Player's statistics
///</summary>
[JsonProperty("statistics")]
public AccountStatistics Statistics { get; set; }
}
}
@@ -0,0 +1,69 @@
using Newtonsoft.Json;
namespace WotBlitzStatisticsPro.WgApiClient.Model
{
public class AccountPrivateInfo
{
///<summary>
/// Account ban info
///</summary>
[JsonProperty("ban_info")]
public string BanInfo { get; set; }
///<summary>
/// Account ban expiration date
///</summary>
[JsonProperty("ban_time")]
public int? BanTime { get; set; }
///<summary>
/// Total time in battles until destroy in seconds
///</summary>
[JsonProperty("battle_life_time")]
public int? BattleLifeTimeInSeconds { get; set; }
///<summary>
/// Amount of credits
///</summary>
[JsonProperty("credits")]
public long? Credits { get; set; }
///<summary>
/// Free experience
///</summary>
[JsonProperty("free_xp")]
public long? FreeXp { get; set; }
///<summary>
///Amount of gold
///</summary>
[JsonProperty("gold")]
public long? Gold { get; set; }
///<summary>
/// Is player has premium account
///</summary>
[JsonProperty("is_premium")]
public bool IsPremium { get; set; }
///<summary>
/// Premium accunt expiration time
///</summary>
[JsonProperty("premium_expires_at")]
private int? PremiumExpiresAt { get; set; }
///<summary>
///Группы контактов.
///Дополнительное поле.
///</summary>
[JsonProperty("grouped_contacts")]
public AccountPrivateInfoGroupedContacts GroupedContacts { get; set; }
///<summary>
///Ограничения аккаунта
///</summary>
[JsonProperty("restrictions")]
public AccountPrivateInfoRestrictions Restrictions { get; set; }
}
}
@@ -0,0 +1,26 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace WotBlitzStatisticsPro.WgApiClient.Model
{
public class AccountPrivateInfoGroupedContacts
{
///<summary>
/// Blocked accountIds
///</summary>
[JsonProperty("blocked")]
public int[] Blocked { get; set; }
///<summary>
/// Groups
///</summary>
[JsonProperty("groups")]
public Dictionary<string, string> Groups { get; set; }
///<summary>
/// Ungrouped accountIds
///</summary>
[JsonProperty("ungrouped")]
public int[] Ungrouped { get; set; }
}
}
@@ -0,0 +1,13 @@
using Newtonsoft.Json;
namespace WotBlitzStatisticsPro.WgApiClient.Model
{
public class AccountPrivateInfoRestrictions
{
///<summary>
/// Clan chat ban time
///</summary>
[JsonProperty("chat_ban_time")]
public int? ChatBanTime { get; set; }
}
}
@@ -0,0 +1,20 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace WotBlitzStatisticsPro.WgApiClient.Model
{
public class AccountStatistics
{
///<summary>
/// Amount of destroyed by player tanks.
///</summary>
[JsonProperty("frags")]
public Dictionary<string, string> Frags { get; set; }
///<summary>
/// Full player's statistics
///</summary>
[JsonProperty("all")]
public AccountFullStatistics All { get; set; }
}
}
@@ -0,0 +1,11 @@
namespace WotBlitzStatisticsPro.WgApiClient.Model
{
public enum RealmType
{
Ru,
Eu,
Na,
Asia
}
}
@@ -0,0 +1,9 @@
namespace WotBlitzStatisticsPro.WgApiClient.Model
{
public enum RequestLanguage
{
Ru,
En,
De
}
}
@@ -0,0 +1,40 @@
using Newtonsoft.Json;
namespace WotBlitzStatisticsPro.WgApiClient
{
internal class ResponseBody<T>
{
[JsonProperty("status")]
public string Status { get; set; }
[JsonProperty("meta")]
public Meta Meta { get; set; }
[JsonProperty("data")]
public T Data { get; set; }
[JsonProperty("error")]
public Error Error { get; set; }
}
internal class Meta
{
[JsonProperty("count")]
public int Count { get; set; }
}
internal class Error
{
[JsonProperty("field")]
public string Field { get; set; }
[JsonProperty("message")]
public string Message { get; set; }
[JsonProperty("code")]
public string Code { get; set; }
[JsonProperty("value")]
public string Value { get; set; }
}
}
@@ -0,0 +1,85 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using WotBlitzStatisticsPro.WgApiClient.Model;
namespace WotBlitzStatisticsPro.WgApiClient
{
public class WagramingApiClientBase
{
private Dictionary<RealmType, string> _blitzApiUrls = new Dictionary<RealmType, string>();
private Dictionary<RealmType, string> _wotApiUrls = new Dictionary<RealmType, string>();
private readonly HttpClient _httpClient;
private readonly IWargamingApiSettings _wargamingApiSettings;
public WagramingApiClientBase(
HttpClient httpClient,
IWargamingApiSettings wargamingApiSettings)
{
_httpClient = httpClient;
_wargamingApiSettings = wargamingApiSettings;
_blitzApiUrls[RealmType.Eu] = "https://api.wotblitz.eu/wotb/";
_blitzApiUrls[RealmType.Ru] = "https://api.wotblitz.ru/wotb/";
_blitzApiUrls[RealmType.Na] = "https://api.wotblitz.com/wotb/";
_blitzApiUrls[RealmType.Asia] = "https://api.wotblitz.asia/wotb/";
_wotApiUrls[RealmType.Eu] = "https://api.worldoftanks.eu/wot/";
_wotApiUrls[RealmType.Ru] = "https://api.worldoftanks.ru/wot/";
_wotApiUrls[RealmType.Na] = "https://api.worldoftanks.com/wot/";
_wotApiUrls[RealmType.Asia] = "https://api.worldoftanks.asia/wot/";
}
protected async Task<T> GetFromBlitzApi<T>(
RealmType realmType,
RequestLanguage language,
string method,
params string[] queryParameters)
{
string uri = GetUri(realmType, language, method, queryParameters);
_httpClient.DefaultRequestHeaders.Accept.Clear();
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await _httpClient.GetAsync(uri);
response.EnsureSuccessStatusCode();
var responseString = await response.Content.ReadAsStringAsync();
var responseBody = JsonConvert.DeserializeObject<ResponseBody<T>>(responseString);
if (responseBody.Status == "ok")
{
return responseBody.Data;
}
if (responseBody.Status == "error")
{
var error = responseBody.Error;
var message = $"Field:{error.Field} Message:{error.Message} Value:{error.Value} Code:{error.Code}";
throw new ArgumentException(message);
}
return default(T);
}
private string GetUri(RealmType realmType, RequestLanguage language, string method, string[] queryParameters)
{
var uri = new StringBuilder($"{_blitzApiUrls[realmType]}{method}");
uri.Append("?application_id=")
.Append(_wargamingApiSettings.ApplicationId)
.Append("&language=")
.Append(language.ToString().ToLower());
if (queryParameters != null)
{
foreach (var param in queryParameters)
{
uri.Append("&")
.Append(param);
}
}
return uri.ToString();
}
}
}
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
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)
{
}
public Task<Dictionary<long, string>> FindAccounts(string nickName,
RealmType realmType = RealmType.Ru,
RequestLanguage language = RequestLanguage.En)
{
throw new NotImplementedException();
}
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/",
$"account_id={accountId}");
return account[accountId.ToString()];
}
}
}
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
</Project>
+12
View File
@@ -11,6 +11,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WotBlitzStatisticsPro.Commo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WotBlitzStatisticsPro.UI.Wasm", "WotBlitzStatisticsPro.Wasm\WotBlitzStatisticsPro.UI.Wasm.csproj", "{57E96A78-BDA4-4023-9965-EC755C68D033}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WotBlitzStatistics.GraphQl", "WotBlitzStatistics.GraphQl\WotBlitzStatistics.GraphQl.csproj", "{9B268E2D-38A5-4755-BAEC-BAF1DC7DCEC7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WotBlitzStatisticsPro.WgApiClient", "WotBlitzStatisticsPro.WgApiClient\WotBlitzStatisticsPro.WgApiClient.csproj", "{E1AB7997-C2A1-433B-A4F5-F8E9C4B73515}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -33,6 +37,14 @@ Global
{57E96A78-BDA4-4023-9965-EC755C68D033}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57E96A78-BDA4-4023-9965-EC755C68D033}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57E96A78-BDA4-4023-9965-EC755C68D033}.Release|Any CPU.Build.0 = Release|Any CPU
{9B268E2D-38A5-4755-BAEC-BAF1DC7DCEC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B268E2D-38A5-4755-BAEC-BAF1DC7DCEC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B268E2D-38A5-4755-BAEC-BAF1DC7DCEC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B268E2D-38A5-4755-BAEC-BAF1DC7DCEC7}.Release|Any CPU.Build.0 = Release|Any CPU
{E1AB7997-C2A1-433B-A4F5-F8E9C4B73515}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1AB7997-C2A1-433B-A4F5-F8E9C4B73515}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1AB7997-C2A1-433B-A4F5-F8E9C4B73515}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1AB7997-C2A1-433B-A4F5-F8E9C4B73515}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE