22using System . Collections . Generic ;
33using System . Collections . ObjectModel ;
44using System . Linq ;
5+ using Digipost . Api . Client . Common . Entrypoint ;
56using Digipost . Api . Client . Common . Enums ;
67using Digipost . Api . Client . Common . Extensions ;
78using Digipost . Api . Client . Common . Identify ;
89using Digipost . Api . Client . Common . Print ;
910using Digipost . Api . Client . Common . Recipient ;
1011using Digipost . Api . Client . Common . Search ;
1112using Digipost . Api . Client . Common . SenderInfo ;
12- using Digipost . Api . Client . Common . Extensions ;
13+ using Digipost . Api . Client . Common . Share ;
1314using Digipost . Api . Client . Send ;
1415using V8 ;
1516using Identification = V8 . Identification ;
1617using Link = Digipost . Api . Client . Common . Entrypoint . Link ;
17- using Root = Digipost . Api . Client . Common . Entrypoint . Root ;
1818
1919namespace 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}
0 commit comments