public async Task <CreateDocumentResponse> CreateDocumentAsync(CreateDocumentRequest request)
        {
            //// This should do nothing but call the http function through HttpClient
            var response = await client.PostAsJsonAsync("api/documents", request);

            return(await response.Content.ReadAsAsync <CreateDocumentResponse>());
        }
Exemple #2
0
        public async Task MergeIndicesTest()
        {
            // arranges
            var firstDocument = new Foo {
                Id = Guid.NewGuid().ToString(), FooDescription = "Some foo description"
            };
            var secondDocument = new Foo {
                Id = Guid.NewGuid().ToString(), FooDescription = "Another foo description"
            };
            var firstDocumentRequest = new CreateDocumentRequest <Foo> {
                Id = firstDocument.Id, Document = firstDocument
            };
            var secondDocumentRequest = new CreateDocumentRequest <Foo> {
                Id = secondDocument.Id, Document = secondDocument
            };
            var firstIndex = await _elasticsearchResource.CreateIndexAsync <Foo>();

            await _elasticsearchResource.CreateDocumentsAsync(firstIndex, firstDocumentRequest);

            var secondIndex = await _elasticsearchResource.CreateIndexAsync <Foo>();

            await _elasticsearchResource.CreateDocumentsAsync(secondIndex, secondDocumentRequest);

            // act
            var mergedIndex = await _elasticsearchResource.MergeIndicesAsync(firstIndex, secondIndex);

            // assert
            SearchResponse <Foo> searchResponse = await _elasticsearchResource.Client.LowLevel.SearchAsync <SearchResponse <Foo> >(
                mergedIndex, typeof(Foo).Name.ToLowerInvariant(), PostData.String(string.Empty));

            searchResponse.IsValid.Should().BeTrue();
            searchResponse.Documents.Should().HaveCount(2);
            searchResponse.Documents.Should().Contain(foo => foo.Id == firstDocument.Id);
            searchResponse.Documents.Should().Contain(foo => foo.Id == secondDocument.Id);
        }
        public async Task <Response> CreateDocument(CreateDocumentRequest request)
        {
            Response retval = new CreateDocumentResponseInvalidData(request);

            if (_dal.IsUserExists(_conn, request.UserID))
            {
                var      id       = Guid.NewGuid().ToString();
                Document document = new Document()
                {
                    DocID    = id, DocumentName = request.DocumentName,
                    ImageURL = request.ImageURL, UserID = request.UserID
                };
                try
                {
                    _dal.CreateDocument(_conn, document);
                    retval = new CreateDocumentResponseOK(request);
                    await _webSocket.Notify("new Document" + id);
                }
                catch (Exception ex)
                {
                    retval = new AppResponseError("Error in create document");
                }
            }
            return(retval);
        }
Exemple #4
0
        public void CreateDocumentRequestObject()
        {
            moq::Mock <Firestore.FirestoreClient> mockGrpcClient = new moq::Mock <Firestore.FirestoreClient>(moq::MockBehavior.Strict);
            CreateDocumentRequest request = new CreateDocumentRequest
            {
                Parent       = "projects/test/databases/test/documents/parent7858e4d0",
                CollectionId = "collection_idd84d1a0a",
                DocumentId   = "document_id10fcfae7",
                Document     = new Document(),
                Mask         = new DocumentMask(),
            };
            Document expectedResponse = new Document
            {
                Name   = "name1c9368b0",
                Fields =
                {
                    {
                        "key8a0b6e3c",
                        new Value()
                    },
                },
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
            };

            mockGrpcClient.Setup(x => x.CreateDocument(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            FirestoreClient client   = new FirestoreClientImpl(mockGrpcClient.Object, null);
            Document        response = client.CreateDocument(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemple #5
0
        public async stt::Task CreateDocumentRequestObjectAsync()
        {
            moq::Mock <Firestore.FirestoreClient> mockGrpcClient = new moq::Mock <Firestore.FirestoreClient>(moq::MockBehavior.Strict);
            CreateDocumentRequest request = new CreateDocumentRequest
            {
                Parent       = "projects/test/databases/test/documents/parent7858e4d0",
                CollectionId = "collection_idd84d1a0a",
                DocumentId   = "document_id10fcfae7",
                Document     = new Document(),
                Mask         = new DocumentMask(),
            };
            Document expectedResponse = new Document
            {
                Name   = "name1c9368b0",
                Fields =
                {
                    {
                        "key8a0b6e3c",
                        new Value()
                    },
                },
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
            };

            mockGrpcClient.Setup(x => x.CreateDocumentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Document>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            FirestoreClient client = new FirestoreClientImpl(mockGrpcClient.Object, null);
            Document        responseCallSettings = await client.CreateDocumentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Document responseCancellationToken = await client.CreateDocumentAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        /**
         * 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");
        }
Exemple #7
0
        private CreateDocumentRequest CreateDocumentRequest()
        {
            var request = new CreateDocumentRequest
            {
                Name       = "Sample Document",
                Url        = SampleDocUrl,
                Recipients = new[]
                {
                    new Models.CreateDocument.Recipient
                    {
                        Email     = "*****@*****.**",
                        FirstName = "Jake",
                        LastName  = "Scott",
                        Role      = "u1",
                    }
                },
                Fields = new Dictionary <string, Field>
                {
                    { "optId", new Field {
                          Title = "Field 1"
                      } }
                }
            };

            return(request);
        }
        internal CreateDocumentResponse CreateDocument(CreateDocumentRequest request)
        {
            var marshaller   = new CreateDocumentRequestMarshaller();
            var unmarshaller = CreateDocumentResponseUnmarshaller.Instance;

            return(Invoke <CreateDocumentRequest, CreateDocumentResponse>(request, marshaller, unmarshaller));
        }
Exemple #9
0
        public async Task CreateDocumentsTest()
        {
            // arranges
            var firstDocument = new Foo {
                Id = Guid.NewGuid().ToString(), FooDescription = "Some foo description"
            };
            var secondDocument = new Foo {
                Id = Guid.NewGuid().ToString(), FooDescription = "Another foo description"
            };
            var firstDocumentRequest = new CreateDocumentRequest <Foo> {
                Id = firstDocument.Id, Document = firstDocument
            };
            var secondDocumentRequest = new CreateDocumentRequest <Foo> {
                Id = secondDocument.Id, Document = secondDocument
            };

            // act
            var index = await _elasticsearchResource.CreateIndexAsync <Foo>();

            await _elasticsearchResource.CreateDocumentsAsync(index, firstDocumentRequest, secondDocumentRequest);

            // assert
            ISearchResponse <Foo> searchResponse = await _elasticsearchResource.Client
                                                   .SearchAsync <Foo>(new SearchRequest <Foo>(Indices.Index(index)));

            searchResponse.IsValid.Should().BeTrue();
            searchResponse.Documents.Should().HaveCount(2);
            searchResponse.Documents.Should().Contain(foo => foo.Id == firstDocument.Id);
            searchResponse.Documents.Should().Contain(foo => foo.Id == secondDocument.Id);
        }
Exemple #10
0
        public async Task <GetDocumentResponse> CreateDocument(byte[] fileContent, CreateDocumentRequest request)
        {
            var sharedDocuments = new List <ShareDocumentResponse>();

            using (var client = SetApiKey())
            {
                if (request == null)
                {
                    request = CreateDocumentRequest();
                }

                var response = await client.CreateDocument(fileContent, request);

                if (!string.IsNullOrEmpty(response.Uuid))
                {
                    var sendRequest = new SendDocumentRequest
                    {
                        Message = "Please sign this document",
                        Silent  = request.DisableEmail
                    };
                    var sendDocResponse = await client.SendDocument(response.Uuid, sendRequest);

                    var getDocResponse = await client.GetDocument(response.Uuid);

                    return(getDocResponse);
                }
                else
                {
                    return(null);
                }
            }
        }
Exemple #11
0
    /// <inheritdoc />
    public Task <Guid> CreateDocumentAsync(CreateDocumentRequest request)
    {
        this._logger.LogDebug(nameof(this.CreateDocumentAsync), request);
        var command = this._mapper.Map <CreateDocumentCommand>(request);

        return(this._mediator.Send(command));
    }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateDocument operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreateDocument operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task <CreateDocumentResponse> CreateDocumentAsync(CreateDocumentRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new CreateDocumentRequestMarshaller();
            var unmarshaller = CreateDocumentResponseUnmarshaller.Instance;

            return(InvokeAsync <CreateDocumentRequest, CreateDocumentResponse>(request, marshaller,
                                                                               unmarshaller, cancellationToken));
        }
        /// <summary>
        /// Creates a configuration document.
        ///
        ///
        /// <para>
        /// After you create a configuration document, you can use <a>CreateAssociation</a> to
        /// associate it with one or more running instances.
        /// </para>
        /// </summary>
        /// <param name="content">A valid JSON file. For more information about the contents of this file, see <a href="http://docs.aws.amazon.com/ssm/latest/APIReference/aws-ssm-document.html">Configuration Document</a>.</param>
        /// <param name="name">A name for the configuration document.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>The response from the CreateDocument service method, as returned by SimpleSystemsManagement.</returns>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.DocumentAlreadyExistsException">
        /// The specified configuration document already exists.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.DocumentLimitExceededException">
        /// You can have at most 100 active configuration documents.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.InternalServerErrorException">
        /// An error occurred on the server side.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidDocumentContentException">
        /// The content for the configuration document is not valid.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.MaxDocumentSizeExceededException">
        /// The size limit of a configuration document is 64 KB.
        /// </exception>
        public Task <CreateDocumentResponse> CreateDocumentAsync(string content, string name, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var request = new CreateDocumentRequest();

            request.Content = content;
            request.Name    = name;
            return(CreateDocumentAsync(request, cancellationToken));
        }
        public async Task <IActionResult> CreateOther(
            [FromHeader] Guid personUniqueId,
            [FromBody] CreateDocumentRequest <OtherDocumentDetail> model,
            [FromServices] DocumentsManager manager)
        {
            var documentId = await manager.CreateDocumentAsync(User.Identity.Name, personUniqueId, model);

            return(Json(new ApiResponse <string>(documentId)));
        }
        /**
         * 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);
        }
Exemple #17
0
        public async Task <GetDocumentResponse> Upload(string fileName, CreateDocumentRequest request)
        {
            var sharedDocuments = new List <ShareDocumentResponse>();
            var pandaDocHelper  = new PandaDocHelper();

            byte[] fileContent = System.IO.File.ReadAllBytes(fileName);
            var    response    = await pandaDocHelper.CreateDocument(fileContent, request);

            return(response);
        }
        public void CreateDocInvalidData()
        {
            var request = new CreateDocumentRequest()
            {
                DocumentName = "apple", ImageURL = "dfdf", UserID = "*****@*****.**"
            };
            var response = _documentService.CreateDocument(request).Result;

            Assert.IsInstanceOf(typeof(CreateDocumentResponseInvalidData), response);
        }
Exemple #19
0
        public async void CreateDocumentAsync()
        {
            using (PandaDocHttpClient client = await EnsureLoggedIn())
            {
                CreateDocumentRequest request = CreateDocumentRequest();

                PandaDocHttpResponse <CreateDocumentResponse> response = await client.CreateDocument(request);

                response.AssertOk();
            }
        }
Exemple #20
0
        public void CreateDocument()
        {
            using (PandaDocHttpClient client = EnsureLoggedIn().Result)
            {
                CreateDocumentRequest request = CreateDocumentRequest();

                PandaDocHttpResponse <CreateDocumentResponse> response = client.CreateDocument(request).Result;

                response.AssertOk();
            }
        }
        public async Task <CreateDocumentResponse> CreateDocument(CreateDocumentRequest request)
        {
            var accountInfo = _auth.GenerateSecurityInformation();

            request.AddAccountInfo(accountInfo);

            EnvioPedidoClient client = new EnvioPedidoClient();
            var result = await client.orderPedidoXMLAsync(request.BuildRequest());

            return(_deserializer.Deserialize <CreateDocumentResponse>(result));
        }
Exemple #22
0
        public ConfirmationResponse Execute(CreateDocumentRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var entity = ToDomainEntity(request);
            var result = _documentRepository.Create(entity);

            return(new ConfirmationResponse("Document created successfully.")
            {
                Id = result,
            });
        }
 public Response CreateDocument(CreateDocumentRequest request)
 {
     try
     {
         var id = _idGeneretor.GenerateId(request.OwnerId + request.DocumentName);
         var ds = _dal.CreateDocument(id, request.OwnerId, request.DocumentName);
         return(new CreateDocumentResponseOK(id));
     }
     catch (Exception ex)
     {
         return(new ResponseError(ex.Message));
     }
 }
Exemple #24
0
        public async Task <GetDocumentResponse> Upload(byte[] fileBytes, CreateDocumentRequest request)
        {
            GetDocumentResponse response = new GetDocumentResponse();

            if (fileBytes.Length > 0)
            {
                var pandaDocHelper = new PandaDocHelper();
                var docresponse    = await pandaDocHelper.CreateDocument(fileBytes, request);

                response = docresponse;
            }
            return(response);
        }
Exemple #25
0
        public void TestCreateDocument()
        {
            string remoteFileName = "TestCreateDocument.doc";

            var request = new CreateDocumentRequest(
                fileName: remoteFileName,
                folder: remoteDataFolder
                );
            var actual = this.WordsApi.CreateDocument(request);

            Assert.NotNull(actual.Document);
            Assert.AreEqual("TestCreateDocument.doc", actual.Document.FileName);
        }
Exemple #26
0
        public async Task <GetDocumentResponse> Upload(string fileName)
        {
            var sharedDocuments           = new List <ShareDocumentResponse>();
            CreateDocumentRequest request = CreateDocumentRequest();

            if (string.IsNullOrEmpty(fileName))
            {
                fileName = "D:\\panda.pdf";
            }
            byte[] fileContent = File.ReadAllBytes(fileName);
            var    response    = await pandaDocHelper.CreateDocument(fileContent, request);

            return(response.Value);
        }
        /**
         * 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");
        }
        /// <summary>
        /// 创建电子文档
        /// </summary>
        /// <param name="req"><see cref="CreateDocumentRequest"/></param>
        /// <returns><see cref="CreateDocumentResponse"/></returns>
        public CreateDocumentResponse CreateDocumentSync(CreateDocumentRequest req)
        {
            JsonResponseModel <CreateDocumentResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "CreateDocument");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <CreateDocumentResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
 /// <summary>Snippet for CreateDocument</summary>
 public void CreateDocument_RequestObject()
 {
     // Snippet: CreateDocument(CreateDocumentRequest,CallSettings)
     // Create client
     FirestoreClient firestoreClient = FirestoreClient.Create();
     // Initialize request argument(s)
     CreateDocumentRequest request = new CreateDocumentRequest
     {
         Parent       = new AnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]").ToString(),
         CollectionId = "",
         DocumentId   = "",
         Document     = new Document(),
     };
     // Make the request
     Document response = firestoreClient.CreateDocument(request);
     // End snippet
 }
Exemple #30
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");
        }