anvil

package module
v0.0.2-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 13 Imported by: 0

README

golang-anvil

Golang API Client and CLI tool for Anvil

This is a library that provides an interface to access the Anvil API from applications written in the Go programming language.

Anvil provides easy APIs for all things paperwork.

  1. PDF filling API - fill out a PDF template with a web request and structured JSON data.
  2. PDF generation API - send markdown or HTML and Anvil will render it to a PDF.
  3. Etch e-sign with API - customizable, embeddable, e-signature platform with an API to control the signing process end-to-end.
  4. Anvil Workflows (w/ API) - Webforms + PDF + e-sign with a powerful no-code builder. Easily collect structured data, generate PDFs, and request signatures.

Learn more on our Anvil developer page. See the API guide and the GraphQL reference for full documentation.

Documentation

General API documentation: Anvil API docs

Setup

Requirements

  • Go 1.18+

Usage

$ go get github.com/rmn87/golang-anvil

Documentation

Overview

Package anvil provides an interface to access the Anvil API

Index

Constants

View Source
const TEMPLATE_VERSION_LATEST = -1
View Source
const TEMPLATE_VERSION_LATEST_PUBLISHED = -2

Variables

View Source
var VERSION = ""

Functions

This section is empty.

Types

type Anvil

type Anvil struct {
	APIKey         string
	RESTAPIVersion string
	BaseURL        string
	UserAgent      string
	Logger         *log.Logger
	// contains filtered or unexported fields
}

func New

func New(apiKey string) (anvil *Anvil)

func (*Anvil) CreateEtchPacket

func (s *Anvil) CreateEtchPacket(payload interface{}) (etchPacketID string, err error)

CreateEtchPacket creates an etch packet via a graphql mutation.

func (*Anvil) DownloadDocuments

func (s *Anvil) DownloadDocuments(documentGroupEID string) (zip []byte, err error)

DownloadDocuments retrieves all completed documents in zip form.

func (*Anvil) FillPDF

func (s *Anvil) FillPDF(templateID, templateVersion string, payload interface{}) (pdf []byte, err error)

FillPDF fills an existing template with provided payload data.

Use the casts graphql query to get a list of available templates you can use for this request.

By default, the request will use the latest published version. You can also use the constants `anvil.TEMPLATE_VERSION_LATEST_PUBLISHED` and `anvil.TEMPLATE_VERSION_LATEST` instead of providing a specific version number.

func (*Anvil) GenerateEtchSigningURL

func (s *Anvil) GenerateEtchSigningURL(signerEID, clientUserID string) (etchSigningURL string, err error)

GenerateEtchSigningURL generates a signing URL for a given user.

func (*Anvil) GeneratePDF

func (s *Anvil) GeneratePDF(payload interface{}) (pdf []byte, err error)

GeneratePDF dynamically generates a new PDF with provided payload data. Useful for agreements, invoices, disclosures, or any other text-heavy documents.

By default, GeneratePDF will format data assuming it's in markdown.

HTML is another supported input type. This can be used by providing `"type": "html"` in the payload and making the `data` field a dict containing keys `"html"` and an optional `"css"`.

type FillPDFPayload

type FillPDFPayload struct {
	Data map[string]interface{} `json:"data"`

	// optional
	Title                *string `json:"title,omitempty"`
	FontFamily           *string `json:"fontFamily,omitempty"`
	FontSize             *int    `json:"fontSize,omitempty"`
	TextColor            *string `json:"textColor,omitempty"`
	UseInteractiveFields *bool   `json:"useInteractiveFields,omitempty"`
}

type GeneratePDFPayload

type GeneratePDFPayload struct {
	Data string `json:"data"`

	// optional
	Title            *string `json:"title,omitempty"`
	Type             *string `json:"type,omitempty"`
	FontFamily       *string `json:"fontFamily,omitempty"`
	FontSize         *int    `json:"fontSize,omitempty"`
	TextColor        *string `json:"textColor,omitempty"`
	IncludeTimestamp *bool   `json:"includeTimestamp,omitempty"`
	Page             *Page   `json:"page,omitempty"`
}
type Logo struct {
	Src       *string `json:"src,omitempty"`
	MaxWidth  *int    `json:"maxWidth,omitempty"`
	MaxHeight *int    `json:"maxHeight,omitempty"`
}

type Page

type Page struct {
	Margin       *string `json:"margin,omitempty"`
	MarginTop    *string `json:"marginTop,omitempty"`
	MarginBottom *string `json:"marginBottom,omitempty"`
	MarginLeft   *string `json:"marginLeft,omitempty"`
	MarginRight  *string `json:"marginRight,omitempty"`
	PageCount    *string `json:"pageCount,omitempty"`
	Width        *int    `json:"width,omitempty"`
	Height       *int    `json:"height,omitempty"`
}

Directories

Path Synopsis
cmd
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL