From 742fdf692a54e39da12d708288777de799279d11 Mon Sep 17 00:00:00 2001 From: Herman Wika Horn Date: Fri, 10 Nov 2023 12:10:25 +0100 Subject: [PATCH] Replace ShareDoccumentsRequestEvent with separate classes for each action --- datatypes-examples.xml | 8 +-- datatypes.xsd | 27 +++++----- readme.md | 37 ++++++++----- .../api/datatypes/DataTypeIdentifier.java | 7 ++- .../types/share/ShareDocumentsRequest.java | 2 +- .../ShareDocumentsRequestDocumentsShared.java | 37 +++++++++++++ .../share/ShareDocumentsRequestEvent.java | 54 ------------------- .../share/ShareDocumentsRequestEventType.java | 6 --- .../ShareDocumentsRequestSharingStopped.java | 22 ++++++++ .../digipost/api/datatypes/types/jaxb.index | 3 +- 10 files changed, 106 insertions(+), 97 deletions(-) create mode 100644 src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestDocumentsShared.java delete mode 100644 src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestEvent.java delete mode 100644 src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestEventType.java create mode 100644 src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestSharingStopped.java diff --git a/datatypes-examples.xml b/datatypes-examples.xml index 84a1bc1..60dae2b 100644 --- a/datatypes-examples.xml +++ b/datatypes-examples.xml @@ -396,11 +396,11 @@ We require to see your latest pay slip in order to grant you a loan. - - FILES_SHARED - 2017-09-30T13:37:00+02:00 + 123 - + + + Bedrift AS diff --git a/datatypes.xsd b/datatypes.xsd index fed70bb..27a5089 100644 --- a/datatypes.xsd +++ b/datatypes.xsd @@ -29,7 +29,9 @@ - + + + @@ -491,29 +493,31 @@ - + - - + + + + - + - - - + + + @@ -524,11 +528,4 @@ - - - - - - - diff --git a/readme.md b/readme.md index 69322fb..df70766 100644 --- a/readme.md +++ b/readme.md @@ -16,7 +16,8 @@ |[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| -|[ShareDocumentsRequestEvent](#sharedocumentsrequestevent)|An update or event related to a ShareDocumentsRequest| +|[ShareDocumentsRequestDocumentsShared](#sharedocumentsrequestdocumentsshared)|Documents have been shared for ShareDocumentsRequest| +|[ShareDocumentsRequestSharingStopped](#sharedocumentsrequestsharingstopped)|Stop sharing of documents for ShareDocumentsRequest| |[SignedDocument](#signeddocument)|Details about a signed document| ## Appointment @@ -1086,6 +1087,9 @@ Residence is a way of linking separate data for the same residence A request for a user to share one or more documents +### Complemented by: +[ShareDocumentsRequestSharingStopped](#sharedocumentsrequestsharingstopped) + ### Fields |Name|Type|Required|Description| @@ -1102,33 +1106,38 @@ A request for a user to share one or more documents ``` -## ShareDocumentsRequestEvent +## ShareDocumentsRequestDocumentsShared -An update or event related to a ShareDocumentsRequest +Documents have been shared for ShareDocumentsRequest ### Fields |Name|Type|Required|Description| |----|----|--------|-----------| -|eventType|[ShareDocumentsRequestEventType](#sharedocumentsrequesteventsharedocumentsrequesteventtype)|yes|The type of event that has occurred| -|timestamp|ZonedDateTime|yes|When the event occurred| |documentIds|List|no|The IDs of the documents related to this specific event| -### ShareDocumentsRequestEvent.ShareDocumentsRequestEventType +### XML -Valid values: +```xml + + 123 + +``` + +## ShareDocumentsRequestSharingStopped + +Stop sharing of documents for ShareDocumentsRequest + +### Fields + +|Name|Type|Required|Description| +|----|----|--------|-----------| -* FILES_SHARED -* SHARING_STOPPED ### XML ```xml - - FILES_SHARED - 2017-09-30T13:37:00+02:00 - 123 - + ``` ## SignedDocument diff --git a/src/main/java/no/digipost/api/datatypes/DataTypeIdentifier.java b/src/main/java/no/digipost/api/datatypes/DataTypeIdentifier.java index c739653..315647a 100644 --- a/src/main/java/no/digipost/api/datatypes/DataTypeIdentifier.java +++ b/src/main/java/no/digipost/api/datatypes/DataTypeIdentifier.java @@ -27,7 +27,9 @@ import static java.util.stream.Collectors.collectingAndThen; import static java.util.stream.Collectors.toMap; import static java.util.stream.Collectors.toSet; -import no.digipost.api.datatypes.types.share.ShareDocumentsRequestEvent; + +import no.digipost.api.datatypes.types.share.ShareDocumentsRequestDocumentsShared; +import no.digipost.api.datatypes.types.share.ShareDocumentsRequestSharingStopped; /** * HOWTO: Add new data type @@ -53,7 +55,8 @@ public enum DataTypeIdentifier { , INVOICE(Invoice.class, "INVO", Invoice.EXAMPLE) , INVOICE_PAYMENT(InvoicePayment.class, "INVP", InvoicePayment.EXAMPLE) , SHARE_DOCUMENT_REQUEST(ShareDocumentsRequest.class, "SHAR", ShareDocumentsRequest.EXAMPLE) - , SHARE_DOCUMENT_REQUEST_EVENT(ShareDocumentsRequestEvent.class, "SHRE", ShareDocumentsRequestEvent.EXAMPLE) + , SHARE_DOCUMENT_REQUEST_SHARING_STOPPED(ShareDocumentsRequestSharingStopped.class, "SHSS", ShareDocumentsRequestSharingStopped.EXAMPLE) + , SHARE_DOCUMENT_REQUEST_DOCUMENTS_SHARED(ShareDocumentsRequestDocumentsShared.class, "SHDS", ShareDocumentsRequestDocumentsShared.EXAMPLE) ; private final Class dataType; 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 8149d05..41fdb1d 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 @@ -19,7 +19,7 @@ @NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) @With @Description("A request for a user to share one or more documents") -@ComplementedBy({ShareDocumentsRequestEvent.class}) +@ComplementedBy({ShareDocumentsRequestSharingStopped.class}) public class ShareDocumentsRequest implements DataType { @XmlElement(name="max-share-duration-seconds", required = true) diff --git a/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestDocumentsShared.java b/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestDocumentsShared.java new file mode 100644 index 0000000..1880e24 --- /dev/null +++ b/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestDocumentsShared.java @@ -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 documentIds; + + public static final ShareDocumentsRequestDocumentsShared EXAMPLE = createExample(); + + private static ShareDocumentsRequestDocumentsShared createExample() { + List documentIds = new ArrayList<>(1); + documentIds.add(123L); + return new ShareDocumentsRequestDocumentsShared( + documentIds + ); + } +} diff --git a/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestEvent.java b/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestEvent.java deleted file mode 100644 index 80ba5fe..0000000 --- a/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestEvent.java +++ /dev/null @@ -1,54 +0,0 @@ -package no.digipost.api.datatypes.types.share; - -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.List; -import javax.validation.constraints.NotNull; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlSchemaType; -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; - -@XmlRootElement(name = "share-documents-request-event") -@Value -@AllArgsConstructor -@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) -@With -@Description("An update or event related to a ShareDocumentsRequest") -public class ShareDocumentsRequestEvent implements DataType { - - @XmlElement(name="event-type", required = true) - @NotNull - @Description("The type of event that has occurred") - ShareDocumentsRequestEventType eventType; - - @XmlElement(name = "timestamp", required = true) - @XmlSchemaType(name="dateTime") - @Description("When the event occurred") - ZonedDateTime timestamp; - - @XmlElement(name = "document-ids") - @Description("The IDs of the documents related to this specific event") - List documentIds; - - public static final ShareDocumentsRequestEvent EXAMPLE = createExample(); - - private static ShareDocumentsRequestEvent createExample() { - List documentIds = new ArrayList<>(1); - documentIds.add(123L); - - return new ShareDocumentsRequestEvent( - ShareDocumentsRequestEventType.FILES_SHARED, - ZonedDateTime.of(2017, 9, 30, 13, 37, 0, 0, ZoneId.of("+02:00")), - documentIds - ); - } - -} diff --git a/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestEventType.java b/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestEventType.java deleted file mode 100644 index 044c091..0000000 --- a/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestEventType.java +++ /dev/null @@ -1,6 +0,0 @@ -package no.digipost.api.datatypes.types.share; - -public enum ShareDocumentsRequestEventType { - FILES_SHARED, - SHARING_STOPPED -} diff --git a/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestSharingStopped.java b/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestSharingStopped.java new file mode 100644 index 0000000..cff3400 --- /dev/null +++ b/src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequestSharingStopped.java @@ -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.PRIVATE) +@With +@Description("Stop sharing of documents for ShareDocumentsRequest") +public class ShareDocumentsRequestSharingStopped implements DataType { + + public static final ShareDocumentsRequestSharingStopped EXAMPLE = new ShareDocumentsRequestSharingStopped(); + +} 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 e3de262..e338896 100644 --- a/src/main/resources/no/digipost/api/datatypes/types/jaxb.index +++ b/src/main/resources/no/digipost/api/datatypes/types/jaxb.index @@ -13,4 +13,5 @@ invoice.Invoice invoice.InvoicePayment Inkasso share.ShareDocumentsRequest -share.ShareDocumentsRequestEvent +share.ShareDocumentsRequestSharingStopped +share.ShareDocumentsRequestDocumentsShared