Updated Chart Fetch functions in order to create a more generic template
This commit is contained in:
@ -1,9 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using EFB.Models.JSON;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Newtonsoft.Json;
|
||||
using EFB.Models;
|
||||
using EFB.Models.JSON;
|
||||
using EFB.Sessions;
|
||||
using EFB.Controllers.Form;
|
||||
using EFB.Controllers.API;
|
||||
|
||||
namespace EFB.Models
|
||||
{
|
||||
@ -41,6 +50,29 @@ namespace EFB.Models
|
||||
}
|
||||
return new Chart[]{};
|
||||
}
|
||||
|
||||
public static async Task<ChartList> FetchAsync(string ICAO){
|
||||
Console.WriteLine("Start");
|
||||
if (FormAuthenticator.ValidateICAOCode(ICAO))
|
||||
{
|
||||
APIInterface API = new APIInterface();
|
||||
Dictionary <string, string> headerData = new Dictionary<string, string>();
|
||||
headerData.Add("referer", "luke-else.co.uk");
|
||||
|
||||
Dictionary<string, string> formData = new Dictionary<string, string>();
|
||||
|
||||
formData.Add("token", Environment.GetEnvironmentVariable("ChartFoxAPIKey", EnvironmentVariableTarget.User));
|
||||
FormUrlEncodedContent body = new FormUrlEncodedContent(formData);
|
||||
|
||||
//make Charts request
|
||||
var requestCharts = await API.Post<ChartResponse>($"https://chartfox.org/api/charts/grouped/{ICAO}", headerData, body);
|
||||
Console.WriteLine("End");
|
||||
return requestCharts.Result.Response;
|
||||
}else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Pinned
|
||||
|
Reference in New Issue
Block a user