PandaDoc (pandadoc.com API v0.1.2) View Source
Documentation for PandaDoc which provides an API for pandadoc.com.
Installation
This package can be installed by adding pandadoc to your list of dependencies in mix.exs:
def deps do
  [{:pandadoc, "~> 0.1.2"}]
endConfiguration
Put the following lines into your config.exs or better, into your environment configuration files like test.exs, dev.exs or prod.exs.
config :pandadoc, api_key: "<your api key>"WebHooks in Phoenix
Put the following lines in a file called pandadoc_controller.ex inside your controllers directory.
defmodule YourAppWeb.PandaDocController do
  use PandaDoc.PhoenixController
  def handle_document_change(id, status, _details) do
    id
    |> Documents.get_by_pandadoc_id!()
    |> Documents.update_document(%{status: status})
  end
  def handle_document_complete(id, pdf, status, _details) do
    id
    |> Documents.get_by_pandadoc_id!()
    |> Documents.update_document(%{data: pdf, status: status})
  end
endPut the following lines into your router.ex and configure the WebHook in the pandadoc portal.
  post "/callbacks/pandadoc", YourAppWeb.PandaDocController, :webhookUsage
iex> recipients = [
  %PandaDoc.Recipient{
    email: "jane@example.com",
    first_name: "Jane",
    last_name: "Example",
    role: "signer1"
  }
]
iex> PandaDoc.create_document("Sample PandaDoc PDF.pdf", [] = pdf_bytes, recipients)
{:ok, "msFYActMfJHqNTKH8YSvF1"}        Link to this section Summary
Functions
Creates a new Document from the given PDF file.
Delete a document.
Get detailed data about a document such as name, status, dates, fields, metadata and much more.
Get basic data about a document such as name, status, and dates.
Download a PDF of any document.
Download a signed PDF of a completed document.
List documents, optionally filter by a search query or tags.
Move a document to sent status and send an optional email.
Generates a link for the given recipient that you can just email or iframe with a validity of lifetime seconds (86400 by default).
Link to this section Functions
create_document(name, pdf_bytes, recipients, fields \\ %{}, tags \\ [], parse_form_fields \\ false, client \\ Connection.new())
View SourceSpecs
create_document( String.t(), binary(), [PandaDoc.Model.Recipient.t()], map() | nil, [String.t()] | nil, boolean() | nil, Tesla.Env.client() | nil ) :: {:ok, String.t()} | {:ok, PandaDoc.Model.BasicDocumentResponse.t()} | {:ok, PandaDoc.Model.ErrorResponse.t()} | {:error, Tesla.Env.t()}
Creates a new Document from the given PDF file.
Parameters
- name (String): Name of the document
 - pdf_bytes (Binary): PDF content
 - recipients ([PandaDoc.Model.Recipient]): Array of Recipients
 - fields (Map): [optional] Field-mappings for the PDF
 - tags ([String]): [optional] Array of Tags
 - parse_form_fields (Boolean): [optional] Should PandaDoc parse old-style PDF Fields?
 - connection (PandaDoc.Connection): [optional] Connection to server
 
Returns
{:ok, document_id}on success{:error, info}on failure
Examples
iex> pdf_bytes = File.read("/path/to/my.pdf")
iex> recipients = [
  %PandaDoc.Model.Recipient{email: "jane@example.com", first_name: "Jane", last_name: "Example", role: "signer1"}
]
iex> fields = %{
  name: %PandaDoc.Model.Field{value: "John", role: "signer1"}
}
iex> PandaDoc.create_document("Sample PandaDoc PDF.pdf", pdf_bytes, recipients, fields, ["tag1"])
{:ok, "msFYActMfJHqNTKH8YSvF1"}  Specs
delete_document(String.t(), Tesla.Env.client() | nil) :: {:ok, :atom} | {:ok, PandaDoc.Model.ErrorResponse.t()} | {:error, Tesla.Env.t()}
Delete a document.
Parameters
- id (String): PandaDoc Document ID
 - connection (PandaDoc.Connection): [optional] Connection to server
 
Returns
{:ok, :ok}on success{:error, info}on failure
Examples
iex> PandaDoc.delete_document("msFYActMfJHqNTKH8YSvF1")
:ok  Specs
document_details(String.t(), Tesla.Env.client() | nil) :: {:ok, PandaDoc.Model.DocumentResponse.t()} | {:ok, PandaDoc.Model.ErrorResponse.t()} | {:error, Tesla.Env.t()}
Get detailed data about a document such as name, status, dates, fields, metadata and much more.
Parameters
- id (String): PandaDoc Document ID
 - connection (PandaDoc.Connection): [optional] Connection to server
 
Returns
{:ok, %PandaDoc.Model.DocumentResponse{}}on success{:error, info}on failure
Examples
iex> PandaDoc.document_details("msFYActMfJHqNTKH8YSvF1")
{:ok, %PandaDoc.Model.DocumentResponse{id: "msFYActMfJHqNTKH8YSvF1", status: "document.waiting_approval"}}  Specs
document_status(String.t(), Tesla.Env.client() | nil) :: {:ok, PandaDoc.Model.BasicDocumentResponse.t()} | {:ok, PandaDoc.Model.ErrorResponse.t()} | {:error, Tesla.Env.t()}
Get basic data about a document such as name, status, and dates.
Parameters
- id (String): PandaDoc Document ID
 - connection (PandaDoc.Connection): [optional] Connection to server
 
Returns
{:ok, %PandaDoc.Model.BasicDocumentResponse{}}on success{:error, info}on failure
Examples
iex> PandaDoc.document_status("msFYActMfJHqNTKH8YSvF1")
{:ok, %PandaDoc.Model.BasicDocumentResponse{id: "msFYActMfJHqNTKH8YSvF1", status: "document.waiting_approval"}}  Specs
download_document( String.t(), keyword(String.t()) | nil, Tesla.Env.client() | nil ) :: {:ok, binary()} | {:ok, PandaDoc.Model.ErrorResponse.t()} | {:error, Tesla.Env.t()}
Download a PDF of any document.
Parameters
- id (String): PandaDoc Document ID
 - query (Keywords): [optional] Query parameters for Watermarks
 - connection (PandaDoc.Connection): [optional] Connection to server
 
Returns
{:ok, [] = pdf_bytes}on success{:error, info}on failure
Examples
iex> PandaDoc.download_document("msFYActMfJHqNTKH8YSvF1", watermark_text: "WATERMARKED")
{:ok, []}  download_protected_document(id, query \\ [], client \\ Connection.new())
View SourceSpecs
download_protected_document( String.t(), keyword(String.t()) | nil, Tesla.Env.client() | nil ) :: {:ok, binary()} | {:ok, PandaDoc.Model.ErrorResponse.t()} | {:error, Tesla.Env.t()}
Download a signed PDF of a completed document.
- id (String): PandaDoc Document ID
 - query (Keywords): [optional] Query parameters for Watermarks
 - connection (PandaDoc.Connection): [optional] Connection to server
 
Returns
{:ok, [] = pdf_bytes}on success{:error, info}on failure
Examples
iex> PandaDoc.download_protected_document("msFYActMfJHqNTKH8YSvF1")
{:ok, []}  Specs
list_documents(keyword(String.t()) | nil, Tesla.Env.client() | nil) :: {:ok, PandaDoc.Model.DocumentListResponse.t()} | {:ok, PandaDoc.Model.ErrorResponse.t()} | {:error, Tesla.Env.t()}
List documents, optionally filter by a search query or tags.
Parameters
- query (Keywords): [optional] Query parameters
 - connection (PandaDoc.Connection): [optional] Connection to server
 
Returns
{:ok, [%PandaDoc.Model.BasicDocumentResponse{}}on success{:error, info}on failure
Examples
iex> PandaDoc.list_documents()
{:ok, %PandaDoc.Model.DocumentListResponse{results: [%PandaDoc.Model.BasicDocumentResponse{}]}}  send_document(id, subject \\ nil, message \\ nil, silent \\ false, client \\ Connection.new())
View SourceSpecs
send_document( String.t(), String.t() | nil, String.t() | nil, boolean() | nil, Tesla.Env.client() | nil ) :: {:ok, PandaDoc.Model.BasicDocumentResponse.t()} | {:ok, PandaDoc.Model.ErrorResponse.t()} | {:error, Tesla.Env.t()}
Move a document to sent status and send an optional email.
Parameters
- id (String): PandaDoc Document ID
 - subject (String): [optional] E-Mail Subject
 - message (String): [optional] E-Mail Message
 - contact (PandaDoc.Model.CreateContact): Contact data
 - connection (PandaDoc.Connection): [optional] Connection to server
 
Returns
{:ok, %PandaDoc.Model.BasicDocumentResponse{}}on success{:error, info}on failure
Examples
iex> PandaDoc.send_document("msFYActMfJHqNTKH8YSvF1", "Document ready", "Hi there, please sign this document")
{:ok, %PandaDoc.Model.BasicDocumentResponse{id: "msFYActMfJHqNTKH8YSvF1", status: "document.sent"}}