// Copy into a net10.0 console app that references lib/SWIFTFramework.dll
//
// export SWIFTFRAMEWORK_RUNTIME_LICENSE_KEY='your-purchased-key'
// dotnet run --project Framework/SourceCode/ConsoleSample/ConsoleSample.csproj
using SWIFTFramework;
using SWIFTFramework.Messages.Category1;
using SWIFTFramework.Validation;

Licensing.RunTimeLicenseKey = Environment.GetEnvironmentVariable("SWIFTFRAMEWORK_RUNTIME_LICENSE_KEY");

string sampleMessage = """
    {1:F01BANKUSPPAXXX6453938350}{2:O1030805090112BANKUKZHH80A53405362810901120805N}{4:
    :20:ABCDEREF
    :23B:CRED
    :32A:090113USD14551,
    :33B:USD14551,
    :50K:/0123456789
    :52A:BANKUSPP
    :57A:/9876543210
    BANKUKZH
    :59:/9988776655
    :71A:SHA
    -}{5:{CHK:30860BAE4D8E}{MAC:00000000}}{S:{SAC:}{COP:P}}
    """;

var parser = new SwiftParser();
var errors = new List<ValidationError>();
SwiftMessage message = parser.GetMessage(sampleMessage, errors);

Console.WriteLine($"Type: {message.GetType().Name}");
Console.WriteLine($"Errors: {errors.Count}");
Console.WriteLine(message.ToXml());

var mt103 = (MT103)message;
mt103.Tag59_BeneficiaryCustomer.Value = "/1122334455";
mt103.ValueDateCurrencyInterbankSettledAmount_32A.Date = DateTime.Today;

Console.WriteLine(parser.GetMessageAsText(mt103));
