Skip to content

kmdlogic/kmd-logic-digitalpost-client

Repository files navigation

KMD Logic Digital Post Client

A dotnet client library for sending digital post (e-Boks) messages via the Logic platform.

How to use this client library

In projects or components where you need to access send messages, add a NuGet package reference to Kmd.Logic.DigitalPost.Client.

The simplest example to send a message is:

using (var httpClient = new HttpClient())
using (var tokenProviderFactory = new LogicTokenProviderFactory(configuration.TokenProvider))
{
    var client = new DigitalPostClient(httpClient, tokenProviderFactory, configuration.DigitalPost);
    var response = await client.SendMessageAsync(IdentifierType.Cpr, "0101010000", "Hi there", "Digital Post test").ConfigureAwait(false);
}

The LogicTokenProviderFactory authorizes access to the Logic platform through the use of a Logic Identity issued client credential. The authorization token is reused until it expires. You would generally create a single instance of LogicTokenProviderFactory.

The DigitalPostClient accesses the Logic Digital Post service.

How to configure the Digital Post client

Perhaps the easiest way to configure the Digital Post client is from Application Settings.

{
  "TokenProvider": {
    "ClientId": "",
    "ClientSecret": "",
    "AuthorizationScope": ""
  },
  "Digital Post": {
    "SubscriptionId": "",
    "ConfigurationId": ""
  }
}

To get started:

  1. Create a subscription in Logic Console. This will provide you the SubscriptionId.
  2. Request a client credential. Once issued you can view the ClientId, ClientSecret and AuthorizationScope in Logic Console.
  3. Create a digital post configuration. This will give you the ConfigurationId.

Sample application

A simple console application is included to demonstrate how to call Logic Digital Post API to transmit a document. You will need to provide the settings described above in appsettings.json.

When run this you should see the message id for the transmission printed to the console.

Callback sample

When configuring your digital post configuration you can optionally specify a callback URL. This allows you to be notified when a citizen or company interacts with your message.

Most importantly, this is how you make use of the inbuilt digital post consent feature. To enable consent you must arrange with the underlying provider for a MaterialID to be configured with this option. NOTE: There is a cost associated with this capability.

Doc2Mail Provider

Doc2Mail is a provider which can be used in by any system. Please contact Charlie Tango or call 25 10 43 01 to arrange your credentials. There is a cost to use this service.

e-Boks Provider

The e-Boks platform may be used directly by approved government agencies. Access can be arranged by contacting Nets.

Digital Post Fake Provider

The Fake Provider is a simple solution for use in Demo or Test environments and also allows you to begin development immediately whilst you wait for your formal credentials.

The fake provider accepts any message sent and always returns a successful response.

About

A C#/dotnet console app which demonstrates how to send documents/messages using the KMD Logic DigitalPost service.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors