This repository has been archived on 2025-05-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
cardmarketbot/ConsoleApp3/LexofficeService.cs
2023-07-12 20:57:48 +02:00

84 lines
2.3 KiB
C#

// See https://aka.ms/new-console-template for more information
using System.Text;
using ConsoleApp3.DataContracts;
using Newtonsoft.Json;
/*
*
* referalPage: /de/OnePiece
username: Skywalkerex
userPassword: Magnatpower310!!
/de/OnePiece/PostGetAction/User_Login
curbpJUJmtup1t.Tq0awbHIhIRwhzMW7vrsWxLAJu.pI9X4r
*/
namespace CardmarketBot
{
class LexofficeService
{
private readonly HttpClient _client;
private readonly Random _random = new();
public LexofficeService()
{
_client = new HttpClient
{
DefaultRequestHeaders =
{
{ "Authorization", "Bearer curbpJUJmtup1t.Tq0awbHIhIRwhzMW7vrsWxLAJu.pI9X4r" },
{ "Accept", "application/json" }
}
};
}
public void test()
{
var d = GetInvoiceAsync("d47936c1-71c6-4e22-b394-3630d7354ebf");
var m = d.Result;
Console.WriteLine(m);
}
public void m(Invoice invoice)
{
}
public async void WriteInvoice(Invoice invoice)
{
var jsonSerializerSettings = new JsonSerializerSettings
{
MissingMemberHandling = MissingMemberHandling.Ignore
};
var s = JsonConvert.SerializeObject(invoice, jsonSerializerSettings);
var content = new StringContent(invoice.ToString(), Encoding.UTF8, "application/json");
var uri = LexofficeApiAddressesBuilder.CreateInvoice();
var result = await _client.PostAsync(uri, content);
Console.WriteLine(result.Content);
}
private async Task<Invoice> GetInvoiceAsync(string id)
{
var uri = LexofficeApiAddressesBuilder.InvoiceUri(id);
var response = await _client.GetAsync(uri).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
var contents = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var jsonSerializerSettings = new JsonSerializerSettings
{
MissingMemberHandling = MissingMemberHandling.Ignore
};
return JsonConvert.DeserializeObject<Invoice>(contents, jsonSerializerSettings);
}
}
}