Code cleanup

This commit is contained in:
2023-07-12 20:57:48 +02:00
parent 632f5ab236
commit 9c6716bc9d
10 changed files with 622 additions and 470 deletions

View File

@@ -0,0 +1,84 @@
// 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);
}
}
}