Skip to content

Commit

Permalink
Add new datatype ShareDocumentsRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
isollid committed Oct 3, 2023
1 parent a513d18 commit e64d940
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 0 deletions.
4 changes: 4 additions & 0 deletions datatypes-examples.xml
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@
<external-id>externalId</external-id>
</residence>

<shareDocumentsRequest xmlns="http://api.digipost.no/schema/datatypes">
<max-share-duration>PT2160H</max-share-duration>
</shareDocumentsRequest>

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

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

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

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

<xs:complexType final="extension restriction" name="address">
Expand Down Expand Up @@ -480,6 +482,12 @@
</xs:sequence>
</xs:complexType>

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

<xs:simpleType name="language">
<xs:restriction base="xs:string">
<xs:enumeration value="NB"/>
Expand Down
19 changes: 19 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
|[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|
|[SignedDocument](#signeddocument)|Details about a signed document|

## Appointment
Expand Down Expand Up @@ -1080,6 +1081,24 @@ 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

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|
|maxShareDuration|Duration|yes|This is the maximum duration in which you are allowed to access the user's documents from they are shared with you|

### XML

```xml
<shareDocumentsRequest xmlns="http://api.digipost.no/schema/datatypes">
<max-share-duration>PT2160H</max-share-duration>
</shareDocumentsRequest>
```

## 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 Down Expand Up @@ -50,6 +51,7 @@ 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)
;

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

import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.time.Duration;

public class DurationXmlAdapter extends XmlAdapter<String, Duration> {


@Override
public Duration unmarshal(String s) {
if (s == null) {
return null;
}
return Duration.parse(s);
}

@Override
public String marshal(Duration duration) {
if (duration == null) {
return null;
}
return duration.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.time.Duration;

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

@XmlElement(name="max-share-duration", 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")
Duration maxShareDuration;

public static final ShareDocumentsRequest EXAMPLE = new ShareDocumentsRequest(Duration.ofDays(90));

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

import no.digipost.api.datatypes.documentation.DataTypePackage;
import no.digipost.api.datatypes.marshalling.DurationXmlAdapter;
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;

Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pickup.PickupNoticeStatus
invoice.Invoice
invoice.InvoicePayment
Inkasso
share.ShareDocumentsRequest

0 comments on commit e64d940

Please sign in to comment.