This is a .NET library compatible with .NET Standard 2.1 for sending messages to the Fiks platform. The library provides functionality to send messages to the Fiks platform using the Fiks IO Send API. The library supports sending messages with and without ASiC-E encryption.
To get started with KS.Fiks.IO.Send.Client, add the NuGet package to your .NET project:
dotnet add package KS.Fiks.IO.Send.Client --version <version_number>
Sending a Message To send a message, you need to create an instance of MeldingSpesifikasjonApiModel and provide the necessary stream or payload. Here's an example:
using KS.Fiks.IO.Send.Client;
using KS.Fiks.IO.Send.Client.Models;
using System;
using System.IO;
using System.Threading.Tasks;
public class SendMessageExample
{
public async Task Send()
{
var sender = new FiksIOSender(/* configuration and maskinportenClient */);
var metaData = new MeldingSpesifikasjonApiModel(
_fiksIoAccountId, // Guid
_toAccountId, // Guid
_messageType, // string
ttl: (long)TimeSpan.FromDays(2).TotalMilliseconds, // long
headere: new()); // Dictionary<string, string>
// Without ASiC-E
using var dataStream = new MemoryStream(/* your data */);
var sentMelding = await sender.Send(metaData, dataStream);
// With ASiC-E
var payload = new Payload("testfile.txt")
var sentMelding = await sender.SendWithEncryptedData(metaData, payload);
Console.WriteLine($"Message sent with ID: {sendtMelding.MeldingId}");
}
}
The FiksIOSender class requires a configuration object to be passed in the constructor. The configuration object must implement the IFiksIOConfiguration interface. Here's an example of how to create a configuration object:
var configurationBuilder = new FiksIOSenderConfigurationBuilder();
You can configure Asice Signing using either a public and private key pair or an X509Certificate2 instance.
configurationBuilder.WithAsiceSigningConfiguration(publicKeyPath, privateKeyPath);
Replace publicKeyPath and privateKeyPath with the paths to your public and private keys respectively.
configurationBuilder.WithAsiceSigningConfiguration(certificate);
Replace certificate with an instance of X509Certificate2.
configurationBuilder.WithFiksIntegrasjonConfiguration(fiksIntegrasjonId, fiksIntegrasjonPassword);
configurationBuilder.WithApiConfiguration(path, scheme, host, hostPort);
Step 5: Build the Configuration
var configuration = configurationBuilder.Build();
var configuration = new FiksIOSenderConfigurationBuilder()
.WithAsiceSigningConfiguration(appSettings.AsiceSigningPublicKey, appSettings.AsiceSigningPrivateKey)
.WithFiksIntegrasjonConfiguration(appSettings.FiksIoIntegrationId, appSettings.FiksIoIntegrationPassword)
.WithApiConfiguration(null, appSettings.ApiScheme, appSettings.ApiHost, appSettings.ApiPort)
.Build();
var sender = new FiksIOSender(configuration, _maskinportenClient);