示例#1
0
 protected async Task UpdateInvoiceStatusAsync(int invoiceId, bool isPaid)
 {
     var invoicePaymentStatusRequest = new UpdateInvoicePaymentStatusRequest {
         IsPaid = isPaid
     };
     await SignerClient.UpdateInvoiceStatusAsync(invoiceId, invoicePaymentStatusRequest);
 }
        /**
         * This scenario demonstrates how to check if a document is concluded, approved, refused or signed
         * and the status of it's flow actions.
         */
        public override async Task RunAsync()
        {
            var result = await CreateDocumentAsync();

            // 1. Get the document's details by it's id
            var details = await SignerClient.GetDocumentDetailsAsync(result.DocumentId);

            // 2. Check if the whole flow is concluded
            if (details.IsConcluded)
            {
            }

            // 3. If needed, check the status of individual flow actions
            foreach (var flowAction in details.FlowActions)
            {
                if (flowAction.Status == ActionStatus.Completed)
                {
                }
            }

            /**
             * NOTE:
             *
             * The best way to know the exact time a document's flow is concluded, signed, approved or refused is by enabling a webhook in your organization on the
             * application. Whenever the flow of a document has one of these steps done, the application will fire a Webhook event by
             * sending a POST request to a registered URL.
             *
             * You can find below an example of the handling logic of a webhook event.
             *
             * Access the following link for information on available Webhook events:
             * https://dropsigner.com/swagger
             */
        }
        /**
         * This scenario demonstrates the creation of a document
         * that will be signed by a sign rule.
         * In a signing rule multiples users are assigned to the
         * same action but just an arbitrary number of them are
         * required to sign in order to complete that action.
         */
        public override async Task RunAsync()
        {
            // 1. The file's bytes must be read by the application and uploaded
            var filePath    = "sample.pdf";
            var fileName    = Path.GetFileName(filePath);
            var file        = File.ReadAllBytes(filePath);
            var uploadModel = await SignerClient.UploadFileAsync(fileName, file, "application/pdf");

            // 2. Define the name of the document which will be visible in the application
            var fileUploadModel = new FileUploadModel(uploadModel)
            {
                DisplayName = "Signing Rule Sample"
            };

            // 3. For each participant on the flow, create one instance of ParticipantUserModel
            var participantUserOne = new ParticipantUserModel()
            {
                Name       = "Jack Bauer",
                Email      = "*****@*****.**",
                Identifier = "75502846369"
            };

            var participantUserTwo = new ParticipantUserModel()
            {
                Name       = "James Bond",
                Email      = "*****@*****.**",
                Identifier = "95588148061"
            };

            // 4. Each signing rule requires just one FlowActionCreateModel no matter
            //    the number of participants assigned to it. The participants are assigned to
            //    it via a list of ParticipantUserModel assigned to the `SignRuleUsers` property.
            //    The number of required signatures from this list of participants is represented by
            //    the property `NumberRequiredSignatures`.
            var flowActionCreateModelSigningRule = new FlowActionCreateModel()
            {
                Type = FlowActionType.SignRule,
                NumberRequiredSignatures = 1,
                SignRuleUsers            = new List <ParticipantUserModel>()
                {
                    participantUserOne, participantUserTwo
                }
            };

            // 5. Send the document create request
            var documentRequest = new CreateDocumentRequest()
            {
                Files = new List <FileUploadModel>()
                {
                    fileUploadModel
                },
                FlowActions = new List <FlowActionCreateModel>()
                {
                    flowActionCreateModelSigningRule
                }
            };
            var result = (await SignerClient.CreateDocumentAsync(documentRequest)).First();

            System.Console.WriteLine($"Document {result.DocumentId} created");
        }
示例#4
0
        public Scenario()
        {
            // Homologation instance
            var domain = "https://signer-lac.azurewebsites.net";
            // Application credentials token.
            var token = "API Sample App|43fc0da834e48b4b840fd6e8c37196cf29f919e5daedba0f1a5ec17406c13a99";

            SignerClient = new SignerClient(domain, token);
        }
        /**
         * This scenario demonstrates the creation of a document
         * that needs to be signed using the XAdES format for a
         * specific XML element.
         */
        public override async Task RunAsync()
        {
            // 1. The file's bytes must be read by the application and uploaded
            var filePath    = "sample.xml";
            var fileName    = Path.GetFileName(filePath);
            var file        = File.ReadAllBytes(filePath);
            var uploadModel = await SignerClient.UploadFileAsync(fileName, file, "application/xml");

            // 2. Define the name of the document which will be visible in the application
            var fileUploadModel = new FileUploadModel(uploadModel)
            {
                DisplayName = "XML Element Sign Sample"
            };

            // 3. For each participant on the flow, create one instance of ParticipantUserModel
            var participantUser = new ParticipantUserModel()
            {
                Name       = "Jack Bauer",
                Email      = "*****@*****.**",
                Identifier = "75502846369"
            };

            // 4. Specify the type of the element (Id is used below) and the value of the identifier
            var xadesOptionsModel = new XadesOptionsModel()
            {
                SignatureType = XadesSignatureTypes.XmlElement,
                ElementToSignIdentifierType = XadesElementIdentifierTypes.Id,
                ElementToSignIdentifier     = "NFe35141214314050000662550010001084271182362300"
            };

            // 5. Create a FlowActionCreateModel instance for each action (signature or approval) in the flow.
            //    This object is responsible for defining the personal data of the participant and the type of
            //    action that he will perform on the flow.
            var flowActionCreateModel = new FlowActionCreateModel()
            {
                Type         = FlowActionType.Signer,
                User         = participantUser,
                XadesOptions = xadesOptionsModel
            };

            // 6. Send the document create request
            var documentRequest = new CreateDocumentRequest()
            {
                Files = new List <FileUploadModel>()
                {
                    fileUploadModel
                },
                FlowActions = new List <FlowActionCreateModel>()
                {
                    flowActionCreateModel
                }
            };
            var result = (await SignerClient.CreateDocumentAsync(documentRequest)).First();

            System.Console.WriteLine($"Document {result.DocumentId} created");
        }
        /**
         * This scenario demonstrates the creation of a document
         * and the generation of an action URL for the embedded signature
         * integration.
         */
        public override async Task RunAsync()
        {
            // 1. The file's bytes must be read by the application and uploaded
            var filePath    = "sample.pdf";
            var fileName    = Path.GetFileName(filePath);
            var file        = File.ReadAllBytes(filePath);
            var uploadModel = await SignerClient.UploadFileAsync(fileName, file, "application/pdf");

            // 2. Define the name of the document which will be visible in the application
            var fileUploadModel = new FileUploadModel(uploadModel)
            {
                DisplayName = "Embedded Signature Sample"
            };

            // 3. For each participant on the flow, create one instance of ParticipantUserModel
            var participantUser = new ParticipantUserModel()
            {
                Name       = "Jack Bauer",
                Email      = "*****@*****.**",
                Identifier = "75502846369"
            };

            // 4. Create a FlowActionCreateModel instance for each action (signature or approval) in the flow.
            //    This object is responsible for defining the personal data of the participant and the type of
            //    action that he will perform on the flow
            var flowActionCreateModel = new FlowActionCreateModel()
            {
                Type = FlowActionType.Signer,
                User = participantUser
            };

            // 5. Send the document create request
            var documentRequest = new CreateDocumentRequest()
            {
                Files = new List <FileUploadModel>()
                {
                    fileUploadModel
                },
                FlowActions = new List <FlowActionCreateModel>()
                {
                    flowActionCreateModel
                }
            };
            var result = (await SignerClient.CreateDocumentAsync(documentRequest)).First();

            // 6. Get the embed URL for the participant
            var actionUrlRequest = new ActionUrlRequest()
            {
                Identifier = participantUser.Identifier
            };
            var actionUrlResponse = await SignerClient.GetActionUrlAsync(result.DocumentId, actionUrlRequest);

            // 7. Load the embed URL in your own application using the LacunaSignerWidget as described in
            //    https://docs.lacunasoftware.com/pt-br/articles/signer/embedded-signature.html
            System.Console.WriteLine(actionUrlResponse.EmbedUrl);
        }
示例#7
0
        /**
         * This scenario demonstrates how to delete a document using it's id.
         */
        public override async Task RunAsync()
        {
            //1 - You need a document id
            var document = await CreateDocumentAsync();

            var docId = document.DocumentId;

            //2 - Call the api method to delete the documet and pass the document Id as parameter
            await SignerClient.DeleteDocumentAsync(docId);
        }
        /**
         * This scenario demonstrates the creation of a PDF document
         * that needs to be signed using the CAdES format.
         */
        public override async Task RunAsync()
        {
            // 1. The file's bytes must be read by the application and uploaded
            var filePath    = "sample.pdf";
            var fileName    = Path.GetFileName(filePath);
            var file        = File.ReadAllBytes(filePath);
            var uploadModel = await SignerClient.UploadFileAsync(fileName, file, "application/pdf");

            // 2. Define the name of the document which will be visible in the application
            var fileUploadModel = new FileUploadModel(uploadModel)
            {
                DisplayName = "PDF Cades Sample"
            };

            // 3. For each participant on the flow, create one instance of ParticipantUserModel
            var participantUser = new ParticipantUserModel()
            {
                Name       = "Jack Bauer",
                Email      = "*****@*****.**",
                Identifier = "75502846369"
            };

            // 4. Create a FlowActionCreateModel instance for each action (signature or approval) in the flow.
            //    This object is responsible for defining the personal data of the participant and the type of
            //    action that he will perform on the flow
            var flowActionCreateModel = new FlowActionCreateModel()
            {
                Type = FlowActionType.Signer,
                User = participantUser
            };

            // 5. Send the document create request specifying that it requires CAdES signatures, since PAdES is
            //    the default for PDF files.
            var documentRequest = new CreateDocumentRequest()
            {
                Files = new List <FileUploadModel>()
                {
                    fileUploadModel
                },
                FlowActions = new List <FlowActionCreateModel>()
                {
                    flowActionCreateModel
                },
                ForceCadesSignature = true
            };
            var result = (await SignerClient.CreateDocumentAsync(documentRequest)).First();

            System.Console.WriteLine($"Document {result.DocumentId} created");
        }
        /**
         * This scenario demonstrates how to notify participants
         * of the flow.
         */
        public override async Task RunAsync()
        {
            // 1. Get a document Id
            var result = await CreateDocumentAsync();

            // 2. Get the document details
            var details = await SignerClient.GetDocumentDetailsAsync(result.DocumentId);

            // 3. Notify each participant individually if necessary
            //    Note: Only participants with pending actions are notified.
            foreach (var flowAction in details.FlowActions)
            {
                await SignerClient.SendFlowActionReminderAsync(result.DocumentId, flowAction.Id);
            }
        }
示例#10
0
        /**
         * This scenario demonstrates the creation of a document with description
         *
         */
        public override async Task RunAsync()
        {
            // 1. The file's bytes must be read by the application and uploaded
            var filePath    = "sample.pdf";
            var fileName    = Path.GetFileName(filePath);
            var file        = File.ReadAllBytes(filePath);
            var uploadModel = await SignerClient.UploadFileAsync(fileName, file, "application/pdf");

            // 2. Define the name of the document which will be visible in the application
            var fileUploadModel = new FileUploadModel(uploadModel)
            {
                DisplayName = "One Description Sample"
            };

            // 3. For each participant on the flow, create one instance of ParticipantUserModel
            var participantUser = new ParticipantUserModel()
            {
                Name       = "Jack Bauer",
                Email      = "*****@*****.**",
                Identifier = "75502846369"
            };

            // 4. Create a FlowActionCreateModel instance for each action (signature or approval) in the flow.
            var flowActionCreateModel = new FlowActionCreateModel()
            {
                Type = FlowActionType.Signer,
                User = participantUser
            };

            // 5. Send the document create request writing the description as a string
            var documentRequest = new CreateDocumentRequest()
            {
                Files = new List <FileUploadModel>()
                {
                    fileUploadModel
                },
                Description = "Some Description Sample",
                FlowActions = new List <FlowActionCreateModel>()
                {
                    flowActionCreateModel
                }
            };
            var result = (await SignerClient.CreateDocumentAsync(documentRequest)).First();

            System.Console.WriteLine($"Document {result.DocumentId} created");
        }
示例#11
0
        static void Main(string[] args)
        {
            var domain = "https://signer-lac.azurewebsites.net";
            var token  = "API Sample App|43fc0da834e48b4b840fd6e8c37196cf29f919e5daedba0f1a5ec17406c13a99";

            SignerClient SignerClient = new SignerClient(domain, token);

            var paginatedSearchParams = new PaginatedSearchParams()
            {
                Q = "Sample"
            };
            var paginatedSearchResult = SignerClient.ListFoldersPaginatedAsync(paginatedSearchParams, null).Result;

            var resultJson = JsonConvert.SerializeObject(paginatedSearchResult, Formatting.Indented);

            Console.WriteLine(resultJson);
        }
        /**
         * This scenario demonstrates how to download different document versions
         */

        public override async Task RunAsync()
        {
            // 1. Get a document Id
            var result = await CreateDocumentAsync();


            //2. You can get a ticket to a specific version of the document. The ticket is a temporary URL that allows you to download that version.
            var ticketDownload = await SignerClient.GetDocumentDownloadTicketAsync(result.DocumentId, DocumentTicketType.Original);


            // 3. Get the document by passing it's Id and the Ticket type
            // Be sure to select the exact DocumentTicketType to download the type of document you want.
            // Chek the available types by ispecting DocumentTicketType's ENUM.
            var documentVersion = await SignerClient.GetDocumentContentAsync(result.DocumentId, DocumentDownloadTypes.Original);

            this.SaveFileStream("downloadversionExample.pdf", documentVersion);

            // 4. You can also get the bytes directly instead of a Stream for a specific version type of the document
            var documentVersionBytes = await SignerClient.GetDocumentBytesAsync(result.DocumentId, DocumentTicketType.Signatures);
        }
示例#13
0
        public override async Task RunAsync()
        {
            /**
             * This scenario describes how to list documents.
             */

            //1 - define the arguments to list the documents according to your requirements
            var searchParams = new DocumentListParameters
            {
                Order       = PaginationOrders.Desc, //Order the list: Ascending = Oldest on top / Descending = Newest on top
                Limit       = 10,                    //Define the number of Documents that you want to list
                IsConcluded = false,                 // List concluded documents if it's "true"
                Q           = "TestDocumentName"     //Retrieve the document list by name
            };

            //2 - Call the ListDocument method and pass "searchParams" as a parameter
            var listOfDocuments = await SignerClient.ListDocumentsAsync(searchParams);


            foreach (var item in listOfDocuments.Items)
            {
                System.Console.WriteLine(item.Name);
            }
        }
示例#14
0
        /**
         * This scenario demonstrates the creation of a document with Attachment.
         */
        public override async Task RunAsync()
        {
            // 1. The file's bytes must be read by the application and uploaded
            var filePath    = "sample.pdf";
            var fileName    = Path.GetFileName(filePath);
            var file        = File.ReadAllBytes(filePath);
            var uploadModel = await SignerClient.UploadFileAsync(fileName, file, "application/pdf");

            var fileUploadModel = new FileUploadModel(uploadModel)
            {
                DisplayName = "One Signer Sample"
            };


            // Repeat the same steps above but now for the attachment
            var attachmentPath   = "sample.pdf";
            var attachmentName   = Path.GetFileName(attachmentPath);
            var attachment       = File.ReadAllBytes(attachmentPath);
            var attachmentUpload = await SignerClient.UploadFileAsync(attachmentName, attachment, "application/pdf");

            // 2. Define the name of the attachment which will be visible in the application using "AttachmentUploadModel"
            var attachmentUploadModel = new AttachmentUploadModel(attachmentUpload)
            {
                DisplayName = "One Attachment Sample",
                IsPrivate   = true
            };


            // 3. For each participant on the flow, create one instance of ParticipantUserModel
            var participantUser = new ParticipantUserModel()
            {
                Name       = "Jack Bauer",
                Email      = "*****@*****.**",
                Identifier = "75502846369"
            };

            // 4. Create a FlowActionCreateModel instance for each action (signature or approval) in the flow.
            //    This object is responsible for defining the personal data of the participant and the type of
            //    action that he will perform on the flow
            var flowActionCreateModel = new FlowActionCreateModel()
            {
                Type = FlowActionType.Signer,
                User = participantUser
            };

            // 5. Send the document create request with whith the attachment attribute
            var documentRequest = new CreateDocumentRequest()
            {
                Files = new List <FileUploadModel>()
                {
                    fileUploadModel
                },
                Attachments = new List <AttachmentUploadModel>()
                {
                    attachmentUploadModel
                },
                FlowActions = new List <FlowActionCreateModel>()
                {
                    flowActionCreateModel
                }
            };
            var result = (await SignerClient.CreateDocumentAsync(documentRequest)).First();

            System.Console.WriteLine($"Document {result.DocumentId} created");
        }
        /**
         * This scenario demonstrates the creation of a document with
         * two signers and without a particular order for the signatures.
         */
        public override async Task RunAsync()
        {
            // 1. The file's bytes must be read by the application and uploaded
            var filePath    = "sample.pdf";
            var fileName    = Path.GetFileName(filePath);
            var file        = File.ReadAllBytes(filePath);
            var uploadModel = await SignerClient.UploadFileAsync(fileName, file, "application/pdf");

            // 2. Define the name of the document which will be visible in the application
            var fileUploadModel = new FileUploadModel(uploadModel)
            {
                DisplayName = "Two Signers Without Order Sample"
            };

            // 3. For each participant on the flow, create one instance of ParticipantUserModel
            var participantUserOne = new ParticipantUserModel()
            {
                Name       = "Jack Bauer",
                Email      = "*****@*****.**",
                Identifier = "75502846369"
            };

            var participantUserTwo = new ParticipantUserModel()
            {
                Name       = "James Bond",
                Email      = "*****@*****.**",
                Identifier = "95588148061"
            };

            // 4. Create a FlowActionCreateModel instance for each action (signature or approval) in the flow.
            //    This object is responsible for defining the personal data of the participant, the type of
            //    action that he will perform on the flow and the order in which this action will take place
            //    (Step property). If the Step property of all action are the same or not specified they
            //    may be executed at any time
            var flowActionCreateModelOne = new FlowActionCreateModel()
            {
                Type = FlowActionType.Signer,
                User = participantUserOne
            };

            var flowActionCreateModelTwo = new FlowActionCreateModel()
            {
                Type = FlowActionType.Signer,
                User = participantUserTwo
            };

            // 5. Send the document create request
            var documentRequest = new CreateDocumentRequest()
            {
                Files = new List <FileUploadModel>()
                {
                    fileUploadModel
                },
                FlowActions = new List <FlowActionCreateModel>()
                {
                    flowActionCreateModelOne,
                    flowActionCreateModelTwo
                }
            };
            var result = (await SignerClient.CreateDocumentAsync(documentRequest)).First();

            System.Console.WriteLine($"Document {result.DocumentId} created");
        }
        /**
         * This scenario demonstrates the creation of a digital degree compliant with "PORTARIA Nº 554, DE 11 DE MARÇO DE 2019".
         */
        public override async Task RunAsync()
        {
            // 1. The file's bytes must be read by the application and uploaded
            var filePath    = "sample-degree.xml";
            var fileName    = Path.GetFileName(filePath);
            var file        = File.ReadAllBytes(filePath);
            var uploadModel = await SignerClient.UploadFileAsync(fileName, file, "application/xml");

            // 2. Define the name of the document which will be visible in the application
            var fileUploadModel = new FileUploadModel(uploadModel)
            {
                DisplayName = "Digital Degree Sample"
            };

            // 3. For each participant on the flow, create one instance of ParticipantUserModel
            var participantUserOne = new ParticipantUserModel()
            {
                Name       = "Jack Bauer",
                Email      = "*****@*****.**",
                Identifier = "75502846369"
            };

            var participantUserTwo = new ParticipantUserModel()
            {
                Name       = "James Bond",
                Email      = "*****@*****.**",
                Identifier = "95588148061"
            };

            var ParticipantUserThree = new ParticipantUserModel()
            {
                Name       = "Gary Eggsy",
                Email      = "*****@*****.**",
                Identifier = "87657257008"
            };

            // 4. Specify the element that holds the namespace of the issuer
            var xmlNamespacesModel = new XmlNamespaceModel()
            {
                Prefix = "dip",
                Uri    = @"http://portal.mec.gov.br/diplomadigital/arquivos-em-xsd"
            };

            // 5. The fields 'DadosDiploma' and 'DadosRegistro' and the entire XML file must be signed
            var xadesOptionsDegreeData = new XadesOptionsModel()
            {
                SignatureType = XadesSignatureTypes.XmlElement,
                ElementToSignIdentifierType = XadesElementIdentifierTypes.XPath,
                ElementToSignIdentifier     = @"//dip:DadosDiploma",
                InsertionOption             = XadesInsertionOptions.AppendChild
            };

            var xadesOptionsModelRegisterData = new XadesOptionsModel()
            {
                SignatureType = XadesSignatureTypes.XmlElement,
                ElementToSignIdentifierType = XadesElementIdentifierTypes.XPath,
                ElementToSignIdentifier     = @"//dip:DadosRegistro",
                InsertionOption             = XadesInsertionOptions.AppendChild
            };

            var xadesOptionsModelFull = new XadesOptionsModel()
            {
                SignatureType = XadesSignatureTypes.FullXml
            };

            // 6. Each signature requires its own flow action
            var degreeDataAction = new FlowActionCreateModel()
            {
                Type         = FlowActionType.Signer,
                User         = participantUserOne,
                XadesOptions = xadesOptionsDegreeData
            };

            var registerDataAction = new FlowActionCreateModel()
            {
                Type         = FlowActionType.Signer,
                User         = participantUserTwo,
                XadesOptions = xadesOptionsModelRegisterData
            };

            var flowActionCreateModelFull = new FlowActionCreateModel()
            {
                Type         = FlowActionType.Signer,
                User         = ParticipantUserThree,
                XadesOptions = xadesOptionsModelFull
            };

            // 7. Send the document create request
            var documentRequest = new CreateDocumentRequest()
            {
                Files = new List <FileUploadModel>()
                {
                    fileUploadModel
                },
                XmlNamespaces = new List <XmlNamespaceModel>()
                {
                    xmlNamespacesModel
                },
                FlowActions = new List <FlowActionCreateModel>()
                {
                    degreeDataAction,
                    registerDataAction,
                    flowActionCreateModelFull
                },
            };
            var result = (await SignerClient.CreateDocumentAsync(documentRequest)).First();

            System.Console.WriteLine($"Document {result.DocumentId} created");
        }
        /**
         * This scenario demonstrates the creation of a document with
         * Prepositioned signatures.
         */
        public override async Task RunAsync()
        {
            // 1. The file's bytes must be read by the application and uploaded
            var filePath    = "sample.pdf";
            var fileName    = Path.GetFileName(filePath);
            var file        = File.ReadAllBytes(filePath);
            var uploadModel = await SignerClient.UploadFileAsync(fileName, file, "application/pdf");

            // 2. Define the name of the document which will be visible in the application
            var fileUploadModel = new FileUploadModel(uploadModel)
            {
                DisplayName = "Prepositioned signatures"
            };

            // 3. For each participant on the flow, create one instance of ParticipantUserModel
            var participantUser = new ParticipantUserModel()
            {
                Name       = "Jack Bauer",
                Email      = "*****@*****.**",
                Identifier = "75502846369"
            };


            // 4. Create a FlowActionCreateModel instance for each action (signature or approval) in the flow.
            //    This object is responsible for defining the personal data of the participant, the type of
            //    action that he will perform on the flow and the order in which this action will take place
            //    (Step property) and the pre-positioned marks for placing signatures. If the Step property of all action are the same or not specified they
            //    may be executed at any time
            var flowActionCreateModel = new FlowActionCreateModel()
            {
                Type = FlowActionType.Signer,
                User = participantUser,
                PrePositionedMarks = new List <PrePositionedDocumentMarkModel>
                {
                    new PrePositionedDocumentMarkModel()
                    {
                        Type       = DocumentMarkType.SignatureVisualRepresentation, //This is the attribute responsible for defining the Type of signature you are going to use
                        UploadId   = fileUploadModel.Id,                             //Document id
                        TopLeftX   = 395.0,                                          //Signature position, in pixels, over the X axis
                        TopLeftY   = 560.0,                                          //Signature position, in pixels, over the Y axis
                        Width      = 170.0,                                          //Width of the rectagular where signature will be placed in (It already has a default value)
                        Height     = 94.0,                                           //Height of the rectagular where signature will be placed in (It already has a default value)
                        PageNumber = 1                                               //Page where the signature wil be placed
                    }
                }
            };


            // 5. Send the document create request
            var documentRequest = new CreateDocumentRequest()
            {
                Files = new List <FileUploadModel>()
                {
                    fileUploadModel
                },
                FlowActions = new List <FlowActionCreateModel>()
                {
                    flowActionCreateModel
                }
            };


            var result = (await SignerClient.CreateDocumentAsync(documentRequest)).First();

            System.Console.WriteLine($"Document {result.DocumentId} created");
        }
示例#18
0
        /**
         * This scenario demonstrates the creation of a document into an existing folder.
         */
        public override async Task RunAsync()
        {
            // 1. The file's bytes must be read by the application and uploaded
            var filePath    = "sample.pdf";
            var fileName    = Path.GetFileName(filePath);
            var file        = File.ReadAllBytes(filePath);
            var uploadModel = await SignerClient.UploadFileAsync(fileName, file, "application/pdf");

            // 2. Define the name of the document which will be visible in the application
            var fileUploadModel = new FileUploadModel(uploadModel)
            {
                DisplayName = "Document in Folder Sample"
            };

            // 3. For each participant on the flow, create one instance of ParticipantUserModel
            var participantUser = new ParticipantUserModel()
            {
                Name       = "Jack Bauer",
                Email      = "*****@*****.**",
                Identifier = "75502846369"
            };

            // 4. Create a FlowActionCreateModel instance for each action (signature or approval) in the flow.
            //    This object is responsible for defining the personal data of the participant and the type of
            //    action that he will perform on the flow
            var flowActionCreateModel = new FlowActionCreateModel()
            {
                Type = FlowActionType.Signer,
                User = participantUser
            };

            // 5. Search a folder by it's name
            var paginatedSearchParams = new PaginatedSearchParams()
            {
                Q = "Sample Folder"
            };
            var paginatedSearchResult = await SignerClient.ListFoldersPaginatedAsync(paginatedSearchParams, null);

            var folder = paginatedSearchResult.Items.FirstOrDefault();

            if (folder == null)
            {
                throw new Exception("Folder was not found");
            }

            // 6. Send the document create request setting the FolderId property
            var documentRequest = new CreateDocumentRequest()
            {
                Files = new List <FileUploadModel>()
                {
                    fileUploadModel
                },
                FlowActions = new List <FlowActionCreateModel>()
                {
                    flowActionCreateModel
                },
                FolderId = folder.Id
            };
            var result = (await SignerClient.CreateDocumentAsync(documentRequest)).First();

            System.Console.WriteLine($"Document {result.DocumentId} created");
        }