33using System . Linq ;
44using System . Xml ;
55using Digipost . Api . Client . Common ;
6+ using Digipost . Api . Client . Common . Enums ;
67using Digipost . Api . Client . Common . Extensions ;
78using V8 ;
89
@@ -86,16 +87,16 @@ public static V8.Document ToDataTransferObject(IDocument document)
8687 return documentDto ;
8788 }
8889
89- public static V8 . Sms_Notification ToDataTransferObject ( ISmsNotification smsNotification )
90+ public static Sms_Notification ToDataTransferObject ( ISmsNotification smsNotification )
9091 {
9192 if ( smsNotification == null )
9293 return null ;
9394
94- var smsNotificationDto = new V8 . Sms_Notification ( ) ;
95+ var smsNotificationDto = new Sms_Notification ( ) ;
9596
9697 if ( smsNotification . NotifyAtTimes . Count > 0 )
9798 {
98- var timesAsListedTimes = smsNotification . NotifyAtTimes . Select ( dateTime => new V8 . Listed_Time { Time = dateTime , TimeSpecified = true } ) ;
99+ var timesAsListedTimes = smsNotification . NotifyAtTimes . Select ( dateTime => new Listed_Time { Time = dateTime , TimeSpecified = true } ) ;
99100 foreach ( var timesAsListedTime in timesAsListedTimes )
100101 {
101102 smsNotificationDto . At . Add ( timesAsListedTime ) ;
@@ -113,7 +114,7 @@ public static V8.Sms_Notification ToDataTransferObject(ISmsNotification smsNotif
113114 return smsNotificationDto ;
114115 }
115116
116- public static IMessageDeliveryResult FromDataTransferObject ( V8 . Message_Delivery messageDeliveryDto )
117+ public static IMessageDeliveryResult FromDataTransferObject ( Message_Delivery messageDeliveryDto )
117118 {
118119 IMessageDeliveryResult messageDeliveryResult = new MessageDeliveryResult
119120 {
@@ -138,7 +139,7 @@ public static IDocument FromDataTransferObject(V8.Document documentDto)
138139 } ;
139140 }
140141
141- public static ISmsNotification FromDataTransferObject ( V8 . Sms_Notification smsNotificationDto )
142+ public static ISmsNotification FromDataTransferObject ( Sms_Notification smsNotificationDto )
142143 {
143144 if ( smsNotificationDto == null )
144145 return null ;
@@ -151,5 +152,47 @@ public static ISmsNotification FromDataTransferObject(V8.Sms_Notification smsNot
151152
152153 return smsNotification ;
153154 }
155+
156+ public static DocumentStatus FromDataTransferObject ( Document_Status dto )
157+ {
158+ return new DocumentStatus (
159+ dto . Uuid ,
160+ dto . Sender_Id ,
161+ dto . Created ,
162+ dto . Status . ToDeliveryStatus ( ) ,
163+ dto . ReadSpecified ? dto . Read . ToRead ( ) : ( DocumentStatus . Read ? ) null ,
164+ dto . Channel . ToDeliveryMethod ( ) ,
165+ dto . Content_Hash ,
166+ dto . DeliveredSpecified ? dto . Delivered : ( DateTime ? ) null ,
167+ dto . Is_Primary_DocumentSpecified ? dto . Is_Primary_Document : ( bool ? ) null ,
168+ dto . Content_Hash_AlgorithmSpecified ? dto . Content_Hash_Algorithm . ToHashAlgoritm ( ) : ( HashAlgoritm ? ) null
169+ ) ;
170+ }
171+
172+ private static DocumentStatus . DocumentDeliveryStatus ToDeliveryStatus ( this Delivery_Status deliveryStatus )
173+ {
174+ switch ( deliveryStatus )
175+ {
176+ case Delivery_Status . DELIVERED :
177+ return DocumentStatus . DocumentDeliveryStatus . DELIVERED ;
178+ case Delivery_Status . NOT_DELIVERED :
179+ return DocumentStatus . DocumentDeliveryStatus . NOT_DELIVERED ;
180+ default :
181+ throw new ArgumentOutOfRangeException ( ) ;
182+ }
183+ }
184+
185+ private static DocumentStatus . Read ToRead ( this Read read )
186+ {
187+ switch ( read )
188+ {
189+ case Read . Y :
190+ return DocumentStatus . Read . YES ;
191+ case Read . N :
192+ return DocumentStatus . Read . NO ;
193+ default :
194+ throw new ArgumentOutOfRangeException ( ) ;
195+ }
196+ }
154197 }
155198}
0 commit comments