예제 #1
0
        public void CreateDocument()
        {
            using (PandaDocHttpClient client = EnsureLoggedIn().Result)
            {
                CreateDocumentRequest request = CreateDocumentRequest();

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

                response.AssertOk();
            }
        }
예제 #2
0
        public async void CreateDocumentAsync()
        {
            using (PandaDocHttpClient client = await EnsureLoggedIn())
            {
                CreateDocumentRequest request = CreateDocumentRequest();

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

                response.AssertOk();
            }
        }
예제 #3
0
        public async void SendDocument()
        {
            using (PandaDocHttpClient client = await EnsureLoggedIn())
            {
                var createRequest  = CreateDocumentRequest();
                var createResponse = await client.CreateDocument(createRequest);

                Console.WriteLine("Document '{0}' was uploaded", createResponse.Value.Uuid);

                // we have to wait for the document to move from document.uploaded to document.draft before you can send it.
                var attempts = 0;
                while (true)
                {
                    var getResponse = await client.GetDocument(createResponse.Value.Uuid);

                    if (getResponse.Value.DocumentStatus == DocumentStatus.Draft)
                    {
                        Console.WriteLine("Document '{0}' has moved to draft", createResponse.Value.Uuid);
                        break;
                    }

                    await Task.Delay(1000);

                    attempts++;

                    if (attempts == 5)
                    {
                        Assert.Fail();
                    }
                }

                var sendRequest = new SendDocumentRequest
                {
                    Message = "Please sign this document"
                };

                PandaDocHttpResponse <SendDocumentResponse> response = await client.SendDocument(createResponse.Value.Uuid, sendRequest);

                response.AssertOk();

                Console.WriteLine("Document '{0}' was sent", response.Value.Uuid);
            }
        }