Skip to content

Commit

Permalink
Merge pull request #30 from digipost/PickupNotice
Browse files Browse the repository at this point in the history
Pickup notice
  • Loading branch information
velfundert authored Nov 16, 2018
2 parents 2a23c2b + 4481198 commit 56b194f
Show file tree
Hide file tree
Showing 14 changed files with 497 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>digipost-data-types</artifactId>
<version>0.14-SNAPSHOT</version>
<version>0.15-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>Data types for Digipost Messages</description>

Expand Down
153 changes: 153 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 pickup notice|
|[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 All @@ -32,6 +33,7 @@ Appointment represents a meeting set for a specific place and time
|Name|Type|Required|Description|
|----|----|--------|-----------|
|streetAddress|String|no|E.g. Storgata 11|
|streetAddress2|String|no|E.g. Romerike Næringspark|
|postalCode|String|no||
|city|String|no||
|country|String|no||
Expand Down Expand Up @@ -213,6 +215,156 @@ For treating documents as Payslips.
<payslip xmlns="http://api.digipost.no/schema/datatypes"/>
```

## PickupNotice

Details about a pickup notice

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|
|parcelId|String|yes|The id of the parcel in posten|
|parcelUUID|String|no|The uuid of the parcel|
|barcode|[Barcode](#pickupnoticebarcode)|yes|Barcode|
|productName|String|no|Mail Service product name|
|arrivalDateTime|ZonedDateTime|yes|ISO8601 full DateTime for arrival at pickup place|
|returnDateTime|ZonedDateTime|yes|ISO8601 full DateTime for return back to sender|
|recipient|[Recipient](#pickupnoticerecipient)|yes|The recipient of the parcel|
|sender|[Sender](#pickupnoticesender)|no|The sender of the parcel|
|pickupPlace|[PickupPlace](#pickupnoticepickupplace)|yes|where the parcel can be fetched|
|thePackage|[Package](#pickupnoticepackage)|no|package information|
|cost|[Cost](#pickupnoticecost)|no|Information about value, mva, customs processing and more|

### PickupNotice.Barcode

|Name|Type|Required|Description|
|----|----|--------|-----------|
|barcodeValue|String|no|The barcode on this receipt|
|barcodeType|String|no||

### PickupNotice.Recipient

|Name|Type|Required|Description|
|----|----|--------|-----------|
|name|String|yes|The name of the recipient|
|digipostAddress|String|yes|The digipost address for the recipient|
|address|[Address](#pickupnoticeaddress)|no||

### PickupNotice.Address

|Name|Type|Required|Description|
|----|----|--------|-----------|
|streetAddress|String|no|E.g. Storgata 11|
|streetAddress2|String|no|E.g. Romerike Næringspark|
|postalCode|String|no||
|city|String|no||
|country|String|no||

### PickupNotice.Sender

|Name|Type|Required|Description|
|----|----|--------|-----------|
|name|String|no|The senders name|
|reference|String|no|The senders reference|
|address|[Address](#pickupnoticeaddress)|no||

### PickupNotice.PickupPlace

|Name|Type|Required|Description|
|----|----|--------|-----------|
|name|String|yes|The pickup place name|
|code|String|yes|The pickup code|
|instruction|String|yes|instructions for fetching the parcel|
|shelfLocation|String|no|shelf location at pickup point|
|address|[Address](#pickupnoticeaddress)|yes||

### PickupNotice.Package

|Name|Type|Required|Description|
|----|----|--------|-----------|
|length|Integer|no|Package lenght in cm|
|width|Integer|no|Package width in cm|
|height|Integer|no|Package height in cm|
|weight|Integer|no|Package weight in grams|

### PickupNotice.Cost

|Name|Type|Required|Description|
|----|----|--------|-----------|
|valueToBePayed|BigDecimal|yes|The value of the parcel in NOK|
|packageValue|BigDecimal|no|The value of the parcel in NOK|
|customsFeeOutlayed|BigDecimal|no|payed fee in customs|
|vasText|String|no|Information about the value added service (vas)|
|customsFee|BigDecimal|no|Fee payed for customs declaration|
|customsFeeOutlayCost|BigDecimal|no|Outlay for customs by the service|
|codAmount|BigDecimal|no|Cash on delivery (cod) amount|
|codFee|BigDecimal|no|Cash on delivery (cod) fee|

### XML

```xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<pickup-notice xmlns="http://api.digipost.no/schema/datatypes">
<parcel-id>KB432788293NO</parcel-id>
<parcel-uuid>70300492517312675</parcel-uuid>
<barcode>
<barcode-value>1234567890</barcode-value>
<barcode-type>CODE_128</barcode-type>
</barcode>
<product-name>Klimanøytral Servicepakke</product-name>
<arrival-date-time>2018-09-10T10:00:00+02:00</arrival-date-time>
<return-date-time>2018-09-24T10:00:00+02:00</return-date-time>
<recipient>
<name>Test Testesen</name>
<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>
</recipient>
<sender>
<name>Avsenderservice as</name>
<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>Coop Mega</name>
<code>RC89</code>
<instruction>Må hentes innen 010180</instruction>
<shelf-location>H32</shelf-location>
<address>
<street-address>Storgata 23</street-address>
<postal-code>0011</postal-code>
<city>Oslo</city>
<country>Norge</country>
</address>
</pickup-place>
<package>
<length>120</length>
<width>60</width>
<height>60</height>
<weight>35000</weight>
</package>
<cost>
<value-to-be-payed>128.00</value-to-be-payed>
<package-value>1277.00</package-value>
<customs-fee-outlayed>162.00</customs-fee-outlayed>
<vas-text>FORENKLET TOLLBEHANDLING</vas-text>
<customs-fee>0</customs-fee>
<customs-fee-outlay-cost>0</customs-fee-outlay-cost>
<cod-amount>0</cod-amount>
<cod-fee>0</cod-fee>
</cost>
</pickup-notice>
```

## Receipt

Receipt represents a document containing details about a purchase
Expand Down Expand Up @@ -249,6 +401,7 @@ Receipt represents a document containing details about a purchase
|Name|Type|Required|Description|
|----|----|--------|-----------|
|streetAddress|String|no|E.g. Storgata 11|
|streetAddress2|String|no|E.g. Romerike Næringspark|
|postalCode|String|no||
|city|String|no||
|country|String|no||
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
Expand Up @@ -11,6 +11,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.lang.System.lineSeparator;
Expand Down Expand Up @@ -90,7 +91,13 @@ private String printJsonExample(Object example) {
private String printTypeInfo(ComplexType parent, ComplexType type, Set<ComplexType> printed) {
printed.add(type);
return heading(3, parent.getTypeName() + "." + type.getTypeName()) + LLF +
printFields(parent, type.getFields(), printed);
((type.getType().isEnum()) ? printEnum(type.getType()) : printFields(parent, type.getFields(), printed));
}

private String printEnum(Class<?> type) {
String desc = "Valid values:";

return desc + LLF + Stream.of(type.getEnumConstants()).map(s-> "" + s).collect(Collectors.joining(LF, "* ", ""));
}

private String printFields(ComplexType parent, List<FieldInfo> fields, Set<ComplexType> printed) {
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/no/digipost/api/datatypes/types/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public class Address {
@Size(max = 100)
@Description("E.g. Storgata 11")
String streetAddress;

@XmlElement(name = "street-address-2")
@Size(max = 100)
@Description("E.g. Romerike Næringspark")
String streetAddress2;

@XmlElement(name = "postal-code")
@Size(max = 10)
Expand All @@ -34,5 +39,5 @@ public class Address {
@XmlElement
String country;

public static final Address EXAMPLE = new Address("Storgata 23", "0011", "Oslo", "Norge");
public static final Address EXAMPLE = new Address("Storgata 23", null, "0011", "Oslo", "Norge");
}
65 changes: 65 additions & 0 deletions src/main/java/no/digipost/api/datatypes/types/pickup/Cost.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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 javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import java.math.BigDecimal;

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

@XmlElement(name = "value-to-be-payed", required = true)
@Description("The value of the parcel in NOK")
BigDecimal valueToBePayed;

@XmlElement(name = "package-value")
@Description("The value of the parcel in NOK")
BigDecimal packageValue;

@XmlElement(name = "customs-fee-outlayed")
@Description("payed fee in customs")
BigDecimal customsFeeOutlayed;

@XmlElement(name = "vas-text")
@Description("Information about the value added service (vas)")
String vasText;

@XmlElement(name = "customs-fee")
@Description("Fee payed for customs declaration")
BigDecimal customsFee;

@XmlElement(name = "customs-fee-outlay-cost")
@Description("Outlay for customs by the service")
BigDecimal customsFeeOutlayCost;

@XmlElement(name = "cod-amount")
@Description("Cash on delivery (cod) amount")
BigDecimal codAmount;

@XmlElement(name = "cod-fee")
@Description("Cash on delivery (cod) fee")
BigDecimal codFee;


public static final Cost EXAMPLE = new Cost(
new BigDecimal("128.00"),
new BigDecimal("1277.00"),
new BigDecimal("162.00"),
"FORENKLET TOLLBEHANDLING",
BigDecimal.ZERO,
BigDecimal.ZERO,
BigDecimal.ZERO,
BigDecimal.ZERO
);

}
37 changes: 37 additions & 0 deletions src/main/java/no/digipost/api/datatypes/types/pickup/Package.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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 javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

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

@XmlElement(name = "length")
@Description("Package lenght in cm")
Integer length;

@XmlElement(name = "width")
@Description("Package width in cm")
Integer width;

@XmlElement(name = "height")
@Description("Package height in cm")
Integer height;

@XmlElement(name = "weight")
@Description("Package weight in grams")
Integer weight;

public static final Package EXAMPLE = new Package(120, 60, 60, 35000);
}
Loading

0 comments on commit 56b194f

Please sign in to comment.