using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace ScoreTracker.API
{
internal class Request
{
internal static readonly HttpClient HttpClient = new HttpClient();
///
/// Persist the given headers for all future requests
///
/// the headers to persist
public static void PersistHeaders(Dictionary headers)
{
HttpClient.DefaultRequestHeaders.Clear(); // Clear existing headers
foreach (var header in headers)
{
HttpClient.DefaultRequestHeaders.Add(header.Key, header.Value);
}
}
///
/// Create a POST request to the given URL with the given data
///
/// the url to post to
/// the data to post
/// whether to check for authentication
/// the task
public static async Task PostJsonAsync(string url, Dictionary