panda_api_js

1.2.4 • Public • Published

PandaDoc API Yarn Package

JS Wrapper for PandaDoc API

Installation

yarn add panda_api_js

Capabilities

Get Bearer Token

  1. Visit PandaDoc Developers Portal (https://developers.pandadoc.com/)
  2. Visit "My Applications" Tab
  3. Create PandaDoc Application (Application Name, Application Author, Redirect URI)
  4. Upon completion, you will receive a Client ID and Client Secret
  5. Install panda_api gem and instantiate the class
var panda = new PandaDoc("", "")
  1. Get Code
panda.getCode({ 
  client_id: <YOUR_CLIENT_ID>,
  client_secret: <YOUR_CLIENT_SECRET>,
  redirect_uri: <YOUR_REDIRECT_URI>,
  grant_type: "authorization_code",
  scope: "read+write"
})
  1. A browser tab will launch. If you are signed into PandaDoc, you authorize PandaDoc
  2. You will be redirected to your redirect_uri, with your code appended to the URL
https://myredirecturi.com/?state=&code=<YOUR_CODE_TO_PASTE>
  1. Copy the code. You are prompted to paste the code into your prompt
  2. Your access token will be returned to you
{"access_token"=>"<YOUR_ACCESS_TOKEN>",
"token_type"=>"Bearer",
"expires_in"=>31535999,
"scope"=>"read write read+write",
"refresh_token"=>"<YOUR_REFRESH_TOKEN>”}

Instantiate with API Key

  1. Get API Key from Integrations Page on PandaDoc
  2. Instantiate new PandaDoc class instance
var panda = new PandaDoc(<YOUR_API_KEY>, "api")
  1. You're Ready to go!

Refresh Oauth Token

var panda = new PandaDoc(<YOUR_BEARER_TOKEN>, "bearer")

refresh_token = panda.refreshAccessToken({
 client_id: <YOUR_CLIENT_ID>,
 client_secret: <YOUR_CLIENT_SECRET>,
 # your REFRESH TOKEN, NOT Access Token 
 refresh_token: <YOUR_REFRESH_TOKEN>,
 scope: <read, write, read+write>
})

Instance Methods

(https://developers.pandadoc.com/reference)

var panda = new PandaDoc(<YOUR_KEY>, <YOUR_KEY_TYPE>)

# Documents Index (GET)
panda.listDocuments({ <YOUR_PARAMS> })

# Templates Index (GET)
panda.listTemplates({ <YOUR_PARAMS> })

# Document Details (GET)
# Document ID Required
panda.documentDetails({ <YOUR_PARAMS> }) 

# Document Status (GET)
# Document ID Required
panda.documentStatus({ <YOUR_PARAMS> }) 

# Template Details (GET)
# Template ID Required
panda.templateDetails({ YOUR_PARAMS })

# Create Document (PDF) (POST)
  var newDoc = panda.createDocumentFromPdf(
   # Valid File: File {<YOUR_FILE>} || params.files[0]
   file: <file_to_send>,
   name: "New PandaDoc Document from PDF",
   recipients: [ { email: "matt@example.com",first_name: "Matt",last_name: "sample",role: "u00"}],
   fields: <YOUR_FIELDS>,
   metadata: <YOUR_META>,
   parse_form_fields: false
 ).body

# Create Document (Template) (POST)
  var newDoc = panda.createDocumentFromTemplate({
   name: "New Doc From Template",
   template_uuid: "<YOUR_TEMPLATE_ID>",
   recipients: [{ first_name: "Balton", last_name: "Reign", email: "client@gmail.com" }],
   tokens: [{ name: "Client.FirstName", value: "Percy" }, { name: "Client.LastName", value: "Johnson" }],
   fields: <YOUR_FIELDS>,
   metadata: <YOUR_META>
 })
 
 # Send Document (POST)
 panda.sendDocument({ id: <YOUR_DOC_ID>, message: <YOUR_MESSAGE>, subject: <YOUR_SUBJECT>, silent: true || false })
 
 # Create Document Session ID (POST)
 panda.createDocumentLink({ id: <YOUR_DOC_ID>, recipient: <YOUR_RECIPIENT_EMAIL>, lifetime: 3600 })
 
 # Download Document (GET)
 panda.downloadDocument({ id: <YOUR_DOC_ID> })
 
 # Download Protected Document (GET)
 panda.downloadProtectedDocument({ id: <YOUR_DOC_ID> })
 
 # Delete Document (DELETE)
 panda.deleteDocument({ id: <YOUR_DOC_ID> })
 
 # Delete Template (DELETE)
 panda.deleteTemplate({ id: <YOUR_TEMP_ID> })
 
 # Create Document Folder (POST)
 panda.createDocumentFolder({ name: "<YOUR_NEW_FOLDER_NAME>" })
 
 # Create Template Folder (POST)
 panda.createTemplateFolder({ name: "<YOUR_NEW_FOLDER_NAME>" })
 
 # List Template Folders (POST)
 panda.listTemplateFolders({ <YOUR_PARAMS> })
 
 # List Document Folders (POST)
 panda.listDocumentFolders({ <YOUR_PARAMS> })
 
 # Update Document Folder Name (PUT)
 panda.updateDocumentFolder({ <YOUR_PARAMS> })
 
 # Update Template Folder Name (PUT)
 panda_doc_api.updateTemplateFolder({ YOUR_PARAMS })

Questions / Concerns

Please reach out directly to the author, matt.deatherage@pandadoc.com

Readme

Keywords

none

Package Sidebar

Install

npm i panda_api_js

Weekly Downloads

0

Version

1.2.4

License

MIT

Unpacked Size

14.3 kB

Total Files

4

Last publish

Collaborators

  • mwd1992