docusign

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAuthURL

func BuildAuthURL(integrationKey string) string

BuildAuthURL constructs the OAuth authorization URL.

func OAuthBaseURL

func OAuthBaseURL() string

OAuthBaseURL returns the OAuth base URL from env or default.

func RedirectURI

func RedirectURI() string

RedirectURI returns the redirect URI from env or default.

func RemoveTokens

func RemoveTokens() error

RemoveTokens deletes the token file.

func TokenFilePath

func TokenFilePath() (string, error)

TokenFilePath returns the path to the token file (~/.docusign/tokens.json).

func WriteTokens

func WriteTokens(tokens *TokenData) error

WriteTokens writes the token data to the token file.

Types

type AuditEvent

type AuditEvent struct {
	EventFields []EventField `json:"event_fields"`
}

type AuditEventsResponse

type AuditEventsResponse struct {
	AuditEvents []AuditEvent `json:"audit_events"`
}

type Client

type Client struct {
	*api.Client
	// contains filtered or unexported fields
}

Client wraps the API client with DocuSign-specific methods.

func NewClient

func NewClient(baseURI, accountID, accessToken string) *Client

NewClient creates a new DocuSign API client from stored tokens and credentials.

func (*Client) CreateEnvelope

func (c *Client) CreateEnvelope(ctx context.Context, req CreateEnvelopeRequest) (*EnvelopeDetail, error)

func (*Client) CreateRecipientView

func (c *Client) CreateRecipientView(ctx context.Context, envelopeID string, req RecipientViewRequest) (*ViewURL, error)

func (*Client) DownloadDocument

func (c *Client) DownloadDocument(ctx context.Context, envelopeID, documentID string) ([]byte, error)

func (*Client) GetAuditEvents

func (c *Client) GetAuditEvents(ctx context.Context, envelopeID string) (*AuditEventsResponse, error)

func (*Client) GetEnvelope

func (c *Client) GetEnvelope(ctx context.Context, envelopeID string) (*EnvelopeDetail, error)

func (*Client) GetTemplate

func (c *Client) GetTemplate(ctx context.Context, templateID string) (*Template, error)

func (*Client) ListDocuments

func (c *Client) ListDocuments(ctx context.Context, envelopeID string) (*DocumentsListResponse, error)

func (*Client) ListEnvelopes

func (c *Client) ListEnvelopes(ctx context.Context, fromDate, status string, count int) (*EnvelopesListResponse, error)

func (*Client) ListRecipients

func (c *Client) ListRecipients(ctx context.Context, envelopeID string) (*RecipientsListResponse, error)

func (*Client) ListTemplates

func (c *Client) ListTemplates(ctx context.Context, search string, count int) (*TemplatesListResponse, error)

func (*Client) SendEnvelope

func (c *Client) SendEnvelope(ctx context.Context, envelopeID string) error

func (*Client) VoidEnvelope

func (c *Client) VoidEnvelope(ctx context.Context, envelopeID, reason string) error

type CreateEnvelopeRequest

type CreateEnvelopeRequest struct {
	EmailSubject string      `json:"email_subject"`
	EmailBlurb   string      `json:"email_blurb,omitempty"`
	Status       string      `json:"status"`
	Documents    []Document  `json:"documents"`
	Recipients   *Recipients `json:"recipients"`
}

type Document

type Document struct {
	DocumentBase64 string `json:"document_base64"`
	Name           string `json:"name"`
	FileExtension  string `json:"file_extension"`
	DocumentID     string `json:"document_id"`
}

type DocumentInfo

type DocumentInfo struct {
	DocumentID string `json:"document_id"`
	Name       string `json:"name"`
	Type       string `json:"type,omitempty"`
	URI        string `json:"uri,omitempty"`
	Order      string `json:"order,omitempty"`
	Pages      string `json:"pages,omitempty"`
}

type DocumentsListResponse

type DocumentsListResponse struct {
	EnvelopeID        string         `json:"envelope_id"`
	EnvelopeDocuments []DocumentInfo `json:"envelope_documents"`
}

type Envelope

type Envelope struct {
	EnvelopeID     string `json:"envelope_id"`
	Status         string `json:"status"`
	EmailSubject   string `json:"email_subject"`
	SentDateTime   string `json:"sent_date_time,omitempty"`
	StatusDateTime string `json:"status_changed_date_time,omitempty"`
	CreatedAt      string `json:"created_date_time,omitempty"`
}

type EnvelopeDetail

type EnvelopeDetail struct {
	EnvelopeID     string `json:"envelope_id"`
	Status         string `json:"status"`
	EmailSubject   string `json:"email_subject"`
	EmailBlurb     string `json:"email_blurb,omitempty"`
	SentDateTime   string `json:"sent_date_time,omitempty"`
	StatusDateTime string `json:"status_changed_date_time,omitempty"`
	CreatedAt      string `json:"created_date_time,omitempty"`
}

type EnvelopesListResponse

type EnvelopesListResponse struct {
	Envelopes     []Envelope `json:"envelopes"`
	ResultSetSize string     `json:"result_set_size"`
	TotalSetSize  string     `json:"total_set_size"`
	StartPosition string     `json:"start_position"`
	EndPosition   string     `json:"end_position"`
}

type EventField

type EventField struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type RecipientInfo

type RecipientInfo struct {
	RecipientID     string `json:"recipient_id"`
	RecipientIDGUID string `json:"recipient_id_guid,omitempty"`
	Name            string `json:"name"`
	Email           string `json:"email"`
	Status          string `json:"status,omitempty"`
	RoutingOrder    string `json:"routing_order,omitempty"`
	DeliveredAt     string `json:"delivered_date_time,omitempty"`
	SignedAt        string `json:"signed_date_time,omitempty"`
}

type RecipientViewRequest

type RecipientViewRequest struct {
	ReturnURL            string `json:"return_url"`
	AuthenticationMethod string `json:"authentication_method"`
	Email                string `json:"email"`
	UserName             string `json:"user_name"`
	ClientUserID         string `json:"client_user_id,omitempty"`
}

type Recipients

type Recipients struct {
	Signers []Signer `json:"signers"`
}

type RecipientsListResponse

type RecipientsListResponse struct {
	Signers         []RecipientInfo `json:"signers"`
	CarbonCopies    []RecipientInfo `json:"carbon_copies,omitempty"`
	CertifiedDelivs []RecipientInfo `json:"certified_deliveries,omitempty"`
}

type Signer

type Signer struct {
	Email        string `json:"email"`
	Name         string `json:"name"`
	RecipientID  string `json:"recipient_id"`
	RoutingOrder string `json:"routing_order,omitempty"`
	ClientUserID string `json:"client_user_id,omitempty"`
}

type Template

type Template struct {
	TemplateID   string `json:"template_id"`
	Name         string `json:"name"`
	Description  string `json:"description,omitempty"`
	Shared       string `json:"shared,omitempty"`
	Created      string `json:"created,omitempty"`
	LastModified string `json:"last_modified,omitempty"`
}

type TemplatesListResponse

type TemplatesListResponse struct {
	EnvelopeTemplates []Template `json:"envelope_templates"`
	ResultSetSize     string     `json:"result_set_size"`
	TotalSetSize      string     `json:"total_set_size"`
}

type TokenData

type TokenData struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int64  `json:"expires_in"`
	ExpiresAt    int64  `json:"expires_at"`
	TokenType    string `json:"token_type"`
}

TokenData represents the stored OAuth tokens.

func ReadTokens

func ReadTokens() (*TokenData, error)

ReadTokens reads the token data from the token file.

func (*TokenData) IsExpired

func (t *TokenData) IsExpired() bool

IsExpired returns true if the access token has expired or will expire within 5 minutes.

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int64  `json:"expires_in"`
	TokenType    string `json:"token_type"`
}

TokenResponse represents the OAuth token endpoint response.

func ExchangeCode

func ExchangeCode(ctx context.Context, integrationKey, secretKey, code string) (*TokenResponse, error)

ExchangeCode exchanges an authorization code for tokens.

func RefreshAccessToken

func RefreshAccessToken(ctx context.Context, integrationKey, secretKey, refreshToken string) (*TokenResponse, error)

RefreshAccessToken refreshes an expired access token using a refresh token.

type UserinfoAccount

type UserinfoAccount struct {
	AccountID   string `json:"account_id"`
	IsDefault   bool   `json:"is_default"`
	AccountName string `json:"account_name"`
	BaseURI     string `json:"base_uri"`
}

UserinfoAccount represents an account in the userinfo response.

func FindDefaultAccount

func FindDefaultAccount(info *UserinfoResponse) (*UserinfoAccount, error)

FindDefaultAccount finds the default account from userinfo response.

type UserinfoResponse

type UserinfoResponse struct {
	Sub      string            `json:"sub"`
	Accounts []UserinfoAccount `json:"accounts"`
}

UserinfoResponse represents the /oauth/userinfo response.

func GetUserinfo

func GetUserinfo(ctx context.Context, accessToken string) (*UserinfoResponse, error)

GetUserinfo calls the /oauth/userinfo endpoint.

type ViewURL

type ViewURL struct {
	URL string `json:"url"`
}

Jump to

Keyboard shortcuts

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