From e64d9406879ede7d558e192a9723a346b46a5bfb Mon Sep 17 00:00:00 2001 From: Ingeborg Sollid Date: Tue, 3 Oct 2023 13:38:26 +0200 Subject: [PATCH] Add new datatype ShareDocumentsRequest --- datatypes-examples.xml | 4 +++ datatypes.xsd | 8 +++++ readme.md | 19 ++++++++++++ .../api/datatypes/DataTypeIdentifier.java | 2 ++ .../marshalling/DurationXmlAdapter.java | 24 ++++++++++++++ .../types/share/ShareDocumentsRequest.java | 31 +++++++++++++++++++ .../datatypes/types/share/package-info.java | 23 ++++++++++++++ .../digipost/api/datatypes/types/jaxb.index | 1 + 8 files changed, 112 insertions(+) create mode 100644 src/main/java/no/digipost/api/datatypes/marshalling/DurationXmlAdapter.java create mode 100644 src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequest.java create mode 100644 src/main/java/no/digipost/api/datatypes/types/share/package-info.java diff --git a/datatypes-examples.xml b/datatypes-examples.xml index 97edf381..c83f130b 100644 --- a/datatypes-examples.xml +++ b/datatypes-examples.xml @@ -391,6 +391,10 @@ externalId + + PT2160H + + Bedrift AS Ansettelseskontrakt diff --git a/datatypes.xsd b/datatypes.xsd index 19ce8701..a66f02fa 100644 --- a/datatypes.xsd +++ b/datatypes.xsd @@ -27,6 +27,8 @@ + + @@ -480,6 +482,12 @@ + + + + + + diff --git a/readme.md b/readme.md index a845323a..97eac634 100644 --- a/readme.md +++ b/readme.md @@ -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 @@ -1080,6 +1081,24 @@ Residence is a way of linking separate data for the same 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 + + PT2160H + +``` + ## SignedDocument Details about a signed document diff --git a/src/main/java/no/digipost/api/datatypes/DataTypeIdentifier.java b/src/main/java/no/digipost/api/datatypes/DataTypeIdentifier.java index ef6cfee0..e70fa530 100644 --- a/src/main/java/no/digipost/api/datatypes/DataTypeIdentifier.java +++ b/src/main/java/no/digipost/api/datatypes/DataTypeIdentifier.java @@ -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; @@ -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 dataType; diff --git a/src/main/java/no/digipost/api/datatypes/marshalling/DurationXmlAdapter.java b/src/main/java/no/digipost/api/datatypes/marshalling/DurationXmlAdapter.java new file mode 100644 index 00000000..a1f3cd4f --- /dev/null +++ b/src/main/java/no/digipost/api/datatypes/marshalling/DurationXmlAdapter.java @@ -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 { + + + @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(); + } +} diff --git a/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequest.java b/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequest.java new file mode 100644 index 00000000..98b533bf --- /dev/null +++ b/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequest.java @@ -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)); + +} diff --git a/src/main/java/no/digipost/api/datatypes/types/share/package-info.java b/src/main/java/no/digipost/api/datatypes/types/share/package-info.java new file mode 100644 index 00000000..3320e59d --- /dev/null +++ b/src/main/java/no/digipost/api/datatypes/types/share/package-info.java @@ -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; + diff --git a/src/main/resources/no/digipost/api/datatypes/types/jaxb.index b/src/main/resources/no/digipost/api/datatypes/types/jaxb.index index 4c438149..818aebbe 100644 --- a/src/main/resources/no/digipost/api/datatypes/types/jaxb.index +++ b/src/main/resources/no/digipost/api/datatypes/types/jaxb.index @@ -12,3 +12,4 @@ pickup.PickupNoticeStatus invoice.Invoice invoice.InvoicePayment Inkasso +share.ShareDocumentsRequest