mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-29 21:30:05 +01:00
ClanInfo added
This commit is contained in:
1 parent
6c2104f6d7
commit
1d13507aa7
6 files changed
+74
-4
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
using HotChocolate.Types;
|
using HotChocolate.Types;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using WotBlitzStatisticsPro.WgApiClient;
|
||||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||||
|
|
||||||
namespace WotBlitzStatistics.GraphQl.ObjectTypes
|
namespace WotBlitzStatistics.GraphQl.ObjectTypes
|
||||||
@@ -9,7 +10,13 @@ namespace WotBlitzStatistics.GraphQl.ObjectTypes
|
|||||||
protected override void Configure(IObjectTypeDescriptor<AccountInfo> descriptor)
|
protected override void Configure(IObjectTypeDescriptor<AccountInfo> descriptor)
|
||||||
{
|
{
|
||||||
descriptor.Field(a => a.Private).Ignore();
|
descriptor.Field(a => a.Private).Ignore();
|
||||||
descriptor.Field("Tanks").Type<NonNullType<ListType<StringType>>>()
|
descriptor.Field("clanInfo")
|
||||||
|
//.Argument("accountId", a => a.Type<NonNullType<LongType>>())
|
||||||
|
//.Type<ClanAccountInfo>()
|
||||||
|
.Resolver(c => c.Service<IWargamingApiClient>()
|
||||||
|
.GetPlayerClanInfo(c.Parent<AccountInfo>().AccountId.Value));
|
||||||
|
|
||||||
|
descriptor.Field("tanks").Type<NonNullType<ListType<StringType>>>()
|
||||||
.Resolver(c => new List<string> { "Fuck yeah" });
|
.Resolver(c => new List<string> { "Fuck yeah" });
|
||||||
// Add resolver for Clan, Tanks, Achievements
|
// Add resolver for Clan, Tanks, Achievements
|
||||||
// https://hotchocolate.io/docs/schema-object-type
|
// https://hotchocolate.io/docs/schema-object-type
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
namespace WotBlitzStatistics.GraphQl.ObjectTypes
|
using HotChocolate.Types;
|
||||||
|
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||||
|
|
||||||
|
namespace WotBlitzStatistics.GraphQl.ObjectTypes
|
||||||
{
|
{
|
||||||
public class PlayerClanInfoObjectType
|
public class PlayerClanInfoObjectType : ObjectType<ClanAccountInfo>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,6 +44,7 @@ namespace WotBlitzStatistics.GraphQl
|
|||||||
.AddType<PlayerAccountInfoObjectType>()
|
.AddType<PlayerAccountInfoObjectType>()
|
||||||
.AddType<AccountStatistics>()
|
.AddType<AccountStatistics>()
|
||||||
.AddType<AccountFullStatistics>()
|
.AddType<AccountFullStatistics>()
|
||||||
|
.AddType<PlayerClanInfoObjectType>()
|
||||||
//.AddEnumType<MarkOfMastery>()
|
//.AddEnumType<MarkOfMastery>()
|
||||||
.Create());
|
.Create());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,5 +13,9 @@ namespace WotBlitzStatisticsPro.WgApiClient
|
|||||||
Task<AccountInfo> GetPlayerAccountInfo(long accountId,
|
Task<AccountInfo> GetPlayerAccountInfo(long accountId,
|
||||||
RealmType realmType = RealmType.Ru,
|
RealmType realmType = RealmType.Ru,
|
||||||
RequestLanguage language = RequestLanguage.En);
|
RequestLanguage language = RequestLanguage.En);
|
||||||
|
|
||||||
|
Task<ClanAccountInfo> GetPlayerClanInfo(long accountId,
|
||||||
|
RealmType realmType = RealmType.Ru,
|
||||||
|
RequestLanguage language = RequestLanguage.En);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace WotBlitzStatisticsPro.WgApiClient.Model
|
||||||
|
{
|
||||||
|
public class ClanAccountInfo
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
/// AccountId
|
||||||
|
///</summary>
|
||||||
|
[JsonProperty("account_id")]
|
||||||
|
public long? AccountId { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Account nick
|
||||||
|
///</summary>
|
||||||
|
[JsonProperty("account_name")]
|
||||||
|
public string AccountName { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// ClanId
|
||||||
|
///</summary>
|
||||||
|
[JsonProperty("clan_id")]
|
||||||
|
public long? ClanId { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Date of joining clan
|
||||||
|
///</summary>
|
||||||
|
[JsonProperty("joined_at")]
|
||||||
|
public int? JoinedAt { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Player clan role
|
||||||
|
///</summary>
|
||||||
|
[JsonProperty("role")]
|
||||||
|
public string Role { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ namespace WotBlitzStatisticsPro.WgApiClient
|
|||||||
{
|
{
|
||||||
public class WargamingApiClient : WagramingApiClientBase, IWargamingApiClient
|
public class WargamingApiClient : WagramingApiClientBase, IWargamingApiClient
|
||||||
{
|
{
|
||||||
|
// ToDo: AddLogging
|
||||||
public WargamingApiClient(
|
public WargamingApiClient(
|
||||||
HttpClient httpClient,
|
HttpClient httpClient,
|
||||||
IWargamingApiSettings wargamingApiSettings) : base(httpClient, wargamingApiSettings)
|
IWargamingApiSettings wargamingApiSettings) : base(httpClient, wargamingApiSettings)
|
||||||
@@ -29,8 +30,24 @@ namespace WotBlitzStatisticsPro.WgApiClient
|
|||||||
realmType,
|
realmType,
|
||||||
language,
|
language,
|
||||||
"account/info/",
|
"account/info/",
|
||||||
$"account_id={accountId}");
|
$"account_id={accountId}").ConfigureAwait(false);
|
||||||
return account[accountId.ToString()];
|
return account[accountId.ToString()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user