A dotnet client library for uploading and sending documents for citizens via the Logic platform.
In projects or components where you need to upload or send documents, add a NuGet package reference to Kmd.Logic.CitizenDocuments.Client.
The simplest example to get a citizens details is:
using (var httpClient = new HttpClient())
{
var tokenProviderFactory = new LogicTokenProviderFactory(tokenProviderOptions);
var citizenDocumentClient = new CitizenDocumentsClient(httpClient, tokenProviderFactory, configuration.Citizen);
var uploadDocument = await citizenDocumentClient.UploadAttachmentWithHttpMessagesAsync(new Guid(configuration.SubscriptionId), configuration.ConfiguartionId, configuration.RetentionPeriodInDays, configuration.Cpr, configuration.DocumentType, configuration.Document, configuration.DocumentName).ConfigureAwait(false);
var sendDocument = await citizenDocumentClient.SendDocumentWithHttpMessagesAsync(new Guid(configuration.SubscriptionId), new SendCitizenDocumentRequest
}
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 CitizenDocumentsClient
accesses the Logic CitizenDocuments service which in turn interacts with one of the data providers.
Perhaps the easiest way to configure the CitizenDocuments client is from Application Settings.
{
"TokenProvider": {
"ClientId": "",
"ClientSecret": "",
"AuthorizationScope": ""
}
}
To get started:
- Create a subscription in Logic Console. This will provide you the
SubscriptionId
. - Request a client credential. Once issued you can view the
ClientId
,ClientSecret
andAuthorizationScope
in Logic Console. - Create a CitizenDocuments configuration. Select the Digital Post configuration and upload the details. This will give you the
CitizenDocumentsConfigurationId
.
A simple console application is included to demonstrate how to call Logic CitizenDocuments API. You will need to provide the settings described above in appsettings.json
.
When run you should see the details of the FileAccessPage and messageId is printed to the console.