Ejemplo n.º 1
0
        public void ConvertSDKSignerWithNullEntriesToAPIRole()
        {
            String roleId = System.Guid.NewGuid().ToString().Replace("-", "");

            sdkSigner1 = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                         .CanChangeSigner()
                         .DeliverSignedDocumentsByEmail()
                         .SigningOrder(1)
                         .WithCompany("ABC Inc.")
                         .WithLanguage("fr")
                         .WithFirstName("first name")
                         .WithLastName("last name")
                         .WithTitle("Miss")
                         .Build();

            apiRole = new SignerConverter(sdkSigner1).ToAPIRole(roleId);

            Assert.IsNotNull(apiRole);
            Assert.AreEqual(apiRole.Signers[0].Email, sdkSigner1.Email);
            Assert.AreEqual(apiRole.Signers[0].FirstName, sdkSigner1.FirstName);
            Assert.AreEqual(apiRole.Signers[0].LastName, sdkSigner1.LastName);
            Assert.AreEqual(apiRole.Signers[0].Company, sdkSigner1.Company);
            Assert.AreEqual(apiRole.Signers[0].Language, sdkSigner1.Language);
            Assert.AreEqual(apiRole.Signers[0].Title, sdkSigner1.Title);
            Assert.AreEqual(apiRole.Id, roleId);
            Assert.AreEqual(apiRole.Name, roleId);
            Assert.IsNull(apiRole.EmailMessage);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public void ConvertNullSDKToAPI()
        {
            sdkSigner1 = null;
            converter  = new SignerConverter(sdkSigner1);

            Assert.IsNull(converter.ToAPISigner());
        }
Ejemplo n.º 4
0
        public void CanAddTwoAttachmentRequirement()
        {
            OneSpanSign.Sdk.AttachmentRequirement attachmentRequirement1 = AttachmentRequirementBuilder.NewAttachmentRequirementWithName("Driver's license")
                                                                           .WithDescription("Please upload scanned driver's license.")
                                                                           .IsRequiredAttachment()
                                                                           .Build();
            OneSpanSign.Sdk.AttachmentRequirement attachmentRequirement2 = AttachmentRequirementBuilder.NewAttachmentRequirementWithName("Medicare card")
                                                                           .WithDescription("Please upload scanned medicare card.")
                                                                           .IsRequiredAttachment()
                                                                           .Build();

            OneSpanSign.Sdk.Signer signer = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                                            .WithFirstName("Billy")
                                            .WithLastName("Bob")
                                            .WithAttachmentRequirement(attachmentRequirement1)
                                            .WithAttachmentRequirement(attachmentRequirement2)
                                            .Build();

            Assert.AreEqual(signer.Attachments.Count, 2);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Name, attachmentRequirement1.Name);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Description, attachmentRequirement1.Description);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Required, attachmentRequirement1.Required);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Status, attachmentRequirement1.Status);
            Assert.AreEqual(signer.GetAttachmentRequirement("Medicare card").Name, attachmentRequirement2.Name);
            Assert.AreEqual(signer.GetAttachmentRequirement("Medicare card").Description, attachmentRequirement2.Description);
            Assert.AreEqual(signer.GetAttachmentRequirement("Medicare card").Required, attachmentRequirement2.Required);
            Assert.AreEqual(signer.GetAttachmentRequirement("Medicare card").Status.ToString(), attachmentRequirement2.Status.ToString());
        }
Ejemplo n.º 5
0
        public void AuthenticationDefaultsToEmail()
        {
            OneSpanSign.Sdk.Signer signer = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                                            .WithFirstName("Billy")
                                            .WithLastName("Bob")
                                            .Build();

            Assert.AreEqual(AuthenticationMethod.EMAIL, signer.AuthenticationMethod);
        }
Ejemplo n.º 6
0
        public void CanConfigureSignedDocumentDelivery()
        {
            OneSpanSign.Sdk.Signer signer = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                                            .WithFirstName("Billy")
                                            .WithLastName("Bob")
                                            .DeliverSignedDocumentsByEmail()
                                            .Build();

            Assert.IsTrue(signer.DeliverSignedDocumentsByEmail);
        }
Ejemplo n.º 7
0
        public void SetsUpSSOAuthentication()
        {
            OneSpanSign.Sdk.Signer signer = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                                            .WithFirstName("Billy")
                                            .WithLastName("Bob")
                                            .WithSSOAuthentication()
                                            .Build();

            Assert.AreEqual(AuthenticationMethod.SSO, signer.AuthenticationMethod);
        }
Ejemplo n.º 8
0
        public void ProvidingSignerCellPhoneNumberSetsUpSMSAuthentication()
        {
            OneSpanSign.Sdk.Signer signer = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                                            .WithFirstName("Billy")
                                            .WithLastName("Bob")
                                            .WithSMSSentTo("1112223333")
                                            .Build();

            Assert.AreEqual(AuthenticationMethod.SMS, signer.AuthenticationMethod);
            Assert.AreEqual("1112223333", signer.PhoneNumber);
        }
Ejemplo n.º 9
0
        public void ProvidingQuestionsAndAnswersSetsAuthenticationMethodToChallenge()
        {
            OneSpanSign.Sdk.Signer signer = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                                            .WithFirstName("Billy")
                                            .WithLastName("Bob")
                                            .ChallengedWithQuestions(ChallengeBuilder.FirstQuestion("What's your favorite sport?")
                                                                     .Answer("golf"))
                                            .Build();

            Assert.AreEqual(AuthenticationMethod.CHALLENGE, signer.AuthenticationMethod);
        }
Ejemplo n.º 10
0
        public void CanSpecifyTitleAndCompany()
        {
            OneSpanSign.Sdk.Signer signer = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                                            .WithFirstName("Billy")
                                            .WithLastName("Bob")
                                            .WithTitle("Managing Director")
                                            .WithCompany("Acme Inc")
                                            .Build();

            Assert.AreEqual("Managing Director", signer.Title);
            Assert.AreEqual("Acme Inc", signer.Company);
        }
Ejemplo n.º 11
0
        public void ConvertSDKToAPI()
        {
            sdkSigner1 = CreateTypicalSDKSigner();
            apiSigner1 = new SignerConverter(sdkSigner1).ToAPISigner();

            Assert.IsNotNull(apiSigner1);
            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.Language, sdkSigner1.Language);
            Assert.AreEqual(apiSigner1.Title, sdkSigner1.Title);
        }
Ejemplo n.º 12
0
        public void BuildsSignerWithBasicInformation()
        {
            OneSpanSign.Sdk.Signer signer = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                                            .WithFirstName("Joe")
                                            .WithLastName("Smith")
                                            .SigningOrder(2)
                                            .Build();

            Assert.AreEqual("*****@*****.**", signer.Email);
            Assert.AreEqual("Joe", signer.FirstName);
            Assert.AreEqual("Smith", signer.LastName);
            Assert.AreEqual(2, signer.SigningOrder);
        }
Ejemplo n.º 13
0
        public void SavesProvidesQuestionsAndAnswers()
        {
            OneSpanSign.Sdk.Signer signer = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                                            .WithFirstName("Billy")
                                            .WithLastName("Bob")
                                            .ChallengedWithQuestions(ChallengeBuilder.FirstQuestion("What's your favorite sport?")
                                                                     .Answer("golf")
                                                                     .SecondQuestion("Do you have a pet?")
                                                                     .Answer("yes"))
                                            .Build();

            Assert.AreEqual(signer.ChallengeQuestion[0], new Challenge("What's your favorite sport?", "golf", Challenge.MaskOptions.None));
            Assert.AreEqual(signer.ChallengeQuestion[1], new Challenge("Do you have a pet?", "yes", Challenge.MaskOptions.None));
        }
Ejemplo n.º 14
0
        public void CanSetAndGetAttachmentRequirements()
        {
            OneSpanSign.Sdk.AttachmentRequirement attachmentRequirement = AttachmentRequirementBuilder.NewAttachmentRequirementWithName("Driver's license")
                                                                          .WithDescription("Please upload scanned driver's license.")
                                                                          .IsRequiredAttachment()
                                                                          .Build();

            OneSpanSign.Sdk.Signer signer = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                                            .WithFirstName("Billy")
                                            .WithLastName("Bob")
                                            .WithAttachmentRequirement(attachmentRequirement)
                                            .Build();

            Assert.AreEqual(signer.Attachments.Count, 1);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Name, attachmentRequirement.Name);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Description, attachmentRequirement.Description);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Required, attachmentRequirement.Required);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Status, attachmentRequirement.Status);
        }
Ejemplo n.º 15
0
        private void SetNewSignersIndexIfRoleWorkflowEnabled(PackageId templateId, DocumentPackage documentPackage)
        {
            DocumentPackage template = new DocumentPackageConverter(packageService.GetPackage(templateId)).ToSDKPackage();

            if (CheckSignerOrdering(template))
            {
                int firstSignerIndex = GetMaxSigningOrder(template, documentPackage) + 1;
                foreach (Signer signer in documentPackage.Signers)
                {
                    Signer templatePlaceholder = template.GetPlaceholder(signer.Id);
                    if (templatePlaceholder != null)
                    {
                        signer.SigningOrder = templatePlaceholder.SigningOrder;
                    }

                    if (signer.SigningOrder <= 0)
                    {
                        signer.SigningOrder = firstSignerIndex;
                        firstSignerIndex++;
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public void ConvertSDKSignerToAPIRole()
        {
            sdkSigner1 = CreateTypicalSDKSigner();
            String roleId = System.Guid.NewGuid().ToString().Replace("-", "");

            apiRole = new SignerConverter(sdkSigner1).ToAPIRole(roleId);

            Assert.IsNotNull(apiRole);
            Assert.AreEqual(apiRole.Signers[0].Email, sdkSigner1.Email);
            Assert.AreEqual(apiRole.Signers[0].FirstName, sdkSigner1.FirstName);
            Assert.AreEqual(apiRole.Signers[0].LastName, sdkSigner1.LastName);
            Assert.AreEqual(apiRole.Signers[0].Company, sdkSigner1.Company);
            Assert.AreEqual(apiRole.Signers[0].Language, sdkSigner1.Language);
            Assert.AreEqual(apiRole.Signers[0].Title, sdkSigner1.Title);
            Assert.AreEqual(apiRole.Id, sdkSigner1.Id);
            Assert.AreEqual(apiRole.Name, sdkSigner1.Id);
            Assert.AreEqual(apiRole.EmailMessage.Content, sdkSigner1.Message);

            string attachmentName = apiRole.AttachmentRequirements[0].Name;

            Assert.AreEqual(apiRole.AttachmentRequirements[0].Name, sdkSigner1.GetAttachmentRequirement(attachmentName).Name);
            Assert.AreEqual(apiRole.AttachmentRequirements[0].Description, sdkSigner1.GetAttachmentRequirement(attachmentName).Description);
            Assert.AreEqual(apiRole.AttachmentRequirements[0].Required, sdkSigner1.GetAttachmentRequirement(attachmentName).Required);
        }
Ejemplo n.º 17
0
        private OneSpanSign.Sdk.Message CreateTypicalSDKMessage()
        {
            OneSpanSign.Sdk.Signer fromSigner = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                                                .WithFirstName("John")
                                                .WithLastName("Smith")
                                                .WithCustomId("user1")
                                                .Build();

            OneSpanSign.Sdk.Message sdkMessage = new OneSpanSign.Sdk.Message(OneSpanSign.Sdk.MessageStatus.NEW, "decline reason", fromSigner);

            sdkMessage.Created = DateTime.Now;

            IDictionary <string, OneSpanSign.Sdk.Signer> toSigners = new Dictionary <string, OneSpanSign.Sdk.Signer>();

            OneSpanSign.Sdk.Signer toSigner = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                                              .WithFirstName("Patty")
                                              .WithLastName("Galant")
                                              .WithCustomId("user2")
                                              .Build();
            toSigners.Add(toSigner.Email, toSigner);
            sdkMessage.AddTo(toSigner);

            return(sdkMessage);
        }
Ejemplo n.º 18
0
 public SignerConverter(Placeholder placeholder)
 {
     this.sdkSigner = new Signer(placeholder.Id);
 }
Ejemplo n.º 19
0
        private OneSpanSign.Sdk.Signer NewRegularSignerFromAPIRole()
        {
            OneSpanSign.API.Signer eslSigner = apiRole.Signers[0];

            SignerBuilder builder = SignerBuilder.NewSignerWithEmail(eslSigner.Email)
                                    .WithCustomId(eslSigner.Id)
                                    .WithFirstName(eslSigner.FirstName)
                                    .WithLastName(eslSigner.LastName)
                                    .WithCompany(eslSigner.Company)
                                    .WithLanguage(eslSigner.Language)
                                    .WithTitle(eslSigner.Title)
                                    .ChallengedWithKnowledgeBasedAuthentication(new KnowledgeBasedAuthenticationConverter(eslSigner.KnowledgeBasedAuthentication).ToSDKKnowledgeBasedAuthentication());

            if (apiRole.Index.HasValue)
            {
                builder.SigningOrder(apiRole.Index.Value);
            }

            foreach (OneSpanSign.API.AttachmentRequirement attachmentRequirement in apiRole.AttachmentRequirements)
            {
                builder.WithAttachmentRequirement(new AttachmentRequirementConverter(attachmentRequirement).ToSDKAttachmentRequirement());
            }

            if (apiRole.Id != null)
            {
                builder.WithCustomId(apiRole.Id);
            }

            if (apiRole.Reassign.Value)
            {
                builder.CanChangeSigner();
            }

            if (apiRole.EmailMessage != null)
            {
                builder.WithEmailMessage(apiRole.EmailMessage.Content);
            }

            if (eslSigner.Delivery != null && eslSigner.Delivery.Email.Value)
            {
                builder.DeliverSignedDocumentsByEmail();
            }

            builder.WithAuthentication(new AuthenticationConverter(eslSigner.Auth).ToSDKAuthentication());

            Signer signer = builder.Build();

            if (apiSigner.SignerType != null)
            {
                signer.SignerType = apiSigner.SignerType;
            }

            if (apiRole.Locked.Value)
            {
                signer.Locked = true;
            }

            IDictionary <string, object> apiRoleData = apiRole.Data;

            if (apiRoleData != null && apiRoleData.ContainsKey("localLanguage"))
            {
                object localLanguage = apiRoleData["localLanguage"];
                if (localLanguage != null)
                {
                    signer.LocalLanguage = localLanguage.ToString();
                }
            }

            return(signer);
        }
Ejemplo n.º 20
0
 public SignerConverter(Signer signer)
 {
     this.sdkSigner = signer;
 }
Ejemplo n.º 21
0
 public Message(MessageStatus status, string content, Signer from)
 {
     Status  = status;
     Content = content;
     From    = from;
 }
        public DownloadedFile DownloadAllAttachmentFilesForSignerInPackage(DocumentPackage sdkPackage, Signer signer)
        {
            Package apiPackage = new DocumentPackageConverter(sdkPackage).ToAPIPackage();
            string  roleId     = "";

            foreach (Role role in apiPackage.Roles)
            {
                foreach (OneSpanSign.API.Signer apiSigner in role.Signers)
                {
                    if (signer.Email.Equals(apiSigner.Email))
                    {
                        roleId = role.Id;
                    }
                }
            }
            return(DownloadAllAttachmentsForSignerInPackage(sdkPackage.Id.Id, roleId));
        }
 public byte[] DownloadAllAttachmentsForSignerInPackage(DocumentPackage sdkPackage, Signer signer)
 {
     return(DownloadAllAttachmentFilesForSignerInPackage(sdkPackage, signer).Contents);
 }
 /// <summary>
 /// Sender downloads all attachment files for the signer in the package.
 /// </summary>
 /// <returns>The attachment files with file name.</returns>
 /// <param name="packageId">Package identifier.</param>
 /// <param name="signer">Signer.</param>
 public DownloadedFile DownloadAllAttachmentFilesForSignerInPackage(DocumentPackage sdkPackage, Signer signer)
 {
     return(apiClient.DownloadAllAttachmentFilesForSignerInPackage(sdkPackage, signer));
 }