Skip to content

jheth/hellosign-go-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: "[email protected]",
      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: "[email protected]",
      Name:  "Jane Doe",
    },
    hellosign.Signer{
      Email: "[email protected]",
      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: "[email protected]",
      Name:  "Freddy Rangel",
      Pin:   "1234",
      Order: 1,
    },
    hellosign.Signer{
      Email: "[email protected]",
      Name:  "Frederick Rangel",
      Pin:   "1234",
      Order: 2,
    },
  },
  CCEmailAddresses: []string{
    "[email protected]",
    "[email protected]",
  },
  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
  "[email protected]", // New Email
)

res.SignatureRequestID => "9040be434b1301e31019b3dad895ed580f8ca890"
res.Signatures[0].SignerEmailAddress => "[email protected]"

Cancel Signature Request

// uses SignatureRequestID
res, err := client.CancelSignatureRequest("5c002b65dfefab79795a521bef312c45914cc48d")

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

About

A Go wrapper for the HelloSign API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%