-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new datatype ShareDocumentsRequest
- Loading branch information
Showing
8 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/no/digipost/api/datatypes/marshalling/DurationXmlAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/no/digipost/api/datatypes/types/share/ShareDocumentsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/no/digipost/api/datatypes/types/share/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ pickup.PickupNoticeStatus | |
invoice.Invoice | ||
invoice.InvoicePayment | ||
Inkasso | ||
share.ShareDocumentsRequest |