Skip to content

richarddowner/PandaDoc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PandaDoc .NET

PandaDoc is a web and mobile application which helps you to send, sign and track documents online. You can learn more about the application at the web site (https://www.pandadoc.com/).

With PandaDoc's programmable API you can send a document for signing straight from your backend system, or embed a document in your web site to request a signature from your clients.

Basic usage

The best way to learn the API is to have a read of the tests

Once you are familiar with the API you can install PandaDoc using nuget:

Install-Package PanadaDoc

Login

var settings = new PandaDocHttpClientSettings();
var client = new PandaDocHttpClient(settings);

var login = await client.Login(username: Username, password: Password);
client.SetBearerToken(login.Value);

Get Documents

PandaDocHttpResponse<GetDocumentsResponse> response = await client.GetDocuments();

Create Document

var request = new CreateDocumentRequest
{
    Name = "Sample Document",
    Url = SampleDocUrl,
    Recipients = new[]
    {
        new Models.CreateDocument.Recipient
        {
            Email = "jake.net@gmail.com",
            FirstName = "Jake",
            LastName = "Scott",
            Role = "u1",
        }
    },
    Fields = new Dictionary<string, Field>
    {
        {"optId", new Field {Title = "Field 1"}}
    }
};

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

Get Document

PandaDocHttpResponse<GetDocumentResponse> response = await client.GetDocument(uuid);

Send Document

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

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

Webhook Test Server

In an elevated command prompt run the following command:

netsh http add urlacl url=http://127.0.0.1:9000/ user=everyone

Signup to https://ngrok.com and download ngrok

Then in another command prompt run ngrok:

C:\Users\Jake\Downloads\ngrok>ngrok -authtoken <YOUR_AUTH_TOKEN> 9000

It should say something like this:

ngrok

Tunnel Status                 online
Version                       1.7/1.6
Forwarding                    http://3730a8f6.ngrok.com -> 127.0.0.1:9000
Forwarding                    https://3730a8f6.ngrok.com -> 127.0.0.1:9000
Web Interface                 127.0.0.1:4040
# Conn                        0
Avg Conn Time                 0.00ms

Now run the PandaDoc.WebhookTests web server:

C:\dev\PandaDoc\PandaDoc.WebhookTests\bin\Debug\PandaDoc.WebhookTests.exe

Then using a tool like POSTMAN send a some Http POST's to ngrok:

POST HTTP/1.1
Host: 3730a8f6.ngrok.com
Content-Type: application/json
Cache-Control: no-cache

{
    "document": {
        "status": "document.draft",
        "name": "Sample Document",
        "recipients": [
            {
                "first_name": "Jake",
                "last_name": "Jake",
                "email": "jake.net@gmail.com",
                "recipient_type": "CC",
                "has_completed": false,
                "id": "TvCqQ9G2wrXQxG9aLWEZ5g"
            }
        ],
        "date_modified": "2014-10-27T06:47:48.888834Z",
        "date_created": "2014-10-27T06:47:48.888809Z",
        "id": "yA6JdcNZemdYbf73Env9jk"
    },
    "event": "created"
}

Open up the ngrok local web interface http://localhost:4040/ and you should see some successful inbound requests!

In the PandaDoc.WebhookTests console window you should see the following:

Listening on http://127.0.0.1:9000/
yA6JdcNZemdYbf73Env9jk

About

PandaDoc .NET

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages