2021-06-04 23:04:03 +02:00
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2021-04-02 17:27:11 +02:00
|
|
|
using HotChocolate;
|
2021-04-02 13:20:59 +02:00
|
|
|
using HotChocolate.AspNetCore.Authorization;
|
|
|
|
|
using HotChocolate.Types;
|
2020-05-21 17:53:01 +02:00
|
|
|
using WotBlitzStatisticsPro.Common.Model;
|
2020-05-23 11:43:14 +02:00
|
|
|
using WotBlitzStatisticsPro.Logic;
|
2020-05-21 17:53:01 +02:00
|
|
|
|
2020-05-23 11:43:14 +02:00
|
|
|
namespace WotBlitzStatisticsPro.GraphQl.Mutation
|
2020-05-21 17:53:01 +02:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// WotBlitzStatistics Mutations
|
|
|
|
|
/// </summary>
|
2021-04-02 13:20:59 +02:00
|
|
|
[ExtendObjectType(Name = "Mutation")]
|
2020-05-21 17:53:01 +02:00
|
|
|
public class WotBlitzStatisticsMutation
|
|
|
|
|
{
|
|
|
|
|
private readonly IWargamingDictionaries _wargamingDictionaries;
|
2020-07-19 13:04:31 +02:00
|
|
|
private readonly IWargamingAccounts _wargamingAccounts;
|
2020-05-21 17:53:01 +02:00
|
|
|
|
2020-07-19 13:04:31 +02:00
|
|
|
public WotBlitzStatisticsMutation(IWargamingDictionaries wargamingDictionaries,
|
|
|
|
|
IWargamingAccounts wargamingAccounts)
|
2020-05-21 17:53:01 +02:00
|
|
|
{
|
|
|
|
|
_wargamingDictionaries = wargamingDictionaries;
|
2020-07-19 13:04:31 +02:00
|
|
|
_wargamingAccounts = wargamingAccounts;
|
2020-05-21 17:53:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates the necessary dictionaries in database.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="updateDictionariesRequest">Determines what dictionaries should be updated.</param>
|
|
|
|
|
/// <returns>Information about what was updated.</returns>
|
2021-04-02 13:20:59 +02:00
|
|
|
[Authorize(Policy = "GithubMbogaOnly")]
|
2020-05-21 17:53:01 +02:00
|
|
|
public Task<UpdateDictionariesResponseItem[]> UpdateDictionaries(
|
|
|
|
|
UpdateDictionariesRequest updateDictionariesRequest)
|
|
|
|
|
{
|
|
|
|
|
return _wargamingDictionaries.UpdateDictionaries(updateDictionariesRequest);
|
|
|
|
|
}
|
2020-07-19 13:04:31 +02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gathers all account information
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="realmType">Account region</param>
|
|
|
|
|
/// <param name="accountId">AccountId</param>
|
|
|
|
|
/// <param name="requestLanguage">Request language</param>
|
2021-04-02 17:27:11 +02:00
|
|
|
/// <param name="wgToken">Wargaming authentication token</param>
|
2020-07-19 13:04:31 +02:00
|
|
|
/// <returns></returns>
|
2021-06-04 23:04:03 +02:00
|
|
|
public Task<DateTime> GatherAccountInformation(
|
2021-04-02 17:27:11 +02:00
|
|
|
RealmType realmType,
|
|
|
|
|
long accountId,
|
|
|
|
|
RequestLanguage requestLanguage,
|
|
|
|
|
[GlobalState("WgToken")] string wgToken)
|
2020-07-19 13:04:31 +02:00
|
|
|
{
|
2021-04-02 17:27:11 +02:00
|
|
|
return _wargamingAccounts.GatherAndSaveAccountInformation(realmType, accountId, requestLanguage, wgToken);
|
2020-07-19 13:04:31 +02:00
|
|
|
}
|
2020-05-21 17:53:01 +02:00
|
|
|
}
|
|
|
|
|
}
|