-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added documentation for the new release which uses java 11 and jakarta.
- Loading branch information
Showing
6 changed files
with
151 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: Introduction | ||
identifier: introduction | ||
layout: default | ||
--- | ||
|
||
This API makes it possible to access agreements between Digipost users and third parties, and followingly perform certain operations which the user has granted the third party. | ||
For instance, the user may permit that certain information may be provided to a third party in order to receive a service. The user may also grant the sender access to documents | ||
through an agreement. The agreement governs which documents the sender can access and what operations it can perform. | ||
|
||
|
||
### Download | ||
|
||
The library can be acquired from Maven Central Repository, using the dependency management tool of your choice. | ||
For Maven you can use the following dependency: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>no.digipost</groupId> | ||
<artifactId>digipost-useragreements-api-client-java</artifactId> | ||
<version>4.0.0</version> | ||
</dependency> | ||
``` | ||
|
||
### Prerequisites | ||
|
||
This library now requires Java 11 and above and uses `jakarta.xml-bind`. | ||
|
||
|
||
### Instantiate and configure client | ||
|
||
```java | ||
InputStream key = getClass().getResourceAsStream("certificate.p12"); | ||
|
||
HttpHost proxy = new HttpHost("proxy.example.com", 8080, "http"); | ||
|
||
BrokerId brokerId = BrokerId.of(1234L); | ||
|
||
DigipostUserAgreementsClient client = new DigipostUserAgreementsClient | ||
.Builder(brokerId, key, "password") | ||
.useProxy(proxy) //optional | ||
.setHttpClientBuilder(HttpClientBuilder.create()) //optional | ||
.serviceEndpoint(URI.create("https://api.digipost.no")) //optional | ||
.build(); | ||
``` | ||
|
||
### Identify Digipost user | ||
|
||
```java | ||
final SenderId senderId = SenderId.of(1234L); | ||
final UserId userId = UserId.of("01017012345"); | ||
|
||
final IdentificationResult identificationResult = client.identifyUser(senderId, userId); | ||
boolean isDigipost = identificationResult.getResult() == IdentificationResultCode.DIGIPOST; | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: Messages sent to user | ||
identifier: fetch_messages | ||
layout: default | ||
--- | ||
|
||
The agreement type `FETCH_MESSAGES` allows a sender to retrieve metadata for | ||
documents that sender has previously sent to the user, that e.g. can be used to | ||
present a synthetic inbox to the user. The metadata includes a deep-link the | ||
user can use to access the document in Digipost. | ||
|
||
|
||
### Create, read, update and delete agreement | ||
|
||
```java | ||
final SenderId senderId = SenderId.of(1234L); | ||
final UserId userId = UserId.of("01017012345"); | ||
|
||
//CreateAgreement | ||
client.createOrReplaceAgreement(senderId, Agreement.createAgreement(userId, AgreementType.FETCH_MESSAGES)); | ||
|
||
//GetAgreement | ||
final GetAgreementResult agreement = client.getAgreement(senderId, AgreementType.FETCH_MESSAGES, userId); | ||
|
||
//UpdateAgreement | ||
client.createOrReplaceAgreement(senderId, Agreement.createAgreement(userId, AgreementType.FETCH_MESSAGES)); | ||
|
||
//DeleteAgreement | ||
client.deleteAgreement(senderId, AgreementType.FETCH_MESSAGES, userId); | ||
``` | ||
|
||
### Get and verify agreement | ||
|
||
```java | ||
final SenderId senderId = SenderId.of(1234L); | ||
final UserId userId = UserId.of("01017012345"); | ||
|
||
final GetAgreementResult agreementResult = client.getAgreement(senderId, AgreementType.FETCH_MESSAGES, userId); | ||
if (agreementResult.isSuccess()) { | ||
final Agreement agreement = agreementResult.getAgreement(); | ||
} else { | ||
switch (agreementResult.getFailedReason()) { | ||
case UNKNOWN_USER: //User does not have a Digipost account | ||
case NO_AGREEMENT: //No agreement exists for user | ||
} | ||
} | ||
``` | ||
|
||
### Get documents | ||
|
||
```java | ||
final SenderId senderId = SenderId.of(1234L); | ||
final UserId userId = UserId.of("01017012345"); | ||
|
||
final List<Document> previouslyDeliveredDocs = client.getDocuments(senderId, AgreementType.FETCH_MESSAGES, | ||
userId, GetDocumentsQuery.empty()); | ||
|
||
final ZoneId OSLO_ZONE = ZoneId.of("Europe/Oslo"); | ||
final List<Document> withinTimeWindow = client.getDocuments(senderId, AgreementType.FETCH_MESSAGES, userId, | ||
GetDocumentsQuery.builder() | ||
.deliveryTimeFrom(ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, OSLO_ZONE)) | ||
.deliveryTimeTo(ZonedDateTime.now(OSLO_ZONE)) | ||
.build()); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
identifier: index | ||
layout: default | ||
redirect_from: / | ||
--- | ||
|
||
<!-- Documentation --> | ||
{% for dok in site.v4_x %} | ||
{% if dok.identifier != 'index' %} | ||
<section class="bs-docs-section"> | ||
<h1 id="{{ dok.identifier }}" class="page-header">{{ dok.title}}</h1> | ||
{{dok.content}} | ||
</section> | ||
{% endif%} | ||
{% endfor %} |