Move mappings and AES to Fortnite Central

This commit is contained in:
GMatrixGames
2022-07-27 22:15:55 -04:00
parent ffedb2be90
commit 88383c30f0
6 changed files with 55 additions and 38 deletions

View File

@@ -79,7 +79,7 @@ public class AesManagerViewModel : ViewModel
new()
{
Key = key,
FileName = collection[e.CollectionIndex].Name,
Name = collection[e.CollectionIndex].Name,
Guid = collection[e.CollectionIndex].Guid.ToString()
}
};
@@ -97,7 +97,7 @@ public class AesManagerViewModel : ViewModel
_keysFromSettings.DynamicKeys.Add(new DynamicKey
{
Key = key,
FileName = collection[e.CollectionIndex].Name,
Name = collection[e.CollectionIndex].Name,
Guid = collection[e.CollectionIndex].Guid.ToString()
});
}

View File

@@ -17,6 +17,7 @@ public class ApiEndpointViewModel
public FortniteApiEndpoint FortniteApi { get; }
public ValorantApiEndpoint ValorantApi { get; }
public FortniteCentralApiEndpoint CentralApi { get; }
public BenbotApiEndpoint BenbotApi { get; }
public EpicApiEndpoint EpicApi { get; }
public FModelApi FModelApi { get; }
@@ -25,6 +26,7 @@ public class ApiEndpointViewModel
{
FortniteApi = new FortniteApiEndpoint(_client);
ValorantApi = new ValorantApiEndpoint(_client);
CentralApi = new FortniteCentralApiEndpoint(_client);
BenbotApi = new BenbotApiEndpoint(_client);
EpicApi = new EpicApiEndpoint(_client);
FModelApi = new FModelApi(_client);

View File

@@ -15,38 +15,6 @@ public class BenbotApiEndpoint : AbstractApiProvider
{
}
public async Task<AesResponse> GetAesKeysAsync(CancellationToken token)
{
var request = new FRestRequest("https://benbot.app/api/v2/aes")
{
OnBeforeDeserialization = resp => { resp.ContentType = "application/json; charset=utf-8"; }
};
var response = await _client.ExecuteAsync<AesResponse>(request, token).ConfigureAwait(false);
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, response.ResponseUri?.OriginalString);
return response.Data;
}
public AesResponse GetAesKeys(CancellationToken token)
{
return GetAesKeysAsync(token).GetAwaiter().GetResult();
}
public async Task<MappingsResponse[]> GetMappingsAsync(CancellationToken token)
{
var request = new FRestRequest("https://benbot.app/api/v1/mappings")
{
OnBeforeDeserialization = resp => { resp.ContentType = "application/json; charset=utf-8"; }
};
var response = await _client.ExecuteAsync<MappingsResponse[]>(request, token).ConfigureAwait(false);
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, response.ResponseUri?.OriginalString);
return response.Data;
}
public MappingsResponse[] GetMappings(CancellationToken token)
{
return GetMappingsAsync(token).GetAwaiter().GetResult();
}
public async Task<Dictionary<string, Dictionary<string, string>>> GetHotfixesAsync(CancellationToken token, string language = "en-US")
{
var request = new FRestRequest("https://benbot.app/api/v1/hotfixes")

View File

@@ -0,0 +1,47 @@
using System.Threading;
using System.Threading.Tasks;
using FModel.Framework;
using FModel.ViewModels.ApiEndpoints.Models;
using RestSharp;
using Serilog;
namespace FModel.ViewModels.ApiEndpoints;
public class FortniteCentralApiEndpoint : AbstractApiProvider
{
public FortniteCentralApiEndpoint(RestClient client) : base(client)
{
}
public async Task<AesResponse> GetAesKeysAsync(CancellationToken token)
{
var request = new FRestRequest("https://fortnitecentral.gmatrixgames.ga/api/v1/aes")
{
OnBeforeDeserialization = resp => { resp.ContentType = "application/json; charset=utf-8"; }
};
var response = await _client.ExecuteAsync<AesResponse>(request, token).ConfigureAwait(false);
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, response.ResponseUri?.OriginalString);
return response.Data;
}
public AesResponse GetAesKeys(CancellationToken token)
{
return GetAesKeysAsync(token).GetAwaiter().GetResult();
}
public async Task<MappingsResponse[]> GetMappingsAsync(CancellationToken token)
{
var request = new FRestRequest("https://fortnitecentral.gmatrixgames.ga/api/v1/mappings")
{
OnBeforeDeserialization = resp => { resp.ContentType = "application/json; charset=utf-8"; }
};
var response = await _client.ExecuteAsync<MappingsResponse[]>(request, token).ConfigureAwait(false);
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, response.ResponseUri?.OriginalString);
return response.Data;
}
public MappingsResponse[] GetMappings(CancellationToken token)
{
return GetMappingsAsync(token).GetAwaiter().GetResult();
}
}

View File

@@ -17,7 +17,7 @@ public class AesResponse
[DebuggerDisplay("{" + nameof(Key) + "}")]
public class DynamicKey
{
[J("fileName")] public string FileName { get; set; }
[J("name")] public string Name { get; set; }
[J("guid")] public string Guid { get; set; }
[J("key")] public string Key { get; set; }
}
}

View File

@@ -296,7 +296,7 @@ public class CUE4ParseViewModel : ViewModel
{
await _threadWorkerView.Begin(cancellationToken =>
{
var aes = _apiEndpointView.BenbotApi.GetAesKeys(cancellationToken);
var aes = _apiEndpointView.CentralApi.GetAesKeys(cancellationToken);
if (aes?.MainKey == null && aes?.DynamicKeys == null && aes?.Version == null) return;
UserSettings.Default.AesKeys[Game] = aes;
@@ -333,7 +333,7 @@ public class CUE4ParseViewModel : ViewModel
else
{
var mappingsFolder = Path.Combine(UserSettings.Default.OutputDirectory, ".data");
var mappings = _apiEndpointView.BenbotApi.GetMappings(cancellationToken);
var mappings = _apiEndpointView.CentralApi.GetMappings(cancellationToken);
if (mappings is { Length: > 0 })
{
foreach (var mapping in mappings)