private static void FromAPIToSDK(Objects.Verify verify, VerifyAPIObject verifyApiObject) { long recipient; string recipientEmail = null; if (!long.TryParse(verifyApiObject.Recipient, out recipient)) { recipientEmail = verifyApiObject.Recipient; } verify.Id = verifyApiObject.Id; verify.Href = verifyApiObject.Href; verify.Recipient = recipient; verify.RecipientEmail = recipientEmail; verify.Reference = verifyApiObject.Reference; verify.Message = verifyApiObject.Message; verify.Status = verifyApiObject.Status; verify.Created = verifyApiObject.Created; verify.ValidUntil = verifyApiObject.ValidUntil; verify.Originator = verifyApiObject.Originator; verify.Template = verifyApiObject.Template; verify.Encoding = verifyApiObject.Encoding; verify.TokenLength = verifyApiObject.TokenLength; verify.Type = verifyApiObject.Type; verify.Timeout = verifyApiObject.Timeout; verify.Voice = verifyApiObject.Voice; verify.Language = verifyApiObject.Language; }
public override void Deserialize(string resource) { if (Object == null) { throw new ErrorException("Invalid resource, has no attached object", new NullReferenceException()); } try { var verifyApiObject = new VerifyAPIObject(); JsonConvert.PopulateObject(resource, verifyApiObject); FromAPIToSDK((Objects.Verify)Object, verifyApiObject); } catch (JsonSerializationException e) { throw new ErrorException("Received response in an unexpected format!", e); } }