hellosign

package module
v1.1.21 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 14 Imported by: 0

README

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

Usage

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

using FileURL

request := hellosign.EmbeddedSignatureRequest{
  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.GetSignatureRequestID())

using File

request := hellosign.EmbeddedSignatureRequest{
  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.GetSignatureRequestID())

Full Feature

request := hellosign.EmbeddedSignatureRequest{
  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.GetSignatureRequestID())
Get Signature Request
// uses SignatureRequestID
res, err := client.GetSignatureRequest("6d7ad140141a7fe6874fec55931c363e0301c353")

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

res.GetSignUrl() =>  "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.GetListInfo().GetNumPages() => 1
res.GetListInfo().GetPage() => 1
res.GetListInfo().GetNumResults() => 19
res.GetListInfo().GetPageSize() => 20

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

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

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

Documentation

Index

Constants

View Source
const (
	HellosignCustomLogoFileKey        = "custom_logo_file"
	DomainsKey                 string = "domains"
)
View Source
const (
	CCEmailAddressesKey string = "cc_email_addresses"
	FileKey             string = "file"
	SignersKey          string = "signers"
	FormFieldsPerDocKey string = "form_fields_per_document"
	CustomFieldsKey     string = "custom_fields"
	FormFieldKey        string = "form_field"
)
View Source
const (
	ClientIDKey    string = "client_id"
	TestModeKey    string = "test_mode"
	TitleKey       string = "title"
	SubjectKey     string = "subject"
	MessageKey     string = "message"
	ShowPreviewKey string = "show_preview"
	PreviewOnlyKey string = "preview_only"
	MetadataKey    string = "metadata"
	SignerRolesKey string = "signer_roles"
	FileURLKey     string = "file_url"
)

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 model.EmbeddedSignatureRequest) (*model.SignatureRequest, error)

CreateEmbeddedSignatureRequest creates a new embedded signature

func (*Client) CreateEmbeddedSignatureWithTemplateRequest added in v1.1.6

func (m *Client) CreateEmbeddedSignatureWithTemplateRequest(embeddedRequest model.EmbeddedSignatureWithTemplateRequest, signerRoles []model.SignerRole) (*model.SignatureRequest, error)

CreateEmbeddedSignatureWithTemplateRequest creates a new embedded signature with template id

func (*Client) CreateEmbeddedTemplate added in v1.1.1

func (m *Client) CreateEmbeddedTemplate(req model.CreateEmbeddedTemplateRequest) (*model.EmbeddedTemplate, error)

CreateEmbeddedTemplate creates a new embedded Template

func (*Client) CreateNewApiApp added in v1.1.4

func (m *Client) CreateNewApiApp(req model.CreateApiAppRequest) (*model.APIApp, error)

CreateNewApiApp – Creates a new API App. Note: we don't support a single domain at the moment as it is out of our current use cases

func (*Client) DeleteSignatureRequest added in v1.1.1

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

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

func (*Client) DeleteTemplate added in v1.1.1

func (m *Client) DeleteTemplate(templateID string) (*http.Response, error)

DeleteTemplate completely deletes the template specified from the account and is irreversible

func (*Client) GetEmbeddedSignURL

func (m *Client) GetEmbeddedSignURL(signatureID string) (*model.SignURLResponse, error)

GetEmbeddedSignURL - Retrieves an embedded signing object.

func (*Client) GetEmbeddedTemplateEditURL added in v1.1.2

func (m *Client) GetEmbeddedTemplateEditURL(templateID, customFields string, enableEdit, testMode bool) (*model.EmbeddedTemplateEditURL, error)

GetEmbeddedTemplateEditURL - Retrieves an embedded template object to edit.

func (*Client) GetEmbeddedTemplateEditURLForPreview added in v1.1.16

func (m *Client) GetEmbeddedTemplateEditURLForPreview(templateID string, testMode bool) (*model.EmbeddedTemplateEditURL, error)

GetEmbeddedTemplateEditURLForPreview - Retrieves an embedded template object for preview. This method uses model.CreateEmbeddedTemplateRequest under the hood which probably needs to be renamed so that it can be reused across different methods.

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. note: this will return an unsigned copy instead of 404 if the signature request is not signed.

func (*Client) GetFinalCopy added in v1.1.15

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

GetFinalCopy - Obtain a final (signed) copy of a signature_request_id in pdf format.

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) (*model.SignatureRequest, error)

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

func (*Client) GetTemplate added in v1.1.9

func (m *Client) GetTemplate(templateID string) (*model.Template, error)

func (*Client) ListSignatureRequests

func (m *Client) ListSignatureRequests() (*model.ListSignaturesResponse, error)

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

func (*Client) ListTemplates added in v1.1.1

func (m *Client) ListTemplates() (*model.ListTemplatesResponse, error)

ListTemplates retrieves a list that are accessible by your account

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) (*model.SignatureRequest, error)

UpdateSignatureRequest - Update an email address on a signature request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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