Skip to content

Commit

Permalink
Merge pull request #106 from digipost/sendEpost
Browse files Browse the repository at this point in the history
Added email recipient in message
  • Loading branch information
Christian Strandenæs authored Sep 7, 2021
2 parents 8adc5d3 + 39f7d69 commit 203f069
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright (C) Posten Norge AS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package no.digipost.api.client.representations;

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


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "email-details", propOrder = {
"emailAddress"
})
public class EmailDetails
{

@XmlElement(name = "email-address", required = true)
protected String emailAddress;

public EmailDetails() {
}

public EmailDetails(final String emailAddress) {
this.emailAddress = emailAddress;
}

public String getEmailAddress() {
return emailAddress;
}


public void setEmailAddress(String value) {
this.emailAddress = value;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public MessageBuilder recipient(OrganisationNumber organisationNumber) {
public MessageBuilder recipient(NameAndAddress nameAndAddress) {
return recipient(new MessageRecipient(nameAndAddress));
}

public MessageBuilder recipient(PeppolAddresses peppolAddresses) {
return recipient(new MessageRecipient(peppolAddresses));
}
Expand Down Expand Up @@ -223,29 +223,29 @@ public static Message copyMessageWithOnlyPrintDetails(Message messageToCopy){

return new Message(messageToCopy.messageId, messageToCopy.senderId, messageToCopy.senderOrganization,
null, null, null, null, messageToCopy.deliveryTime, messageToCopy.invoiceReference,
messageToCopy.primaryDocument.copyDocumentAndSetDigipostFileTypeToPdf(), tmpAttachments, messageToCopy.recipient.getPrintDetails(), null, null, null);
messageToCopy.primaryDocument.copyDocumentAndSetDigipostFileTypeToPdf(), tmpAttachments, messageToCopy.recipient.getPrintDetails(), null, null, null, null);
}

public static Message copyMessageWithOnlyDigipostDetails(Message messageToCopy){
return new Message(messageToCopy.messageId, messageToCopy.senderId, messageToCopy.senderOrganization,
messageToCopy.recipient.nameAndAddress, messageToCopy.recipient.digipostAddress,
messageToCopy.recipient.personalIdentificationNumber, messageToCopy.recipient.organisationNumber,
messageToCopy.deliveryTime, messageToCopy.invoiceReference, messageToCopy.primaryDocument,
messageToCopy.attachments, null, messageToCopy.recipient.bankAccountNumber,
messageToCopy.printIfUnread, messageToCopy.recipient.peppolAddresses);
messageToCopy.attachments, null, messageToCopy.recipient.bankAccountNumber,
messageToCopy.printIfUnread, messageToCopy.recipient.peppolAddresses, messageToCopy.recipient.emailDetails);
}

private Message(final String messageId, final Long senderId, final SenderOrganization senderOrganization,
final NameAndAddress nameAndAddress, final String digipostAddress, String personalIdentificationNumber,
final String organisationNumber, final ZonedDateTime deliveryTime, final String invoiceReference,
final Document primaryDocument, final List<Document> attachments, final PrintDetails printDetails, final String bankAccountNumber,
final PrintIfUnread printIfUnread, final PeppolAddresses peppolAddresses
final PrintIfUnread printIfUnread, final PeppolAddresses peppolAddresses, final EmailDetails emailDetails
){
this.messageId = messageId;
this.senderId = senderId;
this.senderOrganization = senderOrganization;
MessageRecipient recipient = new MessageRecipient(nameAndAddress, digipostAddress,
peppolAddresses, personalIdentificationNumber, organisationNumber, printDetails, bankAccountNumber);
peppolAddresses, personalIdentificationNumber, organisationNumber, printDetails, bankAccountNumber, emailDetails);
this.recipient = recipient;
this.deliveryTime = deliveryTime;
this.invoiceReference = invoiceReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"personalIdentificationNumber",
"organisationNumber",
"printDetails",
"bankAccountNumber"
"bankAccountNumber",
"emailDetails"
})
public class MessageRecipient {

Expand All @@ -49,6 +50,8 @@ public class MessageRecipient {
protected PrintDetails printDetails;
@XmlElement(name = "bank-account-number", nillable = false)
protected String bankAccountNumber;
@XmlElement(name = "email-details", nillable = false)
protected EmailDetails emailDetails;

public MessageRecipient() {
}
Expand All @@ -61,6 +64,7 @@ public MessageRecipient() {
, String organisationNumber
, PrintDetails printDetails
, String bankAccountNumber
, EmailDetails emailDetails
) {
this.nameAndAddress = nameAndAddress;
this.digipostAddress = digipostAddress;
Expand All @@ -69,6 +73,7 @@ public MessageRecipient() {
this.organisationNumber = organisationNumber;
this.printDetails = printDetails;
this.bankAccountNumber = bankAccountNumber;
this.emailDetails = emailDetails;
}

public MessageRecipient(final PersonalIdentificationNumber id) {
Expand Down Expand Up @@ -115,6 +120,10 @@ public MessageRecipient(final OrganisationNumber organisationNumber, final Print
this.printDetails = printDetails;
}

public MessageRecipient(final EmailDetails emailDetails) {
this.emailDetails = emailDetails;
}

public MessageRecipient(final PrintDetails printDetails) {
this.printDetails = printDetails;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/xsd/api_v7.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1312,4 +1312,10 @@
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="email-details">
<xsd:sequence>
<xsd:element name="email-address" minOccurs="1" maxOccurs="1" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>

</xsd:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void assertThatClassesHaveNotBeenChangedWithoutChangingMessageCopyMethod(
}

Field[] recipientFields = MessageRecipient.class.getDeclaredFields();
assertThat(recipientFields.length, is(7));
assertThat(recipientFields.length, is(8));
}

@Test
Expand Down

0 comments on commit 203f069

Please sign in to comment.