hellosign

package module
v0.0.0-...-5a80573 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: MIT Imports: 11 Imported by: 0

README

build status

HelloSign Go SDK

A Go wrapper for the HelloSign API.

The unofficial library for using the HelloSign API for golang.

https://app.hellosign.com/api/reference

Installation

go get github.com/jheth/hellosign-go-sdk

Usage

Client
client := hellosign.Client{APIKey: "ACCOUNT API KEY"}
Embedded Signature Request

using FileURL

request := hellosign.EmbeddedRequest{
  TestMode: true,
  ClientID: os.Getenv("HELLOSIGN_CLIENT_ID"),
  FileURL:  []string{"http://www.pdf995.com/samples/pdf.pdf"},
  Title:    "My First Document",
  Subject:  "Contract",
  Signers: []hellosign.Signer{
    hellosign.Signer{
      Email: "jane@example.com",
      Name:  "Jane Doe",
    },
  },
}

response, err := client.CreateEmbeddedSignatureRequest(request)
if err != nil {
  log.Fatal(err)
}
// type SignatureRequest
fmt.Println(response.SignatureRequestID)

using File

request := hellosign.EmbeddedRequest{
  TestMode: true,
  ClientID: "APP_CLIENT_ID",
  File:     []string{"public/offer_letter.pdf"},
  Title:    "My First Document",
  Subject:  "Contract",
  Signers:  []hellosign.Signer{
    hellosign.Signer{
      Email: "jane@doe.com",
      Name:  "Jane Doe",
    },
    hellosign.Signer{
      Email: "john@gmail.com",
      Name:  "John DOe",
    },
  },
}

response, err := client.CreateEmbeddedSignatureRequest(request)
if err != nil {
  log.Fatal(err)
}
// type SignatureRequest
fmt.Println(response.SignatureRequestID)

Full Feature

request := hellosign.EmbeddedRequest{
  TestMode: true,
  ClientID: os.Getenv("HS_CLIENT_ID"),
  File: []string{
    "public/offer_letter.pdf",
    "public/offer_letter.pdf",
  },
  Title:     "My Document",
  Subject:   "Please Sign",
  Message:   "A message can go here.",
  Signers: []hellosign.Signer{
    hellosign.Signer{
      Email: "freddy@hellosign.com",
      Name:  "Freddy Rangel",
      Pin:   "1234",
      Order: 1,
    },
    hellosign.Signer{
      Email: "frederick.rangel@gmail.com",
      Name:  "Frederick Rangel",
      Pin:   "1234",
      Order: 2,
    },
  },
  CCEmailAddresses: []string{
    "no@cats.com",
    "no@dogs.com",
  },
  UseTextTags:  false,
  HideTextTags: true,
  Metadata: map[string]string{
    "no":   "cats",
    "more": "dogs",
  },
  FormFieldsPerDocument: [][]hellosign.DocumentFormField{
    []hellosign.DocumentFormField{
      hellosign.DocumentFormField{
        APIId:    "api_id",
        Name:     "display name",
        Type:     "text",
        X:        123,
        Y:        456,
        Width:    678,
        Required: true,
        Signer:   0,
      },
    },
    []hellosign.DocumentFormField{
      hellosign.DocumentFormField{
        APIId:    "api_id_2",
        Name:     "display name 2",
        Type:     "text",
        X:        123,
        Y:        456,
        Width:    678,
        Required: true,
        Signer:   1,
      },
    },
  },
}

response, err := client.CreateEmbeddedSignatureRequest(request)
if err != nil {
  log.Fatal(err)
}
// type SignatureRequest
fmt.Println(response.SignatureRequestID)
Get Signature Request
// uses SignatureRequestID
res, err := client.GetSignatureRequest("6d7ad140141a7fe6874fec55931c363e0301c353")

// res is SignatureRequest type
res.SignatureRequestID
res.Signatures
Get Embedded Sign URL
// uses SignerID
res, err := client.GetEmbeddedSignURL("deaf86bfb33764d9a215a07cc060122d")

res.SignURL =>  "https://app.hellosign.com/editor/embeddedSign?signature_id=deaf86bfb33764d9a215a07cc060122d&token=TOKEN"
Get PDF
// uses SignatureRequestID
fileInfo, err := client.GetPDF("6d7ad140141a7fe6874fec55931c363e0301c353", "/tmp/download.pdf")

fileInfo.Size() => 98781
fileInfo.Name() => "download.pdf"
Get Files
// uses SignatureRequestID
fileInfo, err := client.GetFiles("6d7ad140141a7fe6874fec55931c363e0301c353", "zip",  "/tmp/download.zip")

fileInfo.Size() => 98781
fileInfo.Name() => "download.zip"
List Signature Requests
res, err := client.ListSignatureRequests()

res.ListInfo.NumPages => 1
res.ListInfo.Page => 1
res.ListInfo.NumResults => 19
res.ListInfo.PageSize => 20

len(res.SignatureRequests) => 19
Update Signature Request
res, err := client.UpdateSignatureRequest(
  "9040be434b1301e31019b3dad895ed580f8ca890", // SignatureRequestID
  "deaf86bfb33764d9a215a07cc060122d", // SignatureID
  "joe@hello.com", // New Email
)

res.SignatureRequestID => "9040be434b1301e31019b3dad895ed580f8ca890"
res.Signatures[0].SignerEmailAddress => "joe@hello.com"
Cancel Signature Request
// uses SignatureRequestID
res, err := client.CancelSignatureRequest("5c002b65dfefab79795a521bef312c45914cc48d")

// res is *http.Response
res.StatusCode => 200

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	APIKey     string
	BaseURL    string
	HTTPClient *http.Client
}

Client contains APIKey and optional http.client

func (*Client) CancelSignatureRequest

func (m *Client) CancelSignatureRequest(signatureRequestID string) (*http.Response, error)

CancelSignatureRequest - Cancels an incomplete signature request. This action is not reversible.

func (*Client) CreateEmbeddedSignatureRequest

func (m *Client) CreateEmbeddedSignatureRequest(
	embeddedRequest EmbeddedRequest) (*SignatureRequest, error)

CreateEmbeddedSignatureRequest creates a new embedded signature

func (*Client) DeleteSignatureRequest

func (m *Client) DeleteSignatureRequest(signatureRequestID string) (*http.Response, error)

DeleteSignatureRequest - Remove access to a completed SignatureRequest. This action is not reversible.

func (*Client) GetEmbeddedSignURL

func (m *Client) GetEmbeddedSignURL(signatureRequestID string) (*SignURLResponse, error)

GetEmbeddedSignURL - Retrieves an embedded signing object.

func (*Client) GetFiles

func (m *Client) GetFiles(signatureRequestID, fileType string) ([]byte, error)

GetFiles - Obtain a copy of the current documents specified by the signature_request_id parameter. signatureRequestID - The id of the SignatureRequest to retrieve. fileType - Set to "pdf" for a single merged document or "zip" for a collection of individual documents.

func (*Client) GetPDF

func (m *Client) GetPDF(signatureRequestID string) ([]byte, error)

GetPDF - Obtain a copy of the current pdf specified by the signature_request_id parameter.

func (*Client) GetSignatureRequest

func (m *Client) GetSignatureRequest(signatureRequestID string) (*SignatureRequest, error)

GetSignatureRequest - Gets a SignatureRequest that includes the current status for each signer.

func (*Client) ListSignatureRequests

func (m *Client) ListSignatureRequests() (*ListResponse, error)

ListSignatureRequests - Lists the SignatureRequests (both inbound and outbound) that you have access to.

func (*Client) SaveFile

func (m *Client) SaveFile(signatureRequestID, fileType, destFilePath string) (os.FileInfo, error)

func (*Client) UpdateSignatureRequest

func (m *Client) UpdateSignatureRequest(signatureRequestID string, signatureID string, email string) (*SignatureRequest, error)

UpdateSignatureRequest - Update an email address on a signature request.

type CustomField

type CustomField struct {
	Name     string `json:"name"`     // The name of the Custom Field.
	Type     string `json:"type"`     // The type of this Custom Field. Only 'text' and 'checkbox' are currently supported.
	Value    string `json:"value"`    // A text string for text fields or true/false for checkbox fields
	Required bool   `json:"required"` // A boolean value denoting if this field is required.
	Editor   string `json:"editor"`   // The name of the Role that is able to edit this field.
}

type DocumentFormField

type DocumentFormField struct {
	APIId    string `json:"api_id"`
	Name     string `json:"name"`
	Type     string `json:"type"`
	X        int    `json:"x"`
	Y        int    `json:"y"`
	Width    int    `json:"width"`
	Height   int    `json:"height"`
	Required bool   `json:"required"`
	Signer   int    `json:"signer"`
}

type EmbeddedRequest

type EmbeddedRequest struct {
	TestMode              bool                  `form_field:"test_mode"`
	ClientID              string                `form_field:"client_id"`
	FileURL               []string              `form_field:"file_url"`
	File                  []string              `form_field:"file"`
	Title                 string                `form_field:"title"`
	Subject               string                `form_field:"subject"`
	Message               string                `form_field:"message"`
	SigningRedirectURL    string                `form_field:"signing_redirect_url"`
	Signers               []Signer              `form_field:"signers"`
	CCEmailAddresses      []string              `form_field:"cc_email_addresses"`
	UseTextTags           bool                  `form_field:"use_text_tags"`
	HideTextTags          bool                  `form_field:"hide_text_tags"`
	Metadata              map[string]string     `form_field:"metadata"`
	FormFieldsPerDocument [][]DocumentFormField `form_field:"form_fields_per_document"`
}

EmbeddedRequest contains the request parameters for create_embedded

type EmbeddedResponse

type EmbeddedResponse struct {
	Embedded *SignURLResponse `json:"embedded"`
}

type Error

type Error struct {
	Message string `json:"error_msg"`
	Name    string `json:"error_name"`
}

type ErrorResponse

type ErrorResponse struct {
	Error *Error `json:"error"`
}

type ListInfo

type ListInfo struct {
	NumPages   int `json:"num_pages"`   // Total number of pages available
	NumResults int `json:"num_results"` // Total number of objects available
	Page       int `json:"page"`        // Number of the page being returned
	PageSize   int `json:"page_size"`   // Objects returned per page
}

type ListResponse

type ListResponse struct {
	ListInfo          *ListInfo           `json:"list_info"`
	SignatureRequests []*SignatureRequest `json:"signature_requests"`
}

type ResponseData

type ResponseData struct {
	ApiID       string `json:"api_id"`       // The unique ID for this field.
	SignatureID string `json:"signature_id"` // The ID of the signature to which this response is linked.
	Name        string `json:"name"`         // The name of the form field.
	Value       string `json:"value"`        // The value of the form field.
	Required    bool   `json:"required"`     // A boolean value denoting if this field is required.
	Type        string `json:"type"`         // The type of this form field. See field types
}

type SignURLResponse

type SignURLResponse struct {
	SignURL   string `json:"sign_url"`   // URL of the signature page to display in the embedded iFrame.
	ExpiresAt int    `json:"expires_at"` // When the link expires.
}

type Signature

type Signature struct {
	SignatureID        string `json:"signature_id"`         // Signature identifier.
	SignerEmailAddress string `json:"signer_email_address"` // The email address of the signer.
	SignerName         string `json:"signer_name"`          // The name of the signer.
	Order              int    `json:"order"`                // If signer order is assigned this is the 0-based index for this signer.
	StatusCode         string `json:"status_code"`          // The current status of the signature. eg: awaiting_signature, signed, declined
	DeclineReason      string `json:"decline_reason"`       // The reason provided by the signer for declining the request.
	SignatedAt         int    `json:"signed_at"`            // Time that the document was signed or null.
	LastViewedAt       int    `json:"last_viewed_at"`       //The time that the document was last viewed by this signer or null.
	LastRemindedAt     int    `json:"last_reminded_at"`     //The time the last reminder email was sent to the signer or null.
	HasPin             bool   `json:"has_pin"`              // Boolean to indicate whether this signature requires a PIN to access.
}

type SignatureRequest

type SignatureRequest struct {
	TestMode              bool                     `json:"test_mode"`               // Whether this is a test signature request. Test requests have no legal value. Defaults to 0.
	SignatureRequestID    string                   `json:"signature_request_id"`    // The id of the SignatureRequest.
	RequesterEmailAddress string                   `json:"requester_email_address"` // The email address of the initiator of the SignatureRequest.
	Title                 string                   `json:"title"`                   // The title the specified Account uses for the SignatureRequest.
	Subject               string                   `json:"subject"`                 // The subject in the email that was initially sent to the signers.
	Message               string                   `json:"message"`                 // The custom message in the email that was initially sent to the signers.
	IsComplete            bool                     `json:"is_complete"`             // Whether or not the SignatureRequest has been fully executed by all signers.
	IsDeclined            bool                     `json:"is_declined"`             // Whether or not the SignatureRequest has been declined by a signer.
	HasError              bool                     `json:"has_error"`               // Whether or not an error occurred (either during the creation of the SignatureRequest or during one of the signings).
	FilesURL              string                   `json:"files_url"`               // The URL where a copy of the request's documents can be downloaded.
	SigningURL            string                   `json:"signing_url"`             // The URL where a signer, after authenticating, can sign the documents. This should only be used by users with existing HelloSign accounts as they will be required to log in before signing.
	DetailsURL            string                   `json:"details_url"`             // The URL where the requester and the signers can view the current status of the SignatureRequest.
	CCEmailAddress        []*string                `json:"cc_email_addresses"`      // A list of email addresses that were CCed on the SignatureRequest. They will receive a copy of the final PDF once all the signers have signed.
	SigningRedirectURL    string                   `json:"signing_redirect_url"`    // The URL you want the signer redirected to after they successfully sign.
	CustomFields          []map[string]interface{} `json:"custom_fields"`           // An array of Custom Field objects containing the name and type of each custom field.
	ResponseData          []*ResponseData          `json:"response_data"`           // An array of form field objects containing the name, value, and type of each textbox or checkmark field filled in by the signers.
	Signatures            []*Signature             `json:"signatures"`              // An array of signature objects, 1 for each signer.
	Warnings              []*Warning               `json:"warnings"`                // An array of warning objects.
}

type SignatureRequestResponse

type SignatureRequestResponse struct {
	SignatureRequest *SignatureRequest `json:"signature_request"`
}

type Signer

type Signer struct {
	Name  string `field:"name"`
	Email string `field:"email"`
	Order int    `field:"order"`
	Pin   string `field:"pin"`
}

type Warning

type Warning struct {
	Message string `json:"warning_msg"`
	Name    string `json:"warning_name"`
}

Jump to

Keyboard shortcuts

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