/// <summary> /// Convert from SDK AttachmentRequirement to API AttachmentRequirement. /// </summary> /// <returns>The API attachment requirement.</returns> public OneSpanSign.API.AttachmentRequirement ToAPIAttachmentRequirement() { if (sdkAttachmentRequirement == null) { return(apiAttachmentRequirement); } OneSpanSign.API.AttachmentRequirement result = new OneSpanSign.API.AttachmentRequirement(); if (!String.IsNullOrEmpty(sdkAttachmentRequirement.Id)) { result.Id = sdkAttachmentRequirement.Id; } result.Name = sdkAttachmentRequirement.Name; result.Comment = sdkAttachmentRequirement.SenderComment; result.Description = sdkAttachmentRequirement.Description; result.Required = sdkAttachmentRequirement.Required; result.Data = sdkAttachmentRequirement.Data; result.Files = GetApiAttachmentFiles(); if (sdkAttachmentRequirement.Status.Equals(null)) { result.Status = OneSpanSign.Sdk.RequirementStatus.INCOMPLETE.getApiValue(); } else { result.Status = new RequirementStatusConverter(sdkAttachmentRequirement.Status).ToAPIRequirementStatus(); } return(result); }
public void ConvertAPIToSDK() { apiRole = CreateTypicalAPIRole(); apiSigner1 = apiRole.Signers[0]; sdkSigner1 = new SignerConverter(apiRole).ToSDKSigner(); Assert.IsNotNull(sdkSigner1); Assert.AreEqual(apiSigner1.Email, sdkSigner1.Email); Assert.AreEqual(apiSigner1.FirstName, sdkSigner1.FirstName); Assert.AreEqual(apiSigner1.LastName, sdkSigner1.LastName); Assert.AreEqual(apiSigner1.Company, sdkSigner1.Company); Assert.AreEqual(apiSigner1.SignerType, sdkSigner1.SignerType); Assert.AreEqual(apiSigner1.Title, sdkSigner1.Title); Assert.AreEqual(apiSigner1.Language, sdkSigner1.Language); Assert.AreEqual(apiRole.Id, sdkSigner1.Id); Assert.AreEqual(apiRole.Index, sdkSigner1.SigningOrder); Assert.AreEqual(apiRole.Reassign, sdkSigner1.CanChangeSigner); Assert.AreEqual(apiRole.EmailMessage.Content, sdkSigner1.Message); Assert.AreEqual(apiSigner1.Delivery.Email, sdkSigner1.DeliverSignedDocumentsByEmail); string attachmentName = apiRole.AttachmentRequirements[0].Name; OneSpanSign.API.AttachmentRequirement apiAttachment = apiRole.AttachmentRequirements[0]; OneSpanSign.Sdk.AttachmentRequirement sdkAttachment = sdkSigner1.GetAttachmentRequirement(attachmentName); Assert.AreEqual(attachmentName, sdkSigner1.GetAttachmentRequirement(attachmentName).Name); Assert.AreEqual(apiAttachment.Description, sdkAttachment.Description); Assert.AreEqual(apiAttachment.Required, sdkAttachment.Required); Assert.AreEqual(apiAttachment.Status.ToString(), sdkAttachment.Status.ToString()); Assert.AreEqual(apiAttachment.Comment, sdkAttachment.SenderComment); }
public void ConvertSDKToAPIWhenSdkAttachmentRequirementIsNull() { sdkAttachmentRequirement1 = CreateTypicalSDKAttachmentRequirement(); sdkAttachmentRequirement1.Id = null; apiAttachmentRequirement1 = new AttachmentRequirementConverter(sdkAttachmentRequirement1).ToAPIAttachmentRequirement(); Assert.IsNull(apiAttachmentRequirement1.Id); }
public void ConvertAPIToAPI() { apiAttachmentRequirement1 = CreateTypicalAPIAttachmentRequirement(); apiAttachmentRequirement2 = new AttachmentRequirementConverter(apiAttachmentRequirement1).ToAPIAttachmentRequirement(); Assert.IsNotNull(apiAttachmentRequirement2); Assert.AreEqual(apiAttachmentRequirement2, apiAttachmentRequirement1); }
private OneSpanSign.API.AttachmentRequirement CreateTypicalAPIAttachmentRequirement() { OneSpanSign.API.AttachmentRequirement attachmentRequirement = new OneSpanSign.API.AttachmentRequirement(); attachmentRequirement.Name = "Driver's license"; attachmentRequirement.Id = "attachment1"; attachmentRequirement.Description = "Please upload a scanned copy of your driver's license"; attachmentRequirement.Required = true; return(attachmentRequirement); }
public void ConvertSDKToAPI() { sdkAttachmentRequirement1 = CreateTypicalSDKAttachmentRequirement(); apiAttachmentRequirement1 = new AttachmentRequirementConverter(sdkAttachmentRequirement1).ToAPIAttachmentRequirement(); Assert.AreEqual(apiAttachmentRequirement1.Name, sdkAttachmentRequirement1.Name); Assert.AreEqual(apiAttachmentRequirement1.Description, sdkAttachmentRequirement1.Description); Assert.AreEqual(apiAttachmentRequirement1.Id, sdkAttachmentRequirement1.Id); Assert.AreEqual(apiAttachmentRequirement1.Required, sdkAttachmentRequirement1.Required); Assert.AreEqual(apiAttachmentRequirement1.Status, sdkAttachmentRequirement1.Status.ToString()); Assert.AreEqual(apiAttachmentRequirement1.Comment, sdkAttachmentRequirement1.SenderComment); }
public void ConvertAPIToSDK() { apiAttachmentRequirement1 = CreateTypicalAPIAttachmentRequirement(); sdkAttachmentRequirement1 = new AttachmentRequirementConverter(apiAttachmentRequirement1).ToSDKAttachmentRequirement(); Assert.AreEqual(sdkAttachmentRequirement1.Name, apiAttachmentRequirement1.Name); Assert.AreEqual(sdkAttachmentRequirement1.Description, apiAttachmentRequirement1.Description); Assert.AreEqual(sdkAttachmentRequirement1.Id, apiAttachmentRequirement1.Id); Assert.AreEqual(sdkAttachmentRequirement1.Required, apiAttachmentRequirement1.Required); Assert.AreEqual(sdkAttachmentRequirement1.Status.getApiValue(), apiAttachmentRequirement1.Status); Assert.AreEqual(sdkAttachmentRequirement1.SenderComment, apiAttachmentRequirement1.Comment); }
private OneSpanSign.API.Role CreateTypicalAPIRole() { OneSpanSign.API.Role apiRole = new OneSpanSign.API.Role(); OneSpanSign.API.Signer apiSigner = new OneSpanSign.API.Signer(); apiSigner.Email = "*****@*****.**"; apiSigner.FirstName = "Signer first name"; apiSigner.LastName = "Signer last name"; apiSigner.Company = "ABC Inc."; apiSigner.SignerType = "THIRD_PARTY_SIGNER"; apiSigner.Language = "fr"; apiSigner.Title = "Doctor"; OneSpanSign.API.Delivery delivery = new OneSpanSign.API.Delivery(); delivery.Download = true; delivery.Email = true; apiSigner.Delivery = delivery; apiSigner.Id = "1"; apiRole.AddSigner(apiSigner); apiRole.Id = "3"; apiRole.Name = "Signer name"; apiRole.Index = 0; apiRole.Reassign = true; OneSpanSign.API.BaseMessage baseMessage = new OneSpanSign.API.BaseMessage(); baseMessage.Content = "Base message content."; apiRole.EmailMessage = baseMessage; apiRole.Locked = true; OneSpanSign.API.AttachmentRequirement attachmentRequirement = new OneSpanSign.API.AttachmentRequirement(); attachmentRequirement.Name = "Driver's license"; attachmentRequirement.Description = "Please upload your scanned driver's license."; attachmentRequirement.Status = OneSpanSign.Sdk.RequirementStatus.INCOMPLETE.getApiValue(); attachmentRequirement.Required = true; attachmentRequirement.Comment = "Attachment was not uploaded"; apiRole.AddAttachmentRequirement(attachmentRequirement); return(apiRole); }
/// <summary> /// Construct with API AttachmentRequirement object involved in conversion. /// </summary> /// <param name="apiAttachmentRequirement">API attachment requirement.</param> public AttachmentRequirementConverter(OneSpanSign.API.AttachmentRequirement apiAttachmentRequirement) { this.apiAttachmentRequirement = apiAttachmentRequirement; }
public void ConvertNullAPIToAPI() { apiAttachmentRequirement1 = null; converter = new AttachmentRequirementConverter(apiAttachmentRequirement1); Assert.IsNull(converter.ToAPIAttachmentRequirement()); }