hellosign

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 12 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 Attachment added in v1.3.0

type Attachment struct {
	Name         string `field:"name"`
	Instructions string `field:"instructions"`
	SignerIndex  int    `field:"signer_index"`
	Required     bool   `field:"required"`
}

type Client

type Client struct {
	APIKey     string
	ClientID   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(request CreationRequest) (*SignatureRequest, error)

CreateEmbeddedSignatureRequest creates a new embedded signature

func (*Client) CreateSignatureRequest added in v1.3.0

func (m *Client) CreateSignatureRequest(request CreationRequest) (*SignatureRequest, error)

CreateSignatureRequest creates non-embedded signature request.

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) SendSignatureRequest added in v1.3.0

func (m *Client) SendSignatureRequest(request SignatureRequest) (*http.Response, error)

SendSignatureRequest - Creates and sends a new SignatureRequest with the submitted documents.

func (*Client) UpdateSignatureRequest

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

UpdateSignatureRequest - Update an email address on a signature request.

func (*Client) WithHTTPClient added in v1.2.0

func (m *Client) WithHTTPClient(httpClient *http.Client) *Client

type CreationRequest added in v1.3.0

type CreationRequest 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"`
	Attachments           []Attachment          `form_field:"attachments"`
	CustomFields          []CustomField         `form_field:"custom_fields"`
	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"`
	AllowDecline          bool                  `form_field:"allow_decline"`
	AllowReassign         bool                  `form_field:"allow_reassign"`
	FormFieldsPerDocument [][]DocumentFormField `form_field:"form_fields_per_document"`
}

CreationRequest contains the request parameters for create_embedded

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    interface{} `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.
	ApiID    string      `json:"api_id"`   // The unique ID for this field.
	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 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"`
	Warnings []Warning `json:"warnings"`
}

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.
	SignedAt           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.
	ReassignedBy       string  `json:"reassigned_by"`        // Email address of original signer who reassigned to this signer.
	ReassignmentReason string  `json:"reassignment_reason"`  // Reason provided by original signer who reassigned to this signer.
	Error              *string `json:"error"`                // Error message pertaining to this signer, or null.
}

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.
	OriginalTitle         string                   `json:"original_title"`          // Default Label for account.
	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.
	Metadata              map[string]interface{}   `json:"metadata"`                // The metadata attached to the signature request.
	CreatedAt             int                      `json:"created_at"`              // Time the signature request was created.
	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_address"`
	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