コード例 #1
0
        public static void FormDirectSample(ServiceClient client)
        {
            //get FormDirect forms
            var forms = client.getFormList();

            var tfnForm = forms.FirstOrDefault(t => t.Name.Contains("TFN"));
            var superannuationChoiceForm = forms.FirstOrDefault(t => t.Name.Contains("Superannuation"));

            //set invitee infomation for employee
            tfnForm.Signers[0].FirstName = SampleParameters.Invitee1_FirstName;
            tfnForm.Signers[0].LastName = SampleParameters.Invitee1_LastName;
            tfnForm.Signers[0].Email = SampleParameters.Invitee1_Email;
            tfnForm.Signers[0].MobileCountry = SampleParameters.Invitee1_MobileCountry; //e.g. 61 for Australia
            tfnForm.Signers[0].MobileNumber = SampleParameters.Invitee1_MobileNumber;
            //set invitee infomation for employer
            superannuationChoiceForm.Signers[0].FirstName = SampleParameters.Invitee2_FirstName;
            superannuationChoiceForm.Signers[0].LastName = SampleParameters.Invitee2_LastName;
            superannuationChoiceForm.Signers[0].Email = SampleParameters.Invitee2_Email;

            //send forms
            var documents = client.sendForms(
                formsToSend: new List<SecuredSigningClientSdk.Models.FormDirect> {
                    tfnForm,
                    superannuationChoiceForm
                },
                dueDate: DateTime.Now.AddDays(5));
        }
コード例 #2
0
        public static void SmartTagAdvancedUsage4_Attachment(ServiceClient client)
        {
            var attachment= new System.IO.FileInfo(SampleParameters.Path2AttachmentFile);
            var attachmentReference = client.uploadAttachmentFile(attachment);

            var file = new System.IO.FileInfo(SampleParameters.Path2SmartTagDocument);
            var documentReference = client.uploadDocumentFile(file);

            var signers = new SmartTagInvitee[]
            {
                new SmartTagInvitee
                {
                    FirstName=SampleParameters.Invitee1_FirstName,
                    LastName=SampleParameters.Invitee1_LastName,
                    Email=SampleParameters.Invitee1_Email,
                    //if sms needed
                    //MobileCountry=SampleParameters.Invitee1_MobileCountry,
                    //MobileNumber=SampleParameters.Invitee1_MobileNumber,
                    Attachments=new List<string>
                    {
                        attachmentReference
                    }                  
                }
            };

            var smartTagResp = client.sendSmartTagDocument(new List<string> {
                documentReference
            }, DateTime.Now.AddDays(7), signers);
        }
コード例 #3
0
 /// <summary>
 /// Basic Usage. For more details about Smart Tag API, see:
 /// <see cref="http://www.securedsigning.com/documentation/developer/smarttag-api" />
 /// </summary>
 /// <param name="client"></param>
 public static void SmartTagSample(ServiceClient client)
 {
     var file = new System.IO.FileInfo(SampleParameters.Path2SmartTagDocument);
     var documentReference = client.uploadDocumentFile(file);
     var smartTagResp = client.sendSmartTagDocument(new List<string> {
         documentReference
     }, DateTime.Now.AddDays(7));
 }
コード例 #4
0
        static void Main(string[] args)
        {
            //initialise API Client
            var client = new ServiceClient(
                serviceUrl: SampleParameters.SecuredSigningServiceBase,
                version: SampleParameters.SecuredSigningServiceVersion,
                apiKey: SampleParameters.APIKey,
                secret: SampleParameters.APISecret,
                accessUrl: SampleParameters.CallbackUrl
                );
            //see https://www.securedsigning.com/developer/api-documentation#auth for more details about OAuth 2, default enabled for API Key from March 2016. earlier API Key should ignore it.           
            #region OAuth2
            var state = SampleParameters.OAuth2State;

            //get OAuth2 access token in WinForm
            //Application.EnableVisualStyles();
            //var form = new OAuth2AuthoriseForm(client, state, OAuth2Client.OAuth2Scope.Basic | OAuth2Client.OAuth2Scope.FormDirect | OAuth2Client.OAuth2Scope.FormFiller | OAuth2Client.OAuth2Scope.SmartTag);
            //form.OnAuthorized = (_tokenResp, _state) =>
            //{
            //    System.Diagnostics.Debug.Assert(_state == state);
            //    client.AccessToken = _tokenResp.Access_Token;
            //    form.Close();
            //};
            //Application.Run(form);

            //AccountSample(client);


            //get OAuth2 access token in Server
            var authorizeUrl = client.OAuth2.CreateAuthorizeRequest(state,
                OAuth2Client.OAuth2Scope.Basic.ToString(),
                OAuth2Client.OAuth2Scope.FormDirect.ToString(),
                OAuth2Client.OAuth2Scope.FormFiller.ToString(),
                OAuth2Client.OAuth2Scope.SmartTag.ToString());
            //start oauthorize process in a webpage 
            System.Diagnostics.Process.Start(authorizeUrl);
            //run an server implemented by HttpListener, you can implement your own server using ASP.Net, etc.
            Server.SampleServer server = new Server.SampleServer();
            var code = server.StartOnce();
            var tokenResp = client.OAuth2.GetToken(code);
            client.AccessToken = tokenResp.Access_Token;
            tokenResp = client.OAuth2.RefreshToken(tokenResp.Refresh_Token);
            client.AccessToken = tokenResp.Access_Token;

            AccountSample(client);

            #endregion

            //FormDirectSample(client);
            //FormFillerSample(client);
            FormFillerSample_EmbeddedSigning(client);
            //SmartTagSample(client);
            Console.Read();
        }
コード例 #5
0
        public static void SmartTagAdvancedUsage2_Embedded(ServiceClient client)
        {
            var file = new System.IO.FileInfo(SampleParameters.Path2SmartTagDocument);
            var documentReference = client.uploadDocumentFile(file);

            var smartTagResp = client.sendSmartTagDocument(new List<string> {
                documentReference
            }, DateTime.Now.AddDays(7), true);

            var signingKey = smartTagResp[0].Signers[0].SigningKey;
            //populate signing key into a embedded signing webpage.
        }
コード例 #6
0
        public static void SmartTagAdvancedUsage1_EmailTemplate(ServiceClient client)
        {
            var invitationTemplates = client.getInvitationEmailTemplates();
            //Let's say there're 2 templates, take the first one
            var templateReference = invitationTemplates[0].Reference;

            var file = new System.IO.FileInfo(SampleParameters.Path2SmartTagDocument);
            var documentReference = client.uploadDocumentFile(file);
            var smartTagResp = client.sendSmartTagDocument(new List<string> {
                documentReference
            },  DateTime.Now.AddDays(7), templateReference);
        }
コード例 #7
0
 static void AccountSample(ServiceClient client)
 {
     var account=client.getAccountInfo();
     Console.WriteLine($"Hello {account.Name}!");
     var documents = client.getActiveDocuments("InBox");
 }
コード例 #8
0
        public static void FormFillerSample_EmbeddedSigning(ServiceClient client)
        {
            //get FormFiller templates
            var templates = client.getFormFillerTemplates();

            //e.g. There're 3 templates. We select the second one.
            var t2 = templates[1];

            //set Signer(s) for template

            //e.g. There's 1 signer in t2
            //[
            //  {
            //    "SignerReference": "048109...086112",
            //    "FirstName": "",
            //    "LastName": "",
            //    "Email": ""
            //  }
            //]
            t2.Signers = client.getFormFillerSignerTemplate(t2.Reference).Signers;
            t2.Signers[0].FirstName = SampleParameters.Invitee1_FirstName;
            t2.Signers[0].LastName = SampleParameters.Invitee1_LastName;
            t2.Signers[0].Email = SampleParameters.Invitee1_Email;

            //set Field(s) value for template (optional)
            //e.g. There's 2 fields in t2
            //[
            //    {
            //      "Label": "Question1",
            //      "Value": "",
            //      "FieldType": "Text",
            //      "IsRequired": false,
            //      "ID": "154107214180236225199245158115055014119106193119",
            //      "ReadOnly": true
            //    },
            //    {
            //      "Label": "Question2",
            //      "Value": "",
            //      "FieldType": "Text",
            //      "IsRequired": false,
            //      "ID": "150138217070090110130118010201151101188219145216",
            //      "ReadOnly": false
            //    }
            //]
            var fields = client.getFormFillerFieldTemplate(t2.Reference).Fields;
            //e.g. We only want to prefill the first field
            t2.Fields = new List<SecuredSigningClientSdk.Models.FormFillerField>();
            var f1 = fields[0];
            f1.Value = SampleParameters.FormFillerSampleFieldValue;
            t2.Fields.Add(f1);

            //send template(s)
            var documents = client.sendFormFillerTemplates(
                templates: new List<SecuredSigningClientSdk.Models.FormFillerTemplate> {
                    t2
                },
                dueDate: DateTime.Now.AddDays(5),
                embedded: true);
            var signingKey = documents.Signers.FirstOrDefault(t => !string.IsNullOrWhiteSpace(t.SigningKey))?.SigningKey;

            //populate signing key into a embedded signing webpage.
            //a sample server hosts the embedded signing webpage, implement your own page instead.
            Console.WriteLine(signingKey);
            var server = new Server.SampleServer()
            {
                SDKClient = client,
                KeepSecretInServer = true
            };

            System.Diagnostics.Process.Start($"{SampleParameters.EmbeddedSigningUrl}?key={signingKey}");
            var runResult = server.StartOnce();
            Console.WriteLine("Go to browser to sign the document");
            server.Listen();
            bool signed = false;
            while (!signed)
            {
                System.Threading.Thread.Sleep(5000);
                Console.WriteLine("Check document status");
                var status = client.getStatus(documents.Documents.First()?.Reference);
                if (status.Status == "Complete")
                {
                    signed = true;
                }
            }
            server.Stop();
            Console.WriteLine("Done");
            Console.Read();

        }
コード例 #9
0
        public static void FormFillerSample(ServiceClient client)
        {
            //get FormFiller templates
            var templates = client.getFormFillerTemplates();

            //e.g. There're 3 templates. We select the first and second one.
            var t1 = templates[0];
            var t2 = templates[1];

            //set Signer(s) for template

            //e.g. There're 2 signers in t1
            //[
            //  {
            //    "SignerReference": "186210...025238",
            //    "FirstName": "",
            //    "LastName": "",
            //    "Email": ""
            //  },
            //  {
            //    "SignerReference": "023215...001032",
            //    "FirstName": "",
            //    "LastName": "",
            //    "Email": ""
            //  }
            //]
            //
            //and there's 1 signer in t2
            //[
            //  {
            //    "SignerReference": "048109...086112",
            //    "FirstName": "",
            //    "LastName": "",
            //    "Email": ""
            //  }
            //]
            t1.Signers = client.getFormFillerSignerTemplate(t1.Reference).Signers;
            t2.Signers = client.getFormFillerSignerTemplate(t2.Reference).Signers;
            t1.Signers[0].FirstName = t2.Signers[0].FirstName= SampleParameters.Invitee1_FirstName;
            t1.Signers[0].LastName = t2.Signers[0].LastName = SampleParameters.Invitee1_LastName;
            t1.Signers[0].Email = t2.Signers[0].Email= SampleParameters.Invitee1_Email;

            t1.Signers[1].FirstName = SampleParameters.Invitee2_FirstName;
            t1.Signers[1].LastName = SampleParameters.Invitee2_LastName;
            t1.Signers[1].Email = SampleParameters.Invitee2_Email;
            
            //set Field(s) value for template (optional)
            //e.g. There's 2 fields in t2
            //[
            //    {
            //      "Label": "Question1",
            //      "Value": "",
            //      "FieldType": "Text",
            //      "IsRequired": false,
            //      "ID": "154107214180236225199245158115055014119106193119",
            //      "ReadOnly": true
            //    },
            //    {
            //      "Label": "Question2",
            //      "Value": "",
            //      "FieldType": "Text",
            //      "IsRequired": false,
            //      "ID": "150138217070090110130118010201151101188219145216",
            //      "ReadOnly": false
            //    }
            //]
            var fields = client.getFormFillerFieldTemplate(t2.Reference).Fields;
            //e.g. We only want to prefill the first field
            t2.Fields = new List<SecuredSigningClientSdk.Models.FormFillerField>();
            var f1 = fields[0];
            f1.Value = SampleParameters.FormFillerSampleFieldValue;
            t2.Fields.Add(f1);

            //send template(s)
            var documents = client.sendFormFillerTemplates(
                templates: new List<SecuredSigningClientSdk.Models.FormFillerTemplate> {
                    t1,
                    t2
                },
                dueDate: DateTime.Now.AddDays(5));

            //well done.
        }