Skip to content

Commit

Permalink
Et første utkast til ny datatype for hentelapper (Sender, Recipient, …
Browse files Browse the repository at this point in the history
…PickupPoint og noen andre felter)

Noen designtanker:
Mottager, avsender og hente-sted har alle adresser i en eller annen
form. Jeg tenker at vi like gjerne kan generalisere dette
selv om f.eks hente-sted (pickup-place) ikke har gateadresse slik
det ser ut av xml-eksempler jeg har sett fra posten.
  • Loading branch information
eivinhb committed Oct 8, 2018
1 parent 24e1a66 commit be8f415
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 0 deletions.
84 changes: 84 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
|[Category](#category)|Category is a way to specify which category the data of a document is related to.|
|[ExternalLink](#externallink)|An external URL, along with an optional description and deadline for resources such as a survey.|
|[Payslip](#payslip)|For treating documents as Payslips.|
|[PickupNotice](#pickupnotice)|Details about a signed document|
|[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|
|[SignedDocument](#signeddocument)|Details about a signed document|
Expand Down Expand Up @@ -213,6 +214,89 @@ For treating documents as Payslips.
<payslip xmlns="http://api.digipost.no/schema/datatypes"/>
```

## PickupNotice

Details about a signed document

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|
|parcelId|String|yes|The id of the parcel in posten|
|parcelUUID|String|yes|The uuid of the parcel|
|barcode|Barcode|yes|Bar code|
|recipient|[Recipient](#recipient)|yes|The recipient of the parcel|
|sender|[Sender](#sender)|yes|The sender of the parcel|
|pickupPlace|[PickupPlace](#pickupplace)|yes|where the parcel can be fetched|

### Recipient

|Name|Type|Required|Description|
|----|----|--------|-----------|
|digipostAddress|String|yes|The digipost address for the recipient|
|address|Address|no||
|emailAdress|String|no||

### Sender

|Name|Type|Required|Description|
|----|----|--------|-----------|
|reference|String|yes|The senders reference|
|address|Address|no||

### PickupPlace

|Name|Type|Required|Description|
|----|----|--------|-----------|
|name|String|yes|The pickup place name|
|id|String|yes|The pickup place id|
|instruction|String|yes|instructions for fetching the parcel|
|address|Address|no||

### XML

```xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<pickupNotice xmlns="http://api.digipost.no/schema/datatypes">
<parcel-id>KB432788293NO</parcel-id>
<parcel-uuid>70300492517312675</parcel-uuid>
<bar-code>
<barcode-value>1234567890</barcode-value>
<barcode-type>EAN-128</barcode-type>
</bar-code>
<recipient>
<digipost-address>test.testesen#0000</digipost-address>
<address>
<street-address>Storgata 23</street-address>
<postal-code>0011</postal-code>
<city>Oslo</city>
<country>Norge</country>
</address>
<email-address>[email protected]</email-address>
</recipient>
<sender>
<reference>13372500</reference>
<address>
<street-address>Storgata 23</street-address>
<postal-code>0011</postal-code>
<city>Oslo</city>
<country>Norge</country>
</address>
</sender>
<pickup-place>
<name>0132</name>
<id>Coop Mega</id>
<instruction>Må hentes innen 010180</instruction>
<address>
<street-address>Storgata 23</street-address>
<postal-code>0011</postal-code>
<city>Oslo</city>
<country>Norge</country>
</address>
</pickup-place>
</pickupNotice>
```

## Receipt

Receipt represents a document containing details about a purchase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package no.digipost.api.datatypes;

import no.digipost.api.datatypes.types.*;
import no.digipost.api.datatypes.types.pickup.PickupNotice;
import no.digipost.api.datatypes.types.receipt.Receipt;

import java.util.Map;
Expand Down Expand Up @@ -29,6 +30,7 @@ public enum DataTypeIdentifier {
RECEIPT(Receipt.class, "RCPT", Receipt.EXAMPLE),
PAYSLIP(Payslip.class, "PAY", Payslip.EXAMPLE),
SIGNED_DOCUMENT(SignedDocument.class, "SIGN", SignedDocument.EXAMPLE),
PICKUP_NOTICE(PickupNotice.class, "PKUP", PickupNotice.EXAMPLE),
;

private final Class<? extends DataType> dataType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package no.digipost.api.datatypes.types.pickup;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.experimental.Wither;
import no.digipost.api.datatypes.DataType;
import no.digipost.api.datatypes.documentation.Description;
import no.digipost.api.datatypes.types.Address;
import no.digipost.api.datatypes.types.Info;
import no.digipost.api.datatypes.types.receipt.Barcode;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@XmlRootElement
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@Wither
@Description("Details about a signed document")
public class PickupNotice implements DataType {

@XmlElement(name = "parcel-id", required = true)
@Description("The id of the parcel in posten")
String parcelId;

@XmlElement(name = "parcel-uuid", required = true)
@Description("The uuid of the parcel")
String parcelUUID;

@XmlElement(name = "bar-code", required = true)
@Description("Bar code")
Barcode barcode;

@XmlElement(name = "recipient", required = true)
@Description("The recipient of the parcel")
Recipient recipient;

@XmlElement(name = "sender", required = true)
@Description("The sender of the parcel")
Sender sender;

@XmlElement(name = "pickup-place", required = true)
@Description("where the parcel can be fetched")
PickupPlace pickupPlace;

public static PickupNotice EXAMPLE = new PickupNotice(
"KB432788293NO"
, "70300492517312675"
, Barcode.EXAMPLE.withBarcodeType("EAN-128")
, Recipient.EXAMPLE
, Sender.EXAMPLE
, PickupPlace.EXAMPLE
);
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package no.digipost.api.datatypes.types.pickup;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.experimental.Wither;
import no.digipost.api.datatypes.documentation.Description;
import no.digipost.api.datatypes.types.Address;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

@XmlType
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@Wither
public class PickupPlace {

@XmlElement(name = "name", required = true)
@Description("The pickup place name")
String name;

@XmlElement(name = "id", required = true)
@Description("The pickup place id")
String id;

@XmlElement(name = "instruction", required = true)
@Description("instructions for fetching the parcel")
String instruction;

@XmlElement
Address address;

public static final PickupPlace EXAMPLE = new PickupPlace("0132", "Coop Mega", "Må hentes innen 010180", Address.EXAMPLE);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package no.digipost.api.datatypes.types.pickup;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.experimental.Wither;
import no.digipost.api.datatypes.documentation.Description;
import no.digipost.api.datatypes.types.Address;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

@XmlType
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@Wither
public class Recipient {

@XmlElement(name = "digipost-address", required = true)
@Description("The digipost address for the recipient")
String digipostAddress;

@XmlElement
Address address;

@XmlElement(name = "email-address")
String emailAdress;

public static final Recipient EXAMPLE = new Recipient("test.testesen#0000", Address.EXAMPLE, "[email protected]");

}
30 changes: 30 additions & 0 deletions src/main/java/no/digipost/api/datatypes/types/pickup/Sender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package no.digipost.api.datatypes.types.pickup;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.experimental.Wither;
import no.digipost.api.datatypes.documentation.Description;
import no.digipost.api.datatypes.types.Address;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

@XmlType
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@Wither
public class Sender {

@XmlElement(name = "reference", required = true)
@Description("The senders reference")
String reference;

@XmlElement
Address address;

public static final Sender EXAMPLE = new Sender("13372500", Address.EXAMPLE);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@XmlSchema(namespace = DIGIPOST_DATATYPES_NAMESPACE, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlJavaTypeAdapter(ZonedDateTimeXmlAdapter.class)
package no.digipost.api.datatypes.types.pickup;

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 static no.digipost.api.datatypes.marshalling.DataTypesJAXBContext.DIGIPOST_DATATYPES_NAMESPACE;
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Boligdetaljer
receipt.Receipt
Payslip
SignedDocument
pickup.PickupNotice

0 comments on commit be8f415

Please sign in to comment.