Skip to content

Commit

Permalink
Merge pull request #79 from digipost/SplittRecipient
Browse files Browse the repository at this point in the history
Splitt recipient og fiks Identification
  • Loading branch information
kristianenge committed Sep 28, 2015
2 parents 872c8e0 + 4529fb9 commit a86be17
Show file tree
Hide file tree
Showing 45 changed files with 786 additions and 916 deletions.
8 changes: 3 additions & 5 deletions Digipost.Api.Client.ConcurrencyTest/DigipostRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ public IMessage GetMessage()
{
if (_message != null) return _message;

var primaryDocument = new Document("document subject", "txt", GetDocumentBytes());
var recipientByNameAndAddress = new RecipientByNameAndAddress("Ola Nordmann", "0460",
var primaryDocument = new Document("document subject", "txt", GetDocumentBytes());
var digitalRecipientWithFallbackPrint = new RecipientByNameAndAddress("Ola Nordmann", "0460",
"Oslo", "Collettsgate 68");

var digitalRecipientWithFallbackPrint = new Recipient(recipientByNameAndAddress);
_message = new Message(digitalRecipientWithFallbackPrint, primaryDocument);
}

Expand All @@ -66,7 +64,7 @@ public IIdentification GetIdentification()
lock (_lock)
{
if (_identification != null) return _identification;
_identification = new Identification(IdentificationChoiceType.PersonalidentificationNumber, "01013300001");
_identification = new Identification(new RecipientById(IdentificationType.PersonalIdentificationNumber, "01013300001"));
}

return _identification;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public IdentificationDataTransferObject(IdentificationChoiceType identificationC
/// <summary>
/// Identify if recipient exists in Digipost by name and address.
/// </summary>
public IdentificationDataTransferObject(RecipientByNameAndAddress recipientByNameAndAddress)
public IdentificationDataTransferObject(RecipientByNameAndAddressDataTranferObject recipientByNameAndAddressDataTranferObject)
{
IdentificationValue = recipientByNameAndAddress;
IdentificationValue = recipientByNameAndAddressDataTranferObject;
IdentificationType = IdentificationChoiceType.NameAndAddress;
}

Expand All @@ -44,7 +44,7 @@ private IdentificationDataTransferObject()
}

[XmlElement("digipost-address", typeof (string))]
[XmlElement("name-and-address", typeof (RecipientByNameAndAddress))]
[XmlElement("name-and-address", typeof (RecipientByNameAndAddressDataTranferObject))]
[XmlElement("organisation-number", typeof (string))]
[XmlElement("personal-identification-number", typeof (string))]
[XmlChoiceIdentifier("IdentificationType")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ private MessageDataTransferObject()
/**Must exist for serialization.**/
}

public MessageDataTransferObject(RecipientDataTransferObject recipient, DocumentDataTransferObject primaryDocumentDataTransferObject)
public MessageDataTransferObject(RecipientDataTransferObject recipientDataTransferObject, DocumentDataTransferObject primaryDocumentDataTransferObject)
{
Recipient = recipient;
RecipientDataTransferObject = recipientDataTransferObject;
PrimaryDocumentDataTransferObject = primaryDocumentDataTransferObject;
Attachments = new List<DocumentDataTransferObject>();
}

public MessageDataTransferObject(RecipientDataTransferObject recipient, DocumentDataTransferObject primaryDocumentDataTransferObject, string senderId):
this(recipient, primaryDocumentDataTransferObject)
public MessageDataTransferObject(RecipientDataTransferObject recipientDataTransferObject, DocumentDataTransferObject primaryDocumentDataTransferObject, string senderId):
this(recipientDataTransferObject, primaryDocumentDataTransferObject)
{
SenderId = senderId;
}
Expand All @@ -35,7 +35,7 @@ public MessageDataTransferObject(RecipientDataTransferObject recipient, Document
public string SenderId { get; set; }

[XmlElement("recipient")]
public RecipientDataTransferObject Recipient { get; set; }
public RecipientDataTransferObject RecipientDataTransferObject { get; set; }

[XmlElement("delivery-time")]
public DateTime? DeliveryTime { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ private RecipientDataTransferObject()
/**Must exist for serialization.**/
}

public RecipientDataTransferObject(RecipientByNameAndAddress recipientByNameAndAddress, PrintDetailsDataTransferObject printDetailsDataTransferObject = null)
public RecipientDataTransferObject(RecipientByNameAndAddressDataTranferObject recipientByNameAndAddressDataTranferObject, PrintDetailsDataTransferObject printDetailsDataTransferObject = null)
{
IdentificationValue = recipientByNameAndAddress;
IdentificationValue = recipientByNameAndAddressDataTranferObject;
IdentificationType = IdentificationChoiceType.NameAndAddress;
PrintDetailsDataTransferObject = printDetailsDataTransferObject;
}
Expand All @@ -39,7 +39,7 @@ public RecipientDataTransferObject(PrintDetailsDataTransferObject printDetailsDa
}

[XmlElement("digipost-address", typeof (string))]
[XmlElement("name-and-address", typeof (RecipientByNameAndAddress))]
[XmlElement("name-and-address", typeof (RecipientByNameAndAddressDataTranferObject))]
[XmlElement("organisation-number", typeof (string))]
[XmlElement("personal-identification-number", typeof (string))]
[XmlChoiceIdentifier("IdentificationType")]
Expand Down
21 changes: 9 additions & 12 deletions Digipost.Api.Client.Domain/Digipost.Api.Client.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<ItemGroup>
<Reference Include="ApiClientShared">
<HintPath>..\packages\api-client-shared.1.0.5637.25994\lib\net45\ApiClientShared.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
Expand All @@ -51,15 +48,17 @@
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="DigipostRecipient.cs" />
<Compile Include="DataTransferObjects\MessageDeliveryResult.cs" />
<Compile Include="Enums\IdentificationType.cs" />
<Compile Include="Identify\Identification.cs" />
<Compile Include="Extensions\IdentificationTypeExtensions.cs" />
<Compile Include="Enums\IdentificationError.cs" />
<Compile Include="Identify\IdentificationById.cs" />
<Compile Include="Identify\IdentificationByNameAndAddress.cs" />
<Compile Include="Identify\Identification.cs" />
<Compile Include="Identify\IdentificationResult.cs" />
<Compile Include="Identify\IIdentification.cs" />
<Compile Include="Identify\IIdentificationRecipient.cs" />
<Compile Include="Identify\IIdentificationResult.cs" />
<Compile Include="IDigipostRecipient.cs" />
<Compile Include="IError.cs" />
<Compile Include="Print\Address.cs" />
<Compile Include="Print\ForeignAddress.cs" />
Expand All @@ -80,12 +79,12 @@
<Compile Include="Search\ISearchDetailsResult.cs" />
<Compile Include="Search\SearchDetails.cs" />
<Compile Include="SendMessage\IMessageDeliveryResult.cs" />
<Compile Include="SendMessage\IRecipient.cs" />
<Compile Include="SendMessage\Document.cs" />
<Compile Include="SendMessage\IDocument.cs" />
<Compile Include="SendMessage\IInvoice.cs" />
<Compile Include="SendMessage\IMessage.cs" />
<Compile Include="SendMessage\Invoice.cs" />
<Compile Include="SendMessage\IRecipientById.cs" />
<Compile Include="SendMessage\IRecipientByNameAndAddress.cs" />
<Compile Include="SendMessage\ISmsNotification.cs" />
<Compile Include="SendMessage\Message.cs" />
Expand Down Expand Up @@ -125,17 +124,15 @@
<Compile Include="DataTransferObjects\PrintReturnRecipientDataTransferObject.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Enums\SensitivityLevel.cs" />
<Compile Include="SendMessage\Recipient.cs" />
<Compile Include="DataTransferObjects\RecipientDataTransferObject.cs" />
<Compile Include="SendMessage\RecipientByNameAndAddress.cs" />
<Compile Include="SendMessage\RecipientById.cs" />
<Compile Include="SendMessage\RecipientByNameAndAddressDataTranferObject.cs" />
<Compile Include="DataTransferObjects\SmsNotificationDataTransferObject.cs" />
<Compile Include="RequestContent.cs" />
<Compile Include="SendMessage\RecipientByNameAndAddress.cs" />
<Compile Include="SendMessage\SmsNotification.cs" />
<Compile Include="Utilities\DataTransferObjectConverter.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
7 changes: 7 additions & 0 deletions Digipost.Api.Client.Domain/DigipostRecipient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Digipost.Api.Client.Domain
{
public abstract class DigipostRecipient : IDigipostRecipient
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace Digipost.Api.Client.Domain.Enums
{
[Obsolete("Use IdentificationChoice, as this will be hidden in future version.")] //Make enum DataTransferObject, as IdenticficationChoice is exposed out.
[Serializable]
[XmlType(Namespace = "http://api.digipost.no/schema/v6", IncludeInSchema = false)]
public enum IdentificationChoiceType
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using Digipost.Api.Client.Domain.Enums;

namespace Digipost.Api.Client.Domain.Extensions
{
public static class IdentificationTypeExtensions
{
internal static IdentificationChoiceType ToIdentificationChoiceType(this IdentificationType identificationType)
{
var identificationChoiceType =
identificationType == IdentificationType.OrganizationNumber
? OrganizationEnumWithSpellingDifference()
: ParseEnumIgnoreCasing(identificationType);

return identificationChoiceType;
}

private static IdentificationChoiceType ParseEnumIgnoreCasing(IdentificationType identificationType)
{
return (IdentificationChoiceType) Enum.Parse(typeof(IdentificationChoiceType), identificationType.ToString(), ignoreCase: true);
}

internal static IdentificationChoiceType OrganizationEnumWithSpellingDifference()
{
return IdentificationChoiceType.OrganisationNumber;
}

}
}
7 changes: 7 additions & 0 deletions Digipost.Api.Client.Domain/IDigipostRecipient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Digipost.Api.Client.Domain
{
public interface IDigipostRecipient
{

}
}
5 changes: 2 additions & 3 deletions Digipost.Api.Client.Domain/Identify/IIdentification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ namespace Digipost.Api.Client.Domain.Identify
{
public interface IIdentification : IRequestContent
{
object Data { get; }

IdentificationChoiceType IdentificationChoiceType { get; }
DigipostRecipient DigipostRecipient { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Digipost.Api.Client.Domain.Identify
{
public interface IIdentificationRecipient
{

}
}
29 changes: 4 additions & 25 deletions Digipost.Api.Client.Domain/Identify/Identification.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
using System;
using Digipost.Api.Client.Domain.Enums;
using Digipost.Api.Client.Domain.SendMessage;

namespace Digipost.Api.Client.Domain.Identify
namespace Digipost.Api.Client.Domain.Identify
{
[Obsolete("Use IdentificationByNameAndAddress or IdentificationById. Will be removed in future version.")]
public class Identification : IIdentification
{
public IdentificationChoiceType IdentificationChoiceType { get; set; }

public IdentificationType IdentificationType
{
get
{
throw new NotImplementedException("Use IdentificationByNameAndAddress or IdentificationById class, as this will be removed in future version.");
}
}

public Identification(IdentificationChoiceType identificationChoiceType, string value)
{
IdentificationChoiceType = identificationChoiceType;
Data = value;
}
public DigipostRecipient DigipostRecipient { get; set; }

public Identification(RecipientByNameAndAddress recipientByNameAndAddress)
public Identification(DigipostRecipient digipostRecipient)
{
Data = recipientByNameAndAddress;
DigipostRecipient = digipostRecipient;
}

public object Data { get; internal set; }
}
}
53 changes: 0 additions & 53 deletions Digipost.Api.Client.Domain/Identify/IdentificationById.cs

This file was deleted.

This file was deleted.

Loading

0 comments on commit a86be17

Please sign in to comment.