Skip to content

Commit 60bf502

Browse files
authored
Merge pull request #210 from digipost/share_document
Share document
2 parents 94ac9b1 + 63c900d commit 60bf502

File tree

21 files changed

+964
-17
lines changed

21 files changed

+964
-17
lines changed

Digipost.Api.Client.Common/DataTransferObjectConverter.cs

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
using System.Collections.Generic;
33
using System.Collections.ObjectModel;
44
using System.Linq;
5+
using Digipost.Api.Client.Common.Entrypoint;
56
using Digipost.Api.Client.Common.Enums;
67
using Digipost.Api.Client.Common.Extensions;
78
using Digipost.Api.Client.Common.Identify;
89
using Digipost.Api.Client.Common.Print;
910
using Digipost.Api.Client.Common.Recipient;
1011
using Digipost.Api.Client.Common.Search;
1112
using Digipost.Api.Client.Common.SenderInfo;
12-
using Digipost.Api.Client.Common.Extensions;
13+
using Digipost.Api.Client.Common.Share;
1314
using Digipost.Api.Client.Send;
1415
using V8;
1516
using Identification = V8.Identification;
1617
using Link = Digipost.Api.Client.Common.Entrypoint.Link;
17-
using Root = Digipost.Api.Client.Common.Entrypoint.Root;
1818

1919
namespace Digipost.Api.Client.Common
2020
{
@@ -182,15 +182,15 @@ internal static Print_Details ToDataTransferObject(this IPrintDetails printDetai
182182
return printDetailsDataTransferObject;
183183
}
184184

185-
internal static List<Print_Instruction> ToDataTransferObject(this IPrintInstructions printInstructions)
185+
private static List<Print_Instruction> ToDataTransferObject(this IPrintInstructions printInstructions)
186186
{
187187
if (printInstructions == null || printInstructions.PrintInstruction.Count == 0)
188188
return new List<Print_Instruction>();
189189

190190
return printInstructions.PrintInstruction.Select(ToDataTransferObject).ToList();
191191
}
192192

193-
internal static Print_Instruction ToDataTransferObject(IPrintInstruction printInstruction)
193+
private static Print_Instruction ToDataTransferObject(IPrintInstruction printInstruction)
194194
{
195195
if (printInstruction == null)
196196
return null;
@@ -273,7 +273,8 @@ internal static Foreign_Address ToDataTransferObject(this IForeignAddress foreig
273273
if (foreignAddress.CountryIdentifier == CountryIdentifier.Country)
274274
{
275275
result.Country = foreignAddress.CountryIdentifierValue;
276-
} else if (foreignAddress.CountryIdentifier == CountryIdentifier.Countrycode)
276+
}
277+
else if (foreignAddress.CountryIdentifier == CountryIdentifier.Countrycode)
277278
{
278279
result.Country_Code = foreignAddress.CountryIdentifierValue;
279280
}
@@ -361,6 +362,7 @@ internal static IIdentificationResult FromDataTransferObject(this Identification
361362
{
362363
return new IdentificationResult(IdentificationResultType.InvalidReason, identificationResultDto.Invalid_Reason.ToString());
363364
}
365+
364366
if (identificationResultDto.Unidentified_ReasonSpecified)
365367
{
366368
return new IdentificationResult(IdentificationResultType.UnidentifiedReason, identificationResultDto.Unidentified_Reason.ToString());
@@ -384,6 +386,7 @@ private static IdentificationResult IdentificationResultForDigipostOrPersonalIde
384386
default:
385387
throw new ArgumentOutOfRangeException();
386388
}
389+
387390
return identificationResult;
388391
}
389392

@@ -397,7 +400,7 @@ internal static Error FromDataTransferObject(this V8.Error error)
397400
};
398401
}
399402

400-
internal static SearchDetailsResult FromDataTransferObject(this V8.Recipients recipients)
403+
internal static SearchDetailsResult FromDataTransferObject(this Recipients recipients)
401404
{
402405
return new SearchDetailsResult
403406
{
@@ -424,5 +427,43 @@ internal static SearchDetailsResult FromDataTransferObject(this V8.Recipients re
424427
};
425428
}
426429

430+
431+
internal static ShareDocumentsRequestState FromDataTransferObject(this Share_Documents_Request_State dto)
432+
{
433+
return new ShareDocumentsRequestState(
434+
dto.Shared_At_TimeSpecified ? dto.Shared_At_Time : (DateTime?) null,
435+
dto.Expiry_TimeSpecified ? dto.Expiry_Time : (DateTime?) null,
436+
dto.Withdrawn_TimeSpecified ? dto.Withdrawn_Time : (DateTime?) null,
437+
dto.Shared_Documents.FromDataTransferObject(),
438+
dto.Link.FromDataTransferObject()
439+
);
440+
}
441+
442+
private static IEnumerable<SharedDocument> FromDataTransferObject(this Collection<Shared_Document> dto)
443+
{
444+
return dto.Select(document => new SharedDocument(
445+
document.Delivery_Time,
446+
document.Subject,
447+
document.File_Type,
448+
Convert.ToInt32(document.File_Size_Bytes),
449+
document.Origin.FromDataTransferObject(),
450+
document.Link.FromDataTransferObject()
451+
)).ToList();
452+
}
453+
454+
private static IOrigin FromDataTransferObject(this Shared_Document_Origin dto)
455+
{
456+
if (dto.Organisation != null)
457+
{
458+
return new OrganisationOrigin(dto.Organisation.Name, dto.Organisation.Organisation_Number);
459+
}
460+
461+
return new PrivatePersonOrigin(dto.Private_Person.Name);
462+
}
463+
464+
internal static SharedDocumentContent FromDataTransferObject(this Shared_Document_Content dto)
465+
{
466+
return new SharedDocumentContent(dto.Content_Type, new Uri(dto.Uri, UriKind.Absolute));
467+
}
427468
}
428469
}

Digipost.Api.Client.Common/Entrypoint/Entrypoint.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public DocumentStatusUri GetDocumentStatusUri(Guid guid)
8989
{
9090
return new DocumentStatusUri(Links["DOCUMENT_STATUS"], guid);
9191
}
92+
93+
public ShareDocumentsRequestStateUri GetShareDocumentsRequestStateUri(Guid guid)
94+
{
95+
return new ShareDocumentsRequestStateUri(Links["GET_SHARE_DOCUMENTS_REQUEST_STATE"], guid);
96+
}
9297
}
9398

9499
public class Link

0 commit comments

Comments
 (0)