Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify allowed organisation numbers for document sharing #76

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions datatypes-examples.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@
<share-documents-request xmlns="http://api.digipost.no/schema/datatypes">
<max-share-duration-seconds>1209600</max-share-duration-seconds>
<purpose>We require to see your latest pay slip in order to grant you a loan.</purpose>
<allowed-origin-organisation-numbers>984661185</allowed-origin-organisation-numbers>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bare en heads-up på at du har navngitt selve elementet, som kan opptre ingen eller flere ganger, i flertall.
Altså at hvert orgnr. er et "numbers".

<allowed-origin-organisation-numbers>984661185</allowed-origin-organisation-numbers>
<allowed-origin-organisation-numbers>984661186</allowed-origin-organisation-numbers>
<allowed-origin-organisation-numbers>984661187</allowed-origin-organisation-numbers>

Det er nok mer korrekt å navngi elementet som angir ett orgnr i entall, og tillate flere av de (som du allerede gjør).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jeg tenkte på det, men valgte å følge samme scheme som allerede var gjort for tags:

 <xs:element maxOccurs="unbounded" minOccurs="0" name="tags" type="tns:tag"/>

Åpen for at det var et dårlig valg, men det er i det minste konsistent 😅 Eller overser jeg noe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, det er allerede etablert konvensjon. Nei, skal ikke legge meg opp i det, men et element som angir 1 verdi er nok riktigst å navngi som nettopp en verdi, også kan elementet opptre flere ganger. JAXB har også innebygget støtte for å generere f.eks. Set<Tag> tags, altså at den slenger på flertalls-S på generert feltnavn når maxOccurs > 1 i XSD-en.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ja enig 🙌

Jeg har noen ganger valgt å wrappe slike tilfeller i en egen type, f.eks ala

<xsd:complexType name="shared-documents">
    <xsd:sequence>
	<xsd:element name="shared-document" type="shared-document" minOccurs="0" maxOccurs="unbounded" />
    </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="shared-document">
    <xsd:sequence>
	<xsd:element name="delivery-time" type="xsd:dateTime" />
	<xsd:element name="file-type" type="xsd:string" />
        ...
    </xsd:sequence>
</xsd:complexType>

Samme kunne f.eks vært gjort her med tags og tag, allowed-...-numbers og allowed-...-number osv.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ja absolutt, det er ofte røddig det! For det så har du jo også @XmlElementWrapper i JAXB som gjør at du kan unngå en ekstra klasse som uansett bare inneholder en collection av elementer.

</share-documents-request>

<share-documents-request-documents-shared xmlns="http://api.digipost.no/schema/datatypes">
Expand Down
1 change: 1 addition & 0 deletions datatypes.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@
<xs:sequence>
<xs:element name="max-share-duration-seconds" type="xs:long"/>
<xs:element name="purpose" type="xs:string"/>
<xs:element maxOccurs="10" minOccurs="0" name="allowed-origin-organisation-numbers" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType final="extension restriction" name="shareDocumentsRequestDocumentsShared">
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1096,13 +1096,15 @@ A request for a user to share one or more documents
|----|----|--------|-----------|
|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.|
|allowedOriginOrganisationNumbers|Set|no|Only documents received from any of the specified organisations will be possible for the user to share.|

### XML

```xml
<share-documents-request xmlns="http://api.digipost.no/schema/datatypes">
<max-share-duration-seconds>1209600</max-share-duration-seconds>
<purpose>We require to see your latest pay slip in order to grant you a loan.</purpose>
<allowed-origin-organisation-numbers>984661185</allowed-origin-organisation-numbers>
</share-documents-request>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import no.digipost.api.datatypes.DataType;
import no.digipost.api.datatypes.documentation.Description;

import java.util.Set;

@XmlRootElement(name = "share-documents-request")
@Value
@AllArgsConstructor
Expand All @@ -31,9 +33,14 @@ public class ShareDocumentsRequest implements DataType {
@Description("This text should explain why you need to process the recipient's documents in a short and understandable way.")
String purpose;

@XmlElement(name="allowed-origin-organisation-numbers", required = false)
@Description("Only documents received from any of the specified organisations will be possible for the user to share.")
Set<String> allowedOriginOrganisationNumbers;

public static final ShareDocumentsRequest EXAMPLE = new ShareDocumentsRequest(
14 * 24 * 60 * 60L,
"We require to see your latest pay slip in order to grant you a loan."
"We require to see your latest pay slip in order to grant you a loan.",
Set.of("984661185")
);

}
Loading