using Khaemhat.Fiscal.Abstractions;
namespace Khaemhat.Fiscal.Italy.Sdi;
/// The SdICoop messages the SDI sends to the company, as pushes of the channel SDICOOP (issue #76).
public sealed class SdiCoopPushReader : IEInvoicePushReader
{
private const string Soap = "text/xml; charset=utf-8";
///
public string Channel => SdiCoopTransport.ChannelCode;
///
public EInvoicePush? Read(string? contentType, byte[] body)
{
ArgumentNullException.ThrowIfNull(body);
return SdiCoopMessages.Read(contentType, body) is { } inbound
? new EInvoicePush(inbound.ExchangeId, inbound.Files, Soap, SdiCoopMessages.Answer(inbound))
: null;
}
///
public (string ContentType, string Body) Refusal() => (Soap, SdiCoopMessages.Answer(null));
}