From e3edcc2ef4170c49fd3640279cbfc737f3c7d848 Mon Sep 17 00:00:00 2001 From: Mats Byrkjeland Date: Wed, 1 Nov 2023 11:56:09 +0100 Subject: [PATCH] Use seconds instead of ISO 8601 for "max share duration" --- datatypes-examples.xml | 2 +- datatypes.xsd | 2 +- readme.md | 4 ++-- .../marshalling/DurationXmlAdapter.java | 24 ------------------- .../types/share/ShareDocumentsRequest.java | 7 +++--- .../datatypes/types/share/package-info.java | 4 +--- 6 files changed, 8 insertions(+), 35 deletions(-) delete mode 100644 src/main/java/no/digipost/api/datatypes/marshalling/DurationXmlAdapter.java diff --git a/datatypes-examples.xml b/datatypes-examples.xml index 9887d43..84a1bc1 100644 --- a/datatypes-examples.xml +++ b/datatypes-examples.xml @@ -392,7 +392,7 @@ - PT2160H + 1209600 We require to see your latest pay slip in order to grant you a loan. diff --git a/datatypes.xsd b/datatypes.xsd index b18e3de..fed70bb 100644 --- a/datatypes.xsd +++ b/datatypes.xsd @@ -486,7 +486,7 @@ - + diff --git a/readme.md b/readme.md index 98f8a8c..69322fb 100644 --- a/readme.md +++ b/readme.md @@ -1090,14 +1090,14 @@ A request for a user to share one or more documents |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| +|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 - PT2160H + 1209600 We require to see your latest pay slip in order to grant you a loan. ``` diff --git a/src/main/java/no/digipost/api/datatypes/marshalling/DurationXmlAdapter.java b/src/main/java/no/digipost/api/datatypes/marshalling/DurationXmlAdapter.java deleted file mode 100644 index a1f3cd4..0000000 --- a/src/main/java/no/digipost/api/datatypes/marshalling/DurationXmlAdapter.java +++ /dev/null @@ -1,24 +0,0 @@ -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 index 640aa74..f593b15 100644 --- a/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequest.java +++ b/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequest.java @@ -11,7 +11,6 @@ import javax.validation.constraints.NotNull; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import java.time.Duration; @XmlRootElement(name = "share-documents-request") @Value @@ -21,10 +20,10 @@ @Description("A request for a user to share one or more documents") public class ShareDocumentsRequest implements DataType { - @XmlElement(name="max-share-duration", required = true) + @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") - Duration maxShareDuration; + Long maxShareDurationSeconds; @XmlElement(name="purpose", required = true) @NotNull @@ -32,7 +31,7 @@ public class ShareDocumentsRequest implements DataType { String purpose; public static final ShareDocumentsRequest EXAMPLE = new ShareDocumentsRequest( - Duration.ofDays(90), + 14 * 24 * 60 * 60L, "We require to see your latest pay slip in order to grant you a loan." ); 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 index 3320e59..0c5168d 100644 --- 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 @@ -2,14 +2,12 @@ @XmlAccessorType(XmlAccessType.FIELD) @XmlJavaTypeAdapters({ @XmlJavaTypeAdapter(ZonedDateTimeXmlAdapter.class), - @XmlJavaTypeAdapter(LocalDateTimeXmlAdapter.class), - @XmlJavaTypeAdapter(DurationXmlAdapter.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.DurationXmlAdapter; import no.digipost.api.datatypes.marshalling.LocalDateTimeXmlAdapter; import no.digipost.api.datatypes.marshalling.ZonedDateTimeXmlAdapter;