Skip to content

Commit

Permalink
Merge pull request #72 from digipost/deling
Browse files Browse the repository at this point in the history
Add new datatype ShareDocumentsRequest
  • Loading branch information
hermanwh authored Nov 10, 2023
2 parents a513d18 + f480d5d commit 332a229
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 4 deletions.
11 changes: 11 additions & 0 deletions datatypes-examples.xml
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,17 @@
<external-id>externalId</external-id>
</residence>

<share-documents-request xmlns="http://api.digipost.no/schema/datatypes">
<max-share-duration-seconds>1209600</max-share-duration-seconds>
<purpose>We require to see your latest pay slip in order to grant you a loan.</purpose>
</share-documents-request>

<share-documents-request-documents-shared xmlns="http://api.digipost.no/schema/datatypes">
<document-ids>123</document-ids>
</share-documents-request-documents-shared>

<share-documents-request-sharing-stopped xmlns="http://api.digipost.no/schema/datatypes"/>

<signedDocument xmlns="http://api.digipost.no/schema/datatypes">
<document-issuer>Bedrift AS</document-issuer>
<document-subject>Ansettelseskontrakt</document-subject>
Expand Down
31 changes: 27 additions & 4 deletions datatypes.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@

<xs:element name="residence" type="tns:residence"/>

<xs:element name="share-documents-request" type="tns:shareDocumentsRequest"/>

<xs:element name="share-documents-request-documents-shared" type="tns:shareDocumentsRequestDocumentsShared"/>

<xs:element name="share-documents-request-sharing-stopped" type="tns:shareDocumentsRequestSharingStopped"/>

<xs:element name="signedDocument" type="tns:signedDocument"/>

<xs:complexType final="extension restriction" name="address">
Expand Down Expand Up @@ -480,28 +486,45 @@
</xs:sequence>
</xs:complexType>

<xs:complexType final="extension restriction" name="shareDocumentsRequest">
<xs:sequence>
<xs:element name="max-share-duration-seconds" type="xs:long"/>
<xs:element name="purpose" type="xs:string"/>
</xs:sequence>
</xs:complexType>

<xs:complexType final="extension restriction" name="shareDocumentsRequestDocumentsShared">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="document-ids" type="xs:long"/>
</xs:sequence>
</xs:complexType>

<xs:complexType final="extension restriction" name="shareDocumentsRequestSharingStopped">
<xs:sequence/>
</xs:complexType>

<xs:simpleType name="language">
<xs:restriction base="xs:string">
<xs:enumeration value="NB"/>
<xs:enumeration value="EN"/>
<xs:enumeration value="NB"/>
<xs:enumeration value="NN"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="status">
<xs:restriction base="xs:string">
<xs:enumeration value="READY_FOR_PICKUP"/>
<xs:enumeration value="UNKNOWN"/>
<xs:enumeration value="DEVIATION"/>
<xs:enumeration value="READY_FOR_PICKUP"/>
<xs:enumeration value="RETURNED"/>
<xs:enumeration value="PICKED_UP"/>
<xs:enumeration value="UNKNOWN"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="tag">
<xs:restriction base="xs:string">
<xs:enumeration value="VARSEL2"/>
<xs:enumeration value="VARSEL1"/>
<xs:enumeration value="VARSEL2"/>
<xs:enumeration value="POSTEN"/>
</xs:restriction>
</xs:simpleType>
Expand Down
60 changes: 60 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
|[Proof](#proof)|Represents a legal document (Certificate, Licence, Permit, etc.) issued to a single person, valid for one or more time periods.|
|[Receipt](#receipt)|Receipt represents a document containing details about a purchase|
|[Residence](#residence)|Residence is a way of linking separate data for the same residence|
|[ShareDocumentsRequest](#sharedocumentsrequest)|A request for a user to share one or more documents|
|[ShareDocumentsRequestDocumentsShared](#sharedocumentsrequestdocumentsshared)|Documents have been shared for ShareDocumentsRequest|
|[ShareDocumentsRequestSharingStopped](#sharedocumentsrequestsharingstopped)|Stop sharing of documents for ShareDocumentsRequest|
|[SignedDocument](#signeddocument)|Details about a signed document|

## Appointment
Expand Down Expand Up @@ -1080,6 +1083,63 @@ Residence is a way of linking separate data for the same residence
</residence>
```

## ShareDocumentsRequest

A request for a user to share one or more documents

### Complemented by:
[ShareDocumentsRequestSharingStopped](#sharedocumentsrequestsharingstopped)

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|
|maxShareDurationSeconds|Long|yes|This is the maximum duration in which you are allowed to access the user's documents from they are shared with you|
|purpose|String|yes|This text should explain why you need to process the recipient's documents in a short and understandable way.|

### XML

```xml
<share-documents-request xmlns="http://api.digipost.no/schema/datatypes">
<max-share-duration-seconds>1209600</max-share-duration-seconds>
<purpose>We require to see your latest pay slip in order to grant you a loan.</purpose>
</share-documents-request>
```

## ShareDocumentsRequestDocumentsShared

Documents have been shared for ShareDocumentsRequest

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|
|documentIds|List|no|The IDs of the documents related to this specific event|

### XML

```xml
<share-documents-request-documents-shared xmlns="http://api.digipost.no/schema/datatypes">
<document-ids>123</document-ids>
</share-documents-request-documents-shared>
```

## ShareDocumentsRequestSharingStopped

Stop sharing of documents for ShareDocumentsRequest

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|


### XML

```xml
<share-documents-request-sharing-stopped xmlns="http://api.digipost.no/schema/datatypes"/>
```

## SignedDocument

Details about a signed document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import no.digipost.api.datatypes.types.pickup.PickupNoticeStatus;
import no.digipost.api.datatypes.types.proof.Proof;
import no.digipost.api.datatypes.types.receipt.Receipt;
import no.digipost.api.datatypes.types.share.ShareDocumentsRequest;

import java.util.Collections;
import java.util.Map;
Expand All @@ -27,6 +28,9 @@
import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toSet;

import no.digipost.api.datatypes.types.share.ShareDocumentsRequestDocumentsShared;
import no.digipost.api.datatypes.types.share.ShareDocumentsRequestSharingStopped;

/**
* HOWTO: Add new data type
*
Expand All @@ -50,6 +54,9 @@ public enum DataTypeIdentifier {
, INKASSO(Inkasso.class, "INKA", Inkasso.EXAMPLE)
, INVOICE(Invoice.class, "INVO", Invoice.EXAMPLE)
, INVOICE_PAYMENT(InvoicePayment.class, "INVP", InvoicePayment.EXAMPLE)
, SHARE_DOCUMENT_REQUEST(ShareDocumentsRequest.class, "SHAR", ShareDocumentsRequest.EXAMPLE)
, SHARE_DOCUMENT_REQUEST_SHARING_STOPPED(ShareDocumentsRequestSharingStopped.class, "SHSS", ShareDocumentsRequestSharingStopped.EXAMPLE)
, SHARE_DOCUMENT_REQUEST_DOCUMENTS_SHARED(ShareDocumentsRequestDocumentsShared.class, "SHDS", ShareDocumentsRequestDocumentsShared.EXAMPLE)
;

private final Class<? extends DataType> dataType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package no.digipost.api.datatypes.types.share;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.With;
import no.digipost.api.datatypes.ComplementedBy;
import no.digipost.api.datatypes.DataType;
import no.digipost.api.datatypes.documentation.Description;

import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "share-documents-request")
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@With
@Description("A request for a user to share one or more documents")
@ComplementedBy({ShareDocumentsRequestSharingStopped.class})
public class ShareDocumentsRequest implements DataType {

@XmlElement(name="max-share-duration-seconds", required = true)
@NotNull
@Description("This is the maximum duration in which you are allowed to access the user's documents from they are shared with you")
Long maxShareDurationSeconds;

@XmlElement(name="purpose", required = true)
@NotNull
@Description("This text should explain why you need to process the recipient's documents in a short and understandable way.")
String purpose;

public static final ShareDocumentsRequest EXAMPLE = new ShareDocumentsRequest(
14 * 24 * 60 * 60L,
"We require to see your latest pay slip in order to grant you a loan."
);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package no.digipost.api.datatypes.types.share;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.With;
import no.digipost.api.datatypes.DataType;
import no.digipost.api.datatypes.documentation.Description;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;

@XmlRootElement(name = "share-documents-request-documents-shared")
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@With
@Description("Documents have been shared for ShareDocumentsRequest")
public class ShareDocumentsRequestDocumentsShared implements DataType {

@XmlElement(name = "document-ids")
@Description("The IDs of the documents related to this specific event")
List<Long> documentIds;

public static final ShareDocumentsRequestDocumentsShared EXAMPLE = createExample();

private static ShareDocumentsRequestDocumentsShared createExample() {
List<Long> documentIds = new ArrayList<>(1);
documentIds.add(123L);
return new ShareDocumentsRequestDocumentsShared(
documentIds
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package no.digipost.api.datatypes.types.share;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.With;
import no.digipost.api.datatypes.DataType;
import no.digipost.api.datatypes.documentation.Description;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "share-documents-request-sharing-stopped")
@Value
@NoArgsConstructor(force = true, access = AccessLevel.PUBLIC)
@With
@Description("Stop sharing of documents for ShareDocumentsRequest")
public class ShareDocumentsRequestSharingStopped implements DataType {

public static final ShareDocumentsRequestSharingStopped EXAMPLE = new ShareDocumentsRequestSharingStopped();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@XmlSchema(namespace = DIGIPOST_DATATYPES_NAMESPACE, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlJavaTypeAdapters({
@XmlJavaTypeAdapter(ZonedDateTimeXmlAdapter.class),
@XmlJavaTypeAdapter(LocalDateTimeXmlAdapter.class)
})
@DataTypePackage
package no.digipost.api.datatypes.types.share;

import no.digipost.api.datatypes.documentation.DataTypePackage;
import no.digipost.api.datatypes.marshalling.LocalDateTimeXmlAdapter;
import no.digipost.api.datatypes.marshalling.ZonedDateTimeXmlAdapter;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;

import static no.digipost.api.datatypes.marshalling.DataTypesJAXBContext.DIGIPOST_DATATYPES_NAMESPACE;

3 changes: 3 additions & 0 deletions src/main/resources/no/digipost/api/datatypes/types/jaxb.index
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ pickup.PickupNoticeStatus
invoice.Invoice
invoice.InvoicePayment
Inkasso
share.ShareDocumentsRequest
share.ShareDocumentsRequestSharingStopped
share.ShareDocumentsRequestDocumentsShared

0 comments on commit 332a229

Please sign in to comment.