24 lines
766 B
C#
24 lines
766 B
C#
using System.Text.Json;
|
|
using System.Text;
|
|
using e_suite.API.Common.models;
|
|
using e_suite.CustomerApi.Helper;
|
|
using e_suite.CustomerApi.models;
|
|
|
|
namespace e_suite.CustomerApi;
|
|
|
|
public class Authentication
|
|
{
|
|
public async Task Login(Login login)
|
|
{
|
|
var client = HttpHelper.CreateClient();
|
|
|
|
client.BaseAddress = ApiSettings.Instance.BaseUrl;
|
|
|
|
var json = JsonSerializer.Serialize(login);
|
|
var body = new StringContent(json, Encoding.UTF8, "application/json");
|
|
var response = await client.PostAsync("Authentication/login", body);
|
|
|
|
var result = JsonSerializer.Deserialize<SuccessfulLogin>(await response.Content.ReadAsStreamAsync());
|
|
ApiSettings.Instance.Token = result.Token;
|
|
}
|
|
} |