Skip to content

Commit a86be17

Browse files
committed
Merge pull request #79 from digipost/SplittRecipient
Splitt recipient og fiks Identification
2 parents 872c8e0 + 4529fb9 commit a86be17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+786
-916
lines changed

Digipost.Api.Client.ConcurrencyTest/DigipostRunner.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ public IMessage GetMessage()
5050
{
5151
if (_message != null) return _message;
5252

53-
var primaryDocument = new Document("document subject", "txt", GetDocumentBytes());
54-
var recipientByNameAndAddress = new RecipientByNameAndAddress("Ola Nordmann", "0460",
53+
var primaryDocument = new Document("document subject", "txt", GetDocumentBytes());
54+
var digitalRecipientWithFallbackPrint = new RecipientByNameAndAddress("Ola Nordmann", "0460",
5555
"Oslo", "Collettsgate 68");
56-
57-
var digitalRecipientWithFallbackPrint = new Recipient(recipientByNameAndAddress);
5856
_message = new Message(digitalRecipientWithFallbackPrint, primaryDocument);
5957
}
6058

@@ -66,7 +64,7 @@ public IIdentification GetIdentification()
6664
lock (_lock)
6765
{
6866
if (_identification != null) return _identification;
69-
_identification = new Identification(IdentificationChoiceType.PersonalidentificationNumber, "01013300001");
67+
_identification = new Identification(new RecipientById(IdentificationType.PersonalIdentificationNumber, "01013300001"));
7068
}
7169

7270
return _identification;

Digipost.Api.Client.Domain/DataTransferObjects/IdentificationDataTransferObject.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public IdentificationDataTransferObject(IdentificationChoiceType identificationC
3232
/// <summary>
3333
/// Identify if recipient exists in Digipost by name and address.
3434
/// </summary>
35-
public IdentificationDataTransferObject(RecipientByNameAndAddress recipientByNameAndAddress)
35+
public IdentificationDataTransferObject(RecipientByNameAndAddressDataTranferObject recipientByNameAndAddressDataTranferObject)
3636
{
37-
IdentificationValue = recipientByNameAndAddress;
37+
IdentificationValue = recipientByNameAndAddressDataTranferObject;
3838
IdentificationType = IdentificationChoiceType.NameAndAddress;
3939
}
4040

@@ -44,7 +44,7 @@ private IdentificationDataTransferObject()
4444
}
4545

4646
[XmlElement("digipost-address", typeof (string))]
47-
[XmlElement("name-and-address", typeof (RecipientByNameAndAddress))]
47+
[XmlElement("name-and-address", typeof (RecipientByNameAndAddressDataTranferObject))]
4848
[XmlElement("organisation-number", typeof (string))]
4949
[XmlElement("personal-identification-number", typeof (string))]
5050
[XmlChoiceIdentifier("IdentificationType")]

Digipost.Api.Client.Domain/DataTransferObjects/MessageDataTransferObject.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ private MessageDataTransferObject()
1818
/**Must exist for serialization.**/
1919
}
2020

21-
public MessageDataTransferObject(RecipientDataTransferObject recipient, DocumentDataTransferObject primaryDocumentDataTransferObject)
21+
public MessageDataTransferObject(RecipientDataTransferObject recipientDataTransferObject, DocumentDataTransferObject primaryDocumentDataTransferObject)
2222
{
23-
Recipient = recipient;
23+
RecipientDataTransferObject = recipientDataTransferObject;
2424
PrimaryDocumentDataTransferObject = primaryDocumentDataTransferObject;
2525
Attachments = new List<DocumentDataTransferObject>();
2626
}
2727

28-
public MessageDataTransferObject(RecipientDataTransferObject recipient, DocumentDataTransferObject primaryDocumentDataTransferObject, string senderId):
29-
this(recipient, primaryDocumentDataTransferObject)
28+
public MessageDataTransferObject(RecipientDataTransferObject recipientDataTransferObject, DocumentDataTransferObject primaryDocumentDataTransferObject, string senderId):
29+
this(recipientDataTransferObject, primaryDocumentDataTransferObject)
3030
{
3131
SenderId = senderId;
3232
}
@@ -35,7 +35,7 @@ public MessageDataTransferObject(RecipientDataTransferObject recipient, Document
3535
public string SenderId { get; set; }
3636

3737
[XmlElement("recipient")]
38-
public RecipientDataTransferObject Recipient { get; set; }
38+
public RecipientDataTransferObject RecipientDataTransferObject { get; set; }
3939

4040
[XmlElement("delivery-time")]
4141
public DateTime? DeliveryTime { get; set; }

Digipost.Api.Client.Domain/DataTransferObjects/RecipientDataTransferObject.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ private RecipientDataTransferObject()
1919
/**Must exist for serialization.**/
2020
}
2121

22-
public RecipientDataTransferObject(RecipientByNameAndAddress recipientByNameAndAddress, PrintDetailsDataTransferObject printDetailsDataTransferObject = null)
22+
public RecipientDataTransferObject(RecipientByNameAndAddressDataTranferObject recipientByNameAndAddressDataTranferObject, PrintDetailsDataTransferObject printDetailsDataTransferObject = null)
2323
{
24-
IdentificationValue = recipientByNameAndAddress;
24+
IdentificationValue = recipientByNameAndAddressDataTranferObject;
2525
IdentificationType = IdentificationChoiceType.NameAndAddress;
2626
PrintDetailsDataTransferObject = printDetailsDataTransferObject;
2727
}
@@ -39,7 +39,7 @@ public RecipientDataTransferObject(PrintDetailsDataTransferObject printDetailsDa
3939
}
4040

4141
[XmlElement("digipost-address", typeof (string))]
42-
[XmlElement("name-and-address", typeof (RecipientByNameAndAddress))]
42+
[XmlElement("name-and-address", typeof (RecipientByNameAndAddressDataTranferObject))]
4343
[XmlElement("organisation-number", typeof (string))]
4444
[XmlElement("personal-identification-number", typeof (string))]
4545
[XmlChoiceIdentifier("IdentificationType")]

Digipost.Api.Client.Domain/Digipost.Api.Client.Domain.csproj

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@
4040
<SignAssembly>true</SignAssembly>
4141
</PropertyGroup>
4242
<ItemGroup>
43-
<Reference Include="ApiClientShared">
44-
<HintPath>..\packages\api-client-shared.1.0.5637.25994\lib\net45\ApiClientShared.dll</HintPath>
45-
</Reference>
4643
<Reference Include="System" />
4744
<Reference Include="System.Core" />
4845
<Reference Include="System.Xml" />
@@ -51,15 +48,17 @@
5148
<Compile Include="..\SharedAssemblyInfo.cs">
5249
<Link>Properties\SharedAssemblyInfo.cs</Link>
5350
</Compile>
51+
<Compile Include="DigipostRecipient.cs" />
5452
<Compile Include="DataTransferObjects\MessageDeliveryResult.cs" />
5553
<Compile Include="Enums\IdentificationType.cs" />
56-
<Compile Include="Identify\Identification.cs" />
54+
<Compile Include="Extensions\IdentificationTypeExtensions.cs" />
5755
<Compile Include="Enums\IdentificationError.cs" />
58-
<Compile Include="Identify\IdentificationById.cs" />
59-
<Compile Include="Identify\IdentificationByNameAndAddress.cs" />
56+
<Compile Include="Identify\Identification.cs" />
6057
<Compile Include="Identify\IdentificationResult.cs" />
6158
<Compile Include="Identify\IIdentification.cs" />
59+
<Compile Include="Identify\IIdentificationRecipient.cs" />
6260
<Compile Include="Identify\IIdentificationResult.cs" />
61+
<Compile Include="IDigipostRecipient.cs" />
6362
<Compile Include="IError.cs" />
6463
<Compile Include="Print\Address.cs" />
6564
<Compile Include="Print\ForeignAddress.cs" />
@@ -80,12 +79,12 @@
8079
<Compile Include="Search\ISearchDetailsResult.cs" />
8180
<Compile Include="Search\SearchDetails.cs" />
8281
<Compile Include="SendMessage\IMessageDeliveryResult.cs" />
83-
<Compile Include="SendMessage\IRecipient.cs" />
8482
<Compile Include="SendMessage\Document.cs" />
8583
<Compile Include="SendMessage\IDocument.cs" />
8684
<Compile Include="SendMessage\IInvoice.cs" />
8785
<Compile Include="SendMessage\IMessage.cs" />
8886
<Compile Include="SendMessage\Invoice.cs" />
87+
<Compile Include="SendMessage\IRecipientById.cs" />
8988
<Compile Include="SendMessage\IRecipientByNameAndAddress.cs" />
9089
<Compile Include="SendMessage\ISmsNotification.cs" />
9190
<Compile Include="SendMessage\Message.cs" />
@@ -125,17 +124,15 @@
125124
<Compile Include="DataTransferObjects\PrintReturnRecipientDataTransferObject.cs" />
126125
<Compile Include="Properties\AssemblyInfo.cs" />
127126
<Compile Include="Enums\SensitivityLevel.cs" />
128-
<Compile Include="SendMessage\Recipient.cs" />
129127
<Compile Include="DataTransferObjects\RecipientDataTransferObject.cs" />
130-
<Compile Include="SendMessage\RecipientByNameAndAddress.cs" />
128+
<Compile Include="SendMessage\RecipientById.cs" />
129+
<Compile Include="SendMessage\RecipientByNameAndAddressDataTranferObject.cs" />
131130
<Compile Include="DataTransferObjects\SmsNotificationDataTransferObject.cs" />
132131
<Compile Include="RequestContent.cs" />
132+
<Compile Include="SendMessage\RecipientByNameAndAddress.cs" />
133133
<Compile Include="SendMessage\SmsNotification.cs" />
134134
<Compile Include="Utilities\DataTransferObjectConverter.cs" />
135135
</ItemGroup>
136-
<ItemGroup>
137-
<None Include="packages.config" />
138-
</ItemGroup>
139136
<ItemGroup />
140137
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
141138
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Digipost.Api.Client.Domain
2+
{
3+
public abstract class DigipostRecipient : IDigipostRecipient
4+
{
5+
6+
}
7+
}

Digipost.Api.Client.Domain/Enums/IdentificationChoiceType.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
namespace Digipost.Api.Client.Domain.Enums
55
{
6-
[Obsolete("Use IdentificationChoice, as this will be hidden in future version.")] //Make enum DataTransferObject, as IdenticficationChoice is exposed out.
76
[Serializable]
87
[XmlType(Namespace = "http://api.digipost.no/schema/v6", IncludeInSchema = false)]
98
public enum IdentificationChoiceType
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using Digipost.Api.Client.Domain.Enums;
3+
4+
namespace Digipost.Api.Client.Domain.Extensions
5+
{
6+
public static class IdentificationTypeExtensions
7+
{
8+
internal static IdentificationChoiceType ToIdentificationChoiceType(this IdentificationType identificationType)
9+
{
10+
var identificationChoiceType =
11+
identificationType == IdentificationType.OrganizationNumber
12+
? OrganizationEnumWithSpellingDifference()
13+
: ParseEnumIgnoreCasing(identificationType);
14+
15+
return identificationChoiceType;
16+
}
17+
18+
private static IdentificationChoiceType ParseEnumIgnoreCasing(IdentificationType identificationType)
19+
{
20+
return (IdentificationChoiceType) Enum.Parse(typeof(IdentificationChoiceType), identificationType.ToString(), ignoreCase: true);
21+
}
22+
23+
internal static IdentificationChoiceType OrganizationEnumWithSpellingDifference()
24+
{
25+
return IdentificationChoiceType.OrganisationNumber;
26+
}
27+
28+
}
29+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Digipost.Api.Client.Domain
2+
{
3+
public interface IDigipostRecipient
4+
{
5+
6+
}
7+
}

Digipost.Api.Client.Domain/Identify/IIdentification.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ namespace Digipost.Api.Client.Domain.Identify
44
{
55
public interface IIdentification : IRequestContent
66
{
7-
object Data { get; }
8-
9-
IdentificationChoiceType IdentificationChoiceType { get; }
7+
DigipostRecipient DigipostRecipient { get; set; }
8+
109
}
1110
}

0 commit comments

Comments
 (0)