public void GetDocuments() { using (PandaDocHttpClient client = EnsureLoggedIn().Result) { PandaDocHttpResponse <GetDocumentsResponse> response = client.GetDocuments().Result; response.AssertOk(); } }
public async void GetDocumentsAsync() { using (PandaDocHttpClient client = await EnsureLoggedIn()) { PandaDocHttpResponse <GetDocumentsResponse> response = await client.GetDocuments(); response.AssertOk(); } }
protected async Task <PandaDocHttpClient> EnsureLoggedIn() { var settings = new PandaDocHttpClientSettings(); var client = new PandaDocHttpClient(settings); PandaDocHttpResponse <PandaDocBearerToken> login = await client.Login(username : Username, password : Password); client.SetBearerToken(login.Value); return(client); }
public static void AssertOk(this PandaDocHttpResponse response) { Assert.NotNull(response); if (!response.IsSuccessStatusCode) { Console.WriteLine(response.Content); } Assert.IsTrue(response.IsSuccessStatusCode); }
public async void DeleteDocument() { using (PandaDocHttpClient client = await EnsureLoggedIn()) { string uuid = "FRkUcECJzFtCBTSFugsaF5"; PandaDocHttpResponse response = await client.DeleteDocument(uuid); response.AssertOk(); } }
public void CreateDocument() { using (PandaDocHttpClient client = EnsureLoggedIn().Result) { CreateDocumentRequest request = CreateDocumentRequest(); PandaDocHttpResponse <CreateDocumentResponse> response = client.CreateDocument(request).Result; response.AssertOk(); } }
public async void CreateDocumentAsync() { using (PandaDocHttpClient client = await EnsureLoggedIn()) { CreateDocumentRequest request = CreateDocumentRequest(); PandaDocHttpResponse <CreateDocumentResponse> response = await client.CreateDocument(request); response.AssertOk(); } }
public async void LoginAsync() { using (var client = new PandaDocHttpClient()) { PandaDocHttpResponse <PandaDocBearerToken> response = await client.Login(username : Username, password : Password); response.AssertOk(); Assert.NotNull(response.Value.AccessToken); Assert.NotNull(response.Value.RefreshToken); } }
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); } }
public async void GetDocument() { using (PandaDocHttpClient client = await EnsureLoggedIn()) { //var createRequest = CreateDocumentRequest(); //var createResponse = await client.CreateDocument(createRequest); //var uuid = createResponse.Value.Uuid; var uuid = "9x5fr622ME6rpcG277Nx8C"; PandaDocHttpResponse <GetDocumentResponse> response = await client.GetDocument(uuid); response.AssertOk(); Console.WriteLine("Document '{0}' has status '{1}'", response.Value.Uuid, response.Value.Status); foreach (Recipient recipient in response.Value.Recipients) { Console.WriteLine("Recipient '{0} {1}' completed: {2}", recipient.FirstName, recipient.LastName, recipient.HasCompleted); } } }