Files
BeWoPlaner/Service/ServiceProxy/XRechnungApiClient.cs

61 lines
1.5 KiB
C#
Raw Normal View History

using BeWo.Data.Entities;
using BeWo.Service.Core;
using BeWo.Service.DCEntityMapper;
using BS.Shared.Core;
using BS.Shared.Core.Facade;
using BS.Shared.DataContracts.Feature.AI;
2025-06-05 14:03:55 +02:00
using BS.Shared.DataContracts.Invoicing.XRechnung;
2025-06-10 14:29:34 +02:00
using BS.Shared.DataContracts.MikePHPContracts;
using DevExpress.XtraRichEdit.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
2025-06-05 14:03:55 +02:00
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
namespace BeWo.Service.ServiceProxy
{
public class XRechnungApiClient
{
private readonly JsonHttpClientFacade _JsonHttpClientFacade;
2025-06-05 14:03:55 +02:00
public XRechnungApiClient() : this(MergedConfig.GetSetting(WebConfigSetting.XRechnungApiUrl)) { }
public XRechnungApiClient(string base_url)
{
_JsonHttpClientFacade = new JsonHttpClientFacade(base_url);
}
2025-06-10 14:29:34 +02:00
public ApiResponse<byte[]> Create(object xrechnung)
2025-06-05 14:03:55 +02:00
{
_JsonHttpClientFacade.JsonObject = new
{
json = xrechnung
};
var bytes = _JsonHttpClientFacade.SendAsync("create").GetAwaiter().GetResult();
2025-06-10 14:29:34 +02:00
var response = ApiResponse<byte[]>.Parse(bytes);
2025-06-05 14:03:55 +02:00
return response;
}
2025-06-10 14:29:34 +02:00
public ApiResponse<byte[]> Create(object xrechnung, string url)
{
_JsonHttpClientFacade.JsonObject = new
{
json = xrechnung,
pdf = url
};
2025-06-05 14:03:55 +02:00
var bytes = _JsonHttpClientFacade.SendAsync("create").GetAwaiter().GetResult();
2025-06-10 14:29:34 +02:00
var response = ApiResponse<byte[]>.Parse(bytes);
2025-06-05 14:03:55 +02:00
return response;
}
}
}