mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-21 02:17:20 +02:00
feat: Logun url query implementation
This commit is contained in:
1 parent
806268df48
commit
11486b7303
6 files changed
+67
-3
No files matched your search
@@ -0,0 +1,10 @@
|
||||
using System.Threading.Tasks;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.WgApiClient
|
||||
{
|
||||
public interface IWargamingAuthenticationClient
|
||||
{
|
||||
string LoginUrl(RealmType realm);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ namespace WotBlitzStatisticsPro.WgApiClient
|
||||
string method,
|
||||
params string[] queryParameters) where T: class
|
||||
{
|
||||
string uri = GetUri(realmType, language, method, queryParameters);
|
||||
string uri = GetBlitzUri(realmType, language, method, queryParameters);
|
||||
|
||||
_httpClient.DefaultRequestHeaders.Accept.Clear();
|
||||
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
@@ -75,7 +75,23 @@ namespace WotBlitzStatisticsPro.WgApiClient
|
||||
}
|
||||
}
|
||||
|
||||
private string GetUri(RealmType realmType, RequestLanguage language, string method, string[] queryParameters)
|
||||
protected string GetWotUri(RealmType realmType, string method, string[]? queryParameters)
|
||||
{
|
||||
var uri = new StringBuilder($"{_wotApiUrls[realmType]}{method}");
|
||||
uri.Append("?application_id=")
|
||||
.Append(_wargamingApiSettings.ApplicationId);
|
||||
if (queryParameters != null)
|
||||
{
|
||||
foreach (var param in queryParameters)
|
||||
{
|
||||
uri.Append("&")
|
||||
.Append(param);
|
||||
}
|
||||
}
|
||||
return uri.ToString();
|
||||
}
|
||||
|
||||
private string GetBlitzUri(RealmType realmType, RequestLanguage language, string method, string[] queryParameters)
|
||||
{
|
||||
var uri = new StringBuilder($"{_blitzApiUrls[realmType]}{method}");
|
||||
uri.Append("?application_id=")
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace WotBlitzStatisticsPro.WgApiClient
|
||||
public class WargamingApiClient : WagramingApiClientBase,
|
||||
IWargamingApiClient,
|
||||
IWargamingDictionariesApiClient,
|
||||
IWargamingTanksApiClient
|
||||
IWargamingTanksApiClient,
|
||||
IWargamingAuthenticationClient
|
||||
{
|
||||
public WargamingApiClient(
|
||||
HttpClient httpClient,
|
||||
@@ -206,6 +207,13 @@ namespace WotBlitzStatisticsPro.WgApiClient
|
||||
$"account_id={accountId}").ConfigureAwait(false);
|
||||
return tanks?[accountId.ToString()] ?? new List<WotAccountTanksStatistics>();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Authentication
|
||||
public string LoginUrl(RealmType realm)
|
||||
{
|
||||
return GetWotUri(realm, "auth/login/", null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user