Skip to content

Commit 3ecce70

Browse files
Fjerner alt som har med faktura og oppslag på bankkontonummer å gjøre.
Både STNB 2.0 (faktura) og kvitteringstjenesten (oppslag på kontonummer) er avsluttet, så disse APIene skal ikke lenger være i bruk.
1 parent 16ac832 commit 3ecce70

21 files changed

+172
-474
lines changed

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
Online documentation: https://digipost.github.io/digipost-useragreements-api-client-java
88

9-
API specification: https://github.com/digipost/invoice-api-specification
10-
119
## Java Cryptographic Extension
1210

1311
To build and use the API client you need the *Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files for JDK/JRE*

docs/_v3_x/1_introduction.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: Introduction
3+
identifier: introduction
4+
layout: default
5+
---
6+
7+
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.
8+
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
9+
through an agreement. The agreement governs which documents the sender can access and what operations it can perform.
10+
11+
12+
### Download
13+
14+
The library can be acquired from Maven Central Repository, using the dependency management tool of your choice.
15+
For Maven you can use the following dependency:
16+
17+
```xml
18+
<dependency>
19+
<groupId>no.digipost</groupId>
20+
<artifactId>digipost-useragreements-api-client-java</artifactId>
21+
<version>2.0-delta</version>
22+
</dependency>
23+
```
24+
25+
### Prerequisites
26+
27+
The library requires *Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files for JDK/JRE* to be installed:
28+
[www.oracle.com/technetwork/java/javase/downloads/index.html](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
29+
30+
Starting from *Java 8 build 152* the unlimited strength cryptography policy files are bundled with the JDK/JRE, and may be enabled by setting
31+
the security property `security.policy` to `"unlimited"`. How this is set depends on how you deploy your application, but if done early enough,
32+
i.e. *before* the JCE framework is initialized, it can be set programatically like this:
33+
34+
```java
35+
Security.setProperty("crypto.policy", "unlimited"); // only effective on Java 8 b152 or newer
36+
```
37+
38+
More details are available in the [Java 8u152 Release Notes](http://www.oracle.com/technetwork/java/javase/8u152-relnotes-3850503.html#JDK-8157561).
39+
40+
41+
### Instantiate and configure client
42+
43+
```java
44+
InputStream key = getClass().getResourceAsStream("certificate.p12");
45+
46+
HttpHost proxy = new HttpHost("proxy.example.com", 8080, "http");
47+
48+
BrokerId brokerId = BrokerId.of(1234L);
49+
50+
DigipostUserAgreementsClient client = new DigipostUserAgreementsClient
51+
.Builder(brokerId, key, "password")
52+
.useProxy(proxy) //optional
53+
.setHttpClientBuilder(HttpClientBuilder.create()) //optional
54+
.serviceEndpoint(URI.create("https://api.digipost.no")) //optional
55+
.build();
56+
```
57+
58+
### Identify Digipost user
59+
60+
```java
61+
final SenderId senderId = SenderId.of(1234L);
62+
final UserId userId = UserId.of("01017012345");
63+
64+
final IdentificationResult identificationResult = client.identifyUser(senderId, userId);
65+
boolean isDigipost = identificationResult.getResult() == IdentificationResultCode.DIGIPOST;
66+
```
67+

docs/_v3_x/2_fetch_messages.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: Messages sent to user
3+
identifier: fetch_messages
4+
layout: default
5+
---
6+
7+
The agreement type `FETCH_MESSAGES` allows a sender to retrieve metadata for
8+
documents that sender has previously sent to the user, that e.g. can be used to
9+
present a synthetic inbox to the user. The metadata includes a deep-link the
10+
user can use to access the document in Digipost.
11+
12+
13+
### Create, read, update and delete agreement
14+
15+
```java
16+
final SenderId senderId = SenderId.of(1234L);
17+
final UserId userId = UserId.of("01017012345");
18+
19+
//CreateAgreement
20+
client.createOrReplaceAgreement(senderId, Agreement.createAgreement(userId, AgreementType.FETCH_MESSAGES));
21+
22+
//GetAgreement
23+
final GetAgreementResult agreement = client.getAgreement(senderId, AgreementType.FETCH_MESSAGES, userId);
24+
25+
//UpdateAgreement
26+
client.createOrReplaceAgreement(senderId, Agreement.createAgreement(userId, AgreementType.FETCH_MESSAGES));
27+
28+
//DeleteAgreement
29+
client.deleteAgreement(senderId, AgreementType.FETCH_MESSAGES, userId);
30+
```
31+
32+
### Get and verify agreement
33+
34+
```java
35+
final SenderId senderId = SenderId.of(1234L);
36+
final UserId userId = UserId.of("01017012345");
37+
38+
final GetAgreementResult agreementResult = client.getAgreement(senderId, AgreementType.FETCH_MESSAGES, userId);
39+
if (agreementResult.isSuccess()) {
40+
final Agreement agreement = agreementResult.getAgreement();
41+
} else {
42+
switch (agreementResult.getFailedReason()) {
43+
case UNKNOWN_USER: //User does not have a Digipost account
44+
case NO_AGREEMENT: //No agreement exists for user
45+
}
46+
}
47+
```
48+
49+
### Get documents
50+
51+
```java
52+
final SenderId senderId = SenderId.of(1234L);
53+
final UserId userId = UserId.of("01017012345");
54+
55+
final List<Document> previouslyDeliveredDocs = client.getDocuments(senderId, AgreementType.FETCH_MESSAGES,
56+
userId, GetDocumentsQuery.empty());
57+
58+
final ZoneId OSLO_ZONE = ZoneId.of("Europe/Oslo");
59+
final List<Document> withinTimeWindow = client.getDocuments(senderId, AgreementType.FETCH_MESSAGES, userId,
60+
GetDocumentsQuery.builder()
61+
.deliveryTimeFrom(ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, OSLO_ZONE))
62+
.deliveryTimeTo(ZonedDateTime.now(OSLO_ZONE))
63+
.build());
64+
```

docs/_v3_x/index.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
identifier: index
3+
layout: default
4+
redirect_from: /
5+
---
6+
7+
<!-- Documentation -->
8+
{% for dok in site.v3_x %}
9+
{% if dok.identifier != 'index' %}
10+
<section class="bs-docs-section">
11+
<h1 id="{{ dok.identifier }}" class="page-header">{{ dok.title}}</h1>
12+
{{dok.content}}
13+
</section>
14+
{% endif%}
15+
{% endfor %}

src/main/java/no/digipost/api/useragreements/client/Agreement.java

-6
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ public Agreement(final AgreementType type, final UserId userId, final HashMap<St
4949
this.attributes = attributes == null ? new HashMap<String, String>() : attributes;
5050
}
5151

52-
public static Agreement createInvoiceBankAgreement(final UserId userId, final boolean smsNotification) {
53-
HashMap<String, String> attribs = new HashMap<>();
54-
attribs.put("sms-notification", String.valueOf(smsNotification));
55-
return new Agreement(AgreementType.INVOICE_BANK, userId, attribs);
56-
}
57-
5852
public AgreementType getType() {
5953
return type;
6054
}

src/main/java/no/digipost/api/useragreements/client/AgreementType.java

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
public final class AgreementType {
1919

20-
public static final AgreementType INVOICE_BANK = new AgreementType("invoice-bank");
21-
public static final AgreementType BANK_ACCOUNT_NUMBER_FOR_RECEIPTS = new AgreementType("account-num-for-receipts");
2220
public static final AgreementType FETCH_MESSAGES = new AgreementType("fetch-messages");
2321

2422
public static final String QUERY_PARAM_NAME = "agreement-type";

src/main/java/no/digipost/api/useragreements/client/ApiService.java

+1-22
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
import static java.time.Duration.ofMinutes;
4040
import static java.time.format.DateTimeFormatter.ISO_DATE_TIME;
41-
import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE;
4241
import static no.digipost.api.useragreements.client.Headers.X_Digipost_UserId;
4342
import static no.digipost.api.useragreements.client.response.ResponseUtils.mapOkResponseOrThrowException;
4443
import static no.digipost.api.useragreements.client.response.ResponseUtils.unmarshallEntities;
@@ -104,15 +103,6 @@ public Documents getDocuments(final SenderId senderId, final AgreementType agree
104103
}
105104

106105
private void setGetDocumentsQueryParams(final URIBuilder uriBuilder, final GetDocumentsQuery query) {
107-
if (query.getInvoiceStatus() != null) {
108-
uriBuilder.setParameter(InvoiceStatus.QUERY_PARAM_NAME, query.getInvoiceStatus().getStatus());
109-
}
110-
if (query.getInvoiceDueDateFrom() != null) {
111-
uriBuilder.setParameter("invoice-due-date-from", query.getInvoiceDueDateFrom().format(ISO_LOCAL_DATE));
112-
}
113-
if (query.getInvoiceDueDateTo() != null) {
114-
uriBuilder.setParameter("invoice-due-date-to", query.getInvoiceDueDateTo().format(ISO_LOCAL_DATE));
115-
}
116106
if (query.getDeliveryTimeFrom() != null) {
117107
uriBuilder.setParameter("delivery-time-from", query.getDeliveryTimeFrom().format(ISO_DATE_TIME));
118108
}
@@ -128,13 +118,6 @@ public Document getDocument(final SenderId senderId, final AgreementType agreeme
128118
return executeHttpRequest(newGetRequest(uriBuilder, requestTrackingId), handler);
129119
}
130120

131-
public void updateInvoice(final SenderId senderId, final AgreementType agreementType, final long documentId, final InvoiceUpdate invoice, final String requestTrackingId, final ResponseHandler<Void> handler) {
132-
URIBuilder uriBuilder = new URIBuilder(serviceEndpoint)
133-
.setPath(userDocumentsPath(senderId) + "/" + documentId + "/invoice")
134-
.setParameter(AgreementType.QUERY_PARAM_NAME, agreementType.getType());
135-
executeHttpRequest(newPostRequest(uriBuilder, requestTrackingId, invoice), handler);
136-
}
137-
138121
public DocumentCount getDocumentCount(final SenderId senderId, final AgreementType agreementType, final UserId userId, final GetDocumentsQuery query, final String requestTrackingId, final ResponseHandler<DocumentCount> handler) {
139122
URIBuilder uriBuilder = new URIBuilder(serviceEndpoint)
140123
.setPath(userDocumentsPath(senderId) + "/count")
@@ -151,14 +134,10 @@ public DocumentContent getDocumentContent(final SenderId senderId, final Agreeme
151134
return executeHttpRequest(newGetRequest(uriBuilder, requestTrackingId), handler);
152135
}
153136

154-
public StreamingRateLimitedResponse<UserId> getAgreementOwners(final SenderId senderId, final AgreementType agreementType, final Boolean smsNotificationsEnabled, final String requestTrackingId) {
137+
public StreamingRateLimitedResponse<UserId> getAgreementOwners(final SenderId senderId, final AgreementType agreementType, final String requestTrackingId) {
155138
URIBuilder uriBuilder = new URIBuilder(serviceEndpoint)
156139
.setPath(userAgreementsPath(senderId) + "/agreement-owners")
157140
.setParameter(AgreementType.QUERY_PARAM_NAME, agreementType.getType());
158-
if (smsNotificationsEnabled != null) {
159-
uriBuilder
160-
.setParameter("invoice-sms-notification", smsNotificationsEnabled.toString());
161-
}
162141

163142
HttpGet request = newGetRequest(uriBuilder, requestTrackingId);
164143
request.setHeader(X_Digipost_UserId, brokerId.serialize());

src/main/java/no/digipost/api/useragreements/client/DigipostUserAgreementsClient.java

+2-30
Original file line numberDiff line numberDiff line change
@@ -142,30 +142,6 @@ public Document getDocument(final SenderId senderId, final AgreementType agreeme
142142
return apiService.getDocument(senderId, agreementType, documentId, requestTrackingId, singleJaxbEntityHandler(Document.class));
143143
}
144144

145-
public void payInvoice(final SenderId senderId, final AgreementType agreementType, final long documentId, final InvoicePayment invoicePayment) {
146-
payInvoice(senderId, agreementType, documentId, invoicePayment, null);
147-
}
148-
149-
public void payInvoice(final SenderId senderId, final AgreementType agreementType, final long documentId, final InvoicePayment invoicePayment, final String requestTrackingId) {
150-
apiService.updateInvoice(senderId, agreementType, documentId, invoicePayment.asInvoiceUpdate(), requestTrackingId, voidOkHandler());
151-
}
152-
153-
public void updateInvoice(final SenderId senderId, final AgreementType agreementType, final long documentId, final InvoiceUpdate invoiceUpdate) {
154-
updateInvoice(senderId, agreementType, documentId, invoiceUpdate, null);
155-
}
156-
157-
public void updateInvoice(final SenderId senderId, final AgreementType agreementType, final long documentId, final InvoiceUpdate invoiceUpdate, final String requestTrackingId) {
158-
apiService.updateInvoice(senderId, agreementType, documentId, invoiceUpdate, requestTrackingId, voidOkHandler());
159-
}
160-
161-
public void deleteInvoice(final SenderId senderId, final AgreementType agreementType, final long documentId) {
162-
deleteInvoice(senderId, agreementType, documentId, null);
163-
}
164-
165-
public void deleteInvoice(final SenderId senderId, final AgreementType agreementType, final long documentId, final String requestTrackingId) {
166-
apiService.updateInvoice(senderId, agreementType, documentId, new InvoiceUpdate(InvoiceStatus.DELETED), requestTrackingId, voidOkHandler());
167-
}
168-
169145
public long getDocumentCount(final SenderId senderId, final AgreementType agreementType, final UserId userId, final GetDocumentsQuery query) {
170146
return getDocumentCount(senderId, agreementType, userId, query, null);
171147
}
@@ -189,14 +165,10 @@ public StreamingRateLimitedResponse<UserId> getAgreementOwners(final SenderId se
189165
return getAgreementOwners(senderId, agreementType, null);
190166
}
191167

192-
public StreamingRateLimitedResponse<UserId> getAgreementOwners(final SenderId senderId, final AgreementType agreementType, final Boolean smsNotificationEnabled) {
193-
return getAgreementOwners(senderId, agreementType, smsNotificationEnabled, null);
194-
}
195-
196-
public StreamingRateLimitedResponse<UserId> getAgreementOwners(final SenderId senderId, final AgreementType agreementType, final Boolean smsNotificationEnabled, final String requestTrackingId) {
168+
public StreamingRateLimitedResponse<UserId> getAgreementOwners(final SenderId senderId, final AgreementType agreementType, final String requestTrackingId) {
197169
Objects.requireNonNull(senderId, "senderId cannot be null");
198170
Objects.requireNonNull(agreementType, "agreementType cannot be null");
199-
return apiService.getAgreementOwners(senderId, agreementType, smsNotificationEnabled, requestTrackingId);
171+
return apiService.getAgreementOwners(senderId, agreementType, requestTrackingId);
200172
}
201173

202174
private ResponseHandler<Void> voidOkHandler() {

src/main/java/no/digipost/api/useragreements/client/Document.java

+1-9
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ public class Document {
3131
@XmlElement(name = "sender-name")
3232
private String senderName;
3333
@XmlElement
34-
private Invoice invoice;
35-
@XmlElement
3634
private String subject;
3735
@XmlElement(name = "delivery-time")
3836
private ZonedDateTime deliveryTime;
@@ -45,13 +43,8 @@ public class Document {
4543

4644
private Document() {}
4745

48-
public Document(final long id, final Invoice invoice) {
46+
public Document(final long id) {
4947
this.id = id;
50-
this.invoice = invoice;
51-
}
52-
53-
public Invoice getInvoice() {
54-
return invoice;
5548
}
5649

5750
public String getSenderName() {
@@ -87,7 +80,6 @@ public String toString() {
8780
final StringBuilder sb = new StringBuilder("Document{");
8881
sb.append("id=").append(id);
8982
sb.append(", senderName='").append(senderName).append('\'');
90-
sb.append(", invoice=").append(invoice);
9183
sb.append(", authenticationLevel=").append(authenticationLevel);
9284
sb.append(", deliveryTime=").append(deliveryTime);
9385
sb.append('}');

src/main/java/no/digipost/api/useragreements/client/ErrorCode.java

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ public enum ErrorCode {
2121
UNKNOWN_USER_ID,
2222
NOT_AUTHORIZED,
2323
AGREEMENT_NOT_FOUND,
24-
INVOICE_ALREADY_PAID,
25-
INVALID_INVOICE_STATUS,
2624
INVALID_REQUEST_PARAMETER,
2725
INVALID_FIELD,
2826

src/main/java/no/digipost/api/useragreements/client/GetDocumentsQuery.java

-37
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,18 @@
1616
package no.digipost.api.useragreements.client;
1717

1818

19-
import java.time.LocalDate;
2019
import java.time.OffsetDateTime;
2120
import java.time.ZonedDateTime;
2221

2322
public class GetDocumentsQuery {
24-
private final InvoiceStatus invoiceStatus;
25-
private final LocalDate invoiceDueDateFrom;
26-
private final LocalDate invoiceDueDateTo;
2723
private final OffsetDateTime deliveryTimeFrom;
2824
private final OffsetDateTime deliveryTimeTo;
2925

3026
private GetDocumentsQuery(final Builder builder) {
31-
this.invoiceStatus = builder.invoiceStatus;
32-
this.invoiceDueDateFrom = builder.invoiceDueDateFrom;
33-
this.invoiceDueDateTo = builder.invoiceDueDateTo;
3427
this.deliveryTimeFrom = builder.deliveryTimeFrom;
3528
this.deliveryTimeTo = builder.deliveryTimeTo;
3629
}
3730

38-
public InvoiceStatus getInvoiceStatus() {
39-
return invoiceStatus;
40-
}
41-
42-
public LocalDate getInvoiceDueDateFrom() {
43-
return invoiceDueDateFrom;
44-
}
45-
46-
public LocalDate getInvoiceDueDateTo() {
47-
return invoiceDueDateTo;
48-
}
49-
5031
public OffsetDateTime getDeliveryTimeFrom() {
5132
return deliveryTimeFrom;
5233
}
@@ -64,29 +45,11 @@ public static GetDocumentsQuery empty() {
6445
}
6546

6647
public static class Builder {
67-
private InvoiceStatus invoiceStatus;
68-
private LocalDate invoiceDueDateFrom;
69-
private LocalDate invoiceDueDateTo;
7048
private OffsetDateTime deliveryTimeFrom;
7149
private OffsetDateTime deliveryTimeTo;
7250

7351
private Builder() {}
7452

75-
public Builder invoiceStatus(final InvoiceStatus invoiceStatus) {
76-
this.invoiceStatus = invoiceStatus;
77-
return this;
78-
}
79-
80-
public Builder invoiceDueDateFrom(final LocalDate invoiceDueDateFrom) {
81-
this.invoiceDueDateFrom = invoiceDueDateFrom;
82-
return this;
83-
}
84-
85-
public Builder invoiceDueDateTo(final LocalDate invoiceDueDateTo) {
86-
this.invoiceDueDateTo = invoiceDueDateTo;
87-
return this;
88-
}
89-
9053
public Builder deliveryTimeFrom(final OffsetDateTime deliveryTimeFrom) {
9154
this.deliveryTimeFrom = deliveryTimeFrom;
9255
return this;

0 commit comments

Comments
 (0)