yousign

package module
v0.0.0-...-79d3513 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

Yousign API client written in Go

This library doesn't cover all the API, so contributions are welcome.

That said, the main parts are covered so you can create procedures, manage files, add server stamps... etc. You can check the test files to have an overview.

Usage
client := NewClient("YOUR-API-KEY")

// Add a file for this procedure
pdf, err := os.Open("mydocument.pdf")
if err != nil {
	t.Fatal(err)
}
defer pdf.Close()

file, resp, err := client.File.Create(&FileRequest{
	Name:    String("myFile"),
	Content: base64Encode(pdf),
})
if err != nil {
	fatal(t, err, resp)
}
fmt.Println("file created:", *file.ID)

// Create a procedure
p, resp, err := client.Procedure.Create(&ProcedureRequest{
	Name:        String("Procedure 1"),
	Description: String("My first procedure"),
	Start:       Bool(true),
	Members: []MemberRequest{
		{
			Firstname: String("John"),
			Lastname:  String("Doe"),
			Phone:     String("+33xxxxxxxxx"),
			Email:     String("jdoe@mail.com"),
			FileObjects: []FileObjectRequest{
				{
					Page:     Int(1),
					Position: String("164,61,263,123"),
					File:     file.ID,
				},
			},
		},
	},
})
if err != nil {
	fatal(t, err, resp)
}
fmt.Println("Procedure created and started:", *p.ID)

// Use this link to sign the document for a particular member of the
// procedure
fmt.Println("Sign URL:", client.SignURL(*p.Members[0].ID))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

func Int

func Int(v int) *int

func String

func String(v string) *string

Types

type Client

type Client struct {
	User        *UserService
	UserGroup   *UserGroupService
	Member      *MemberService
	File        *FileService
	FileObject  *FileObjectService
	Procedure   *ProceduresService
	ServerStamp *ServerStampService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiKey string) *Client

NewClient returns a new YouSign API client. You must provide a valid apiKey retrieved from your YouSign account.

func NewClientStaging

func NewClientStaging(apiKey string) *Client

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do performs the request, the json received in the response is decoded and stored in the value pointed by v. Do can be used to perform the request created with NewRequest, which should be used only for API requests not implemented in this library.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, opt interface{}, body interface{}) (*http.Request, error)

NewRequest creates an API request. This method can be used to performs API request not implemented in this library. Otherwise it should not be be used directly. Relative URLs should always be specified without a preceding slash.

func (*Client) SignURL

func (c *Client) SignURL(memberID string) string

type File

type File struct {
	ID          *string         `json:"id,omitempty"`
	Name        *string         `json:"name,omitempty"`
	Type        *string         `json:"type,omitempty"`
	ContentType *string         `json:"contentType,omitempty"`
	Description *string         `json:"description,omitempty"`
	CreatedAt   *time.Time      `json:"createdAt,omitempty"`
	UpdatedAt   *time.Time      `json:"updatedAt,omitempty"`
	Metadata    json.RawMessage `json:"metadata,omitempty"`
	Company     *string         `json:"company,omitempty"`
	Creator     *string         `json:"creator,omitempty"`
}

type FileObject

type FileObject struct {
	ID               *string    `json:"id,omitempty"`
	File             *string    `json:"file,omitempty"`
	Member           *Member    `json:"member,omitempty"`
	Page             *int       `json:"page,omitempty"`
	Position         *string    `json:"position,omitempty"`
	FieldName        *string    `json:"fieldName,omitempty"`
	Mention          *string    `json:"mention,omitempty"`
	Mention2Internal *string    `json:"mention2 (internal),omitempty"`
	CreatedAt        *time.Time `json:"createdAt,omitempty"`
	UpdatedAt        *time.Time `json:"updatedAt,omitempty"`
	ExecutedAt       *time.Time `json:"executedAt,omitempty"`
}

type FileObjectRequest

type FileObjectRequest struct {
	File      *string `json:"file,omitempty"`
	Page      *int    `json:"page,omitempty"`
	Position  *string `json:"position,omitempty"`
	FieldName *string `json:"fieldName,omitempty"`
	Mention   *string `json:"mention,omitempty"`
	Mention2  *string `json:"mention2,omitempty"`
	Member    *string `json:"member,omitempty"`
}

type FileObjectService

type FileObjectService struct {
	// contains filtered or unexported fields
}

func (*FileObjectService) Create

func (*FileObjectService) Get

type FileRequest

type FileRequest struct {
	Name        *string           `json:"name,omitempty"`
	Type        *string           `json:"type,omitempty"`
	Password    *string           `json:"password,omitempty"`
	Description *string           `json:"description,omitempty"`
	Metadata    map[string]string `json:"metadata,omitempty"`
	Content     *string           `json:"content,omitempty"`
	Procedure   *string           `json:"procedure,omitempty"`
}

type FileService

type FileService struct {
	// contains filtered or unexported fields
}

func (*FileService) Create

func (s *FileService) Create(r *FileRequest) (*File, *http.Response, error)

func (*FileService) Download

func (s *FileService) Download(id string) (*string, *http.Response, error)

func (*FileService) Get

func (s *FileService) Get(id string) (*File, *http.Response, error)

type Member

type Member struct {
	ID                   *string               `json:"id,omitempty"`
	User                 *string               `json:"user,omitempty"`
	Type                 *string               `json:"type,omitempty"`
	Firstname            *string               `json:"firstname,omitempty"`
	Lastname             *string               `json:"lastname,omitempty"`
	Email                *string               `json:"email,omitempty"`
	Phone                *string               `json:"phone,omitempty"`
	Position             *int                  `json:"position,omitempty"`
	CreatedAt            *time.Time            `json:"createdAt,omitempty"`
	UpdatedAt            *time.Time            `json:"updatedAt,omitempty"`
	Status               *string               `json:"status,omitempty"`
	FileObjects          []MemberFileObject    `json:"fileObjects,omitempty"`
	Comment              *string               `json:"comment,omitempty"`
	Procedure            *string               `json:"procedure,omitempty"`
	OperationLevel       *string               `json:"operationLevel,omitempty"`
	OperationCustomModes []string              `json:"operationCustomModes,omitempty"`
	ModeSmsConfiguration *ModeSmsConfiguration `json:"modeSmsConfiguration,omitempty"`
}

type MemberFileObject

type MemberFileObject struct {
	ID               *string    `json:"id,omitempty"`
	File             *File      `json:"file,omitempty"`
	Page             *int       `json:"page,omitempty"`
	Position         *string    `json:"position,omitempty"`
	FieldName        *string    `json:"fieldName,omitempty"`
	Mention          *string    `json:"mention,omitempty"`
	Mention2Internal *string    `json:"mention2 (internal),omitempty"`
	CreatedAt        *time.Time `json:"createdAt,omitempty"`
	UpdatedAt        *time.Time `json:"updatedAt,omitempty"`
	ExecutedAt       *time.Time `json:"executedAt,omitempty"`
}

type MemberRequest

type MemberRequest struct {
	User                 *string               `json:"user,omitempty"`
	Type                 *string               `json:"type,omitempty"`
	Firstname            *string               `json:"firstname,omitempty"`
	Lastname             *string               `json:"lastname,omitempty"`
	Email                *string               `json:"email,omitempty"`
	Phone                *string               `json:"phone,omitempty"`
	Position             *int                  `json:"position,omitempty"`
	FileObjects          []FileObjectRequest   `json:"fileObjects,omitempty"`
	Procedure            *string               `json:"procedure,omitempty"`
	OperationLevel       *string               `json:"operationLevel,omitempty"`
	OperationCustomModes []string              `json:"operationCustomModes,omitempty"`
	ModeSmsConfiguration *ModeSmsConfiguration `json:"modeSmsConfiguration,omitempty"`
}

type MemberService

type MemberService struct {
	// contains filtered or unexported fields
}

func (*MemberService) Create

func (s *MemberService) Create(r *MemberRequest) (*Member, *http.Response, error)

func (*MemberService) Get

func (s *MemberService) Get(id string) (*Member, *http.Response, error)

type ModeSmsConfiguration

type ModeSmsConfiguration struct {
	Content string `json:"content,omitempty"`
}

type Msg

type Msg struct {
	To       []string `json:"to,omitempty"`
	Subject  *string  `json:"subject,omitempty"`
	Message  *string  `json:"message,omitempty"`
	FromName *string  `json:"fromName,omitempty"`
}

type Procedure

type Procedure struct {
	ID                 *string         `json:"id,omitempty"`
	Name               *string         `json:"name,omitempty"`
	Description        *string         `json:"description,omitempty"`
	CreatedAt          *time.Time      `json:"createdAt,omitempty"`
	UpdatedAt          *time.Time      `json:"updatedAt,omitempty"`
	ExpiresAt          *time.Time      `json:"expiresAt,omitempty"`
	Status             *string         `json:"status,omitempty"`
	Creator            *string         `json:"creator,omitempty"`
	CreatorFirstName   *string         `json:"creatorFirstName,omitempty"`
	CreatorLastName    *string         `json:"creatorLastName,omitempty"`
	Company            *string         `json:"company,omitempty"`
	Template           *bool           `json:"template,omitempty"`
	Ordered            *bool           `json:"ordered,omitempty"`
	Parent             *string         `json:"parent,omitempty"`
	Metadata           json.RawMessage `json:"metadata,omitempty"`
	Config             json.RawMessage `json:"config,omitempty"`
	Members            []Member        `json:"members,omitempty"`
	Files              []File          `json:"files,omitempty"`
	RelatedFilesEnable *bool           `json:"relatedFilesEnable,omitempty"`
	Archive            *bool           `json:"archive,omitempty"`
}

type ProcedureConfig

type ProcedureConfig struct {
	Email     ProcedureConfigEmail      `json:"email,omitempty"`
	Reminders []ProcedureConfigReminder `json:"reminders,omitempty"`
	Webhook   ProcedureConfigWebhook    `json:"webhook,omitempty"`
}

type ProcedureConfigEmail

type ProcedureConfigEmail struct {
	ProcedureStarted  []Msg `json:"procedure.started,omitempty"`
	ProcedureFinished []Msg `json:"procedure.finished,omitempty"`
	ProcedureRefused  []Msg `json:"procedure.refused,omitempty"`
	ProcedureExpired  []Msg `json:"procedure.expired,omitempty"`
	ProcedureDeleted  []Msg `json:"procedure.deleted,omitempty"`
	MemberStarted     []Msg `json:"member.started,omitempty"`
	MemberFinished    []Msg `json:"member.finished,omitempty"`
	CommentCreated    []Msg `json:"comment.created,omitempty"`
}

type ProcedureConfigReminder

type ProcedureConfigReminder struct {
	Interval *int           `json:"interval,omitempty"`
	Limit    *int           `json:"limit,omitempty"`
	Config   ReminderConfig `json:"config,omitempty"`
}

type ProcedureConfigWebhook

type ProcedureConfigWebhook struct {
	ProcedureStarted  []Webhook `json:"procedure.started,omitempty"`
	ProcedureFinished []Webhook `json:"procedure.finished,omitempty"`
	ProcedureRefused  []Webhook `json:"procedure.refused,omitempty"`
	ProcedureExpired  []Webhook `json:"procedure.expired,omitempty"`
	ProcedureDeleted  []Webhook `json:"procedure.deleted,omitempty"`
	MemberStarted     []Webhook `json:"member.started,omitempty"`
	MemberFinished    []Webhook `json:"member.finished,omitempty"`
	CommentCreated    []Webhook `json:"comment.created,omitempty"`
}

type ProcedureRequest

type ProcedureRequest struct {
	Name               *string           `json:"name,omitempty"`
	Description        *string           `json:"description,omitempty"`
	ExpiresAt          *string           `json:"expiresAt,omitempty"`
	Template           *bool             `json:"template,omitempty"`
	Ordered            *bool             `json:"ordered,omitempty"`
	Metadata           map[string]string `json:"metadata,omitempty"`
	Config             *ProcedureConfig  `json:"config,omitempty"`
	Members            []MemberRequest   `json:"members,omitempty"`
	Start              *bool             `json:"start,omitempty"`
	RelatedFilesEnable *bool             `json:"relatedFilesEnable,omitempty"`
	Archive            *bool             `json:"archive,omitempty"`
}

type ProceduresService

type ProceduresService struct {
	// contains filtered or unexported fields
}

func (*ProceduresService) Create

func (*ProceduresService) Get

func (*ProceduresService) Update

type ReminderConfig

type ReminderConfig struct {
	Email ReminderConfigEmail `json:"email,omitempty"`
}

type ReminderConfigEmail

type ReminderConfigEmail struct {
	ReminderExecuted []Msg `json:"reminder.executed,omitempty"`
}

type ServerStamp

type ServerStamp struct {
	ID          *string         `json:"id,omitempty"`
	File        *string         `json:"file,omitempty"`
	Certificate *string         `json:"certificate,omitempty"`
	FileObjects []FileObject    `json:"fileObjects,omitempty"`
	Config      json.RawMessage `json:"config,omitempty"`
	CreatedAt   *time.Time      `json:"createdAt,omitempty"`
	UpdatedAt   *time.Time      `json:"updatedAt,omitempty"`
	FinishedAt  *time.Time      `json:"finishedAt,omitempty"`
	Status      *string         `json:"status,omitempty"`
	Company     *string         `json:"company,omitempty"`
}

type ServerStampConfig

type ServerStampConfig struct {
	Webhook struct {
		ServerStampFinished []Webhook `json:"server_stamp.finished,omitempty"`
	}
}

type ServerStampRequest

type ServerStampRequest struct {
	File        *string             `json:"file,omitempty"`
	Certificate *string             `json:"certificate,omitempty"`
	Config      *ServerStampConfig  `json:"config,omitempty"`
	FileObjects []FileObjectRequest `json:"fileObjects,omitempty"`
	SignImage   *string             `json:"signImage,omitempty"`
}

type ServerStampService

type ServerStampService struct {
	// contains filtered or unexported fields
}

func (*ServerStampService) Create

func (*ServerStampService) Get

type User

type User struct {
	ID               *string     `json:"id,omitempty"`
	Firstname        *string     `json:"firstname,omitempty"`
	Lastname         *string     `json:"lastname,omitempty"`
	FullName         *string     `json:"fullName,omitempty"`
	Title            *string     `json:"title,omitempty"`
	Email            *string     `json:"email,omitempty"`
	Phone            *string     `json:"phone,omitempty"`
	Status           *string     `json:"status,omitempty"`
	Company          *string     `json:"company,omitempty"`
	CreatedAt        *time.Time  `json:"createdAt,omitempty"`
	UpdatedAt        *time.Time  `json:"updatedAt,omitempty"`
	Config           interface{} `json:"config,omitempty"`
	SamlNameID       *string     `json:"samlNameId,omitempty"`
	DefaultSignImage *string     `json:"defaultSignImage,omitempty"`
	FastSign         *bool       `json:"fastSign,omitempty"`
	Group            *UserGroup  `json:"group,omitempty"`
	Notifications    interface{} `json:"notifications,omitempty"`
	Deleted          *bool       `json:"deleted,omitempty"`
	DeletedAt        *time.Time  `json:"deletedAt,omitempty"`
}

type UserGroup

type UserGroup struct {
	ID          *string  `json:"id"`
	Name        *string  `json:"name"`
	Permissions []string `json:"permissions"`
}

type UserGroupService

type UserGroupService struct {
	// contains filtered or unexported fields
}

type UserRequest

type UserRequest struct {
	Firstname        *string     `json:"firstname,omitempty"`
	Lastname         *string     `json:"lastname,omitempty"`
	Title            *string     `json:"title,omitempty"`
	Phone            *string     `json:"phone,omitempty"`
	Company          *string     `json:"company,omitempty"`
	Config           interface{} `json:"config,omitempty"`
	Group            *string     `json:"group,omitempty"`
	DefaultSignImage *string     `json:"defaultSignImage,omitempty"`
	Notifications    *string     `json:"notifications,omitempty"`
}

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func (*UserService) All

func (s *UserService) All() ([]User, *http.Response, error)

type Webhook

type Webhook struct {
	URL     *string        `json:"url,omitempty"`
	Method  *string        `json:"method,omitempty"`
	Headers *WebhookHeader `json:"headers,omitempty"`
}

type WebhookHeader

type WebhookHeader struct {
	XYousignCustomHeader string `json:"X-Yousign-Custom-Header,omitempty"`
}

Jump to

Keyboard shortcuts

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