-
Notifications
You must be signed in to change notification settings - Fork 3
/
procedures.go
140 lines (121 loc) · 5.05 KB
/
procedures.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package yousign
import (
"encoding/json"
"net/http"
"time"
)
type ProceduresService struct {
client *Client
}
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 struct {
Email ProcedureConfigEmail `json:"email,omitempty"`
Reminders []ProcedureConfigReminder `json:"reminders,omitempty"`
Webhook ProcedureConfigWebhook `json:"webhook,omitempty"`
}
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 struct {
Interval *int `json:"interval,omitempty"`
Limit *int `json:"limit,omitempty"`
Config ReminderConfig `json:"config,omitempty"`
}
type ReminderConfig struct {
Email ReminderConfigEmail `json:"email,omitempty"`
}
type ReminderConfigEmail struct {
ReminderExecuted []Msg `json:"reminder.executed,omitempty"`
}
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 Msg struct {
To []string `json:"to,omitempty"`
Subject *string `json:"subject,omitempty"`
Message *string `json:"message,omitempty"`
FromName *string `json:"fromName,omitempty"`
}
type Webhook struct {
URL *string `json:"url,omitempty"`
Method *string `json:"method,omitempty"`
Headers *WebhookHeader `json:"headers,omitempty"`
}
type WebhookHeader struct {
XYousignCustomHeader string `json:"X-Yousign-Custom-Header,omitempty"`
}
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"`
}
func (s *ProceduresService) Create(r *ProcedureRequest) (*Procedure, *http.Response, error) {
req, err := s.client.NewRequest("POST", "procedures", nil, r)
if err != nil {
return nil, nil, err
}
var v Procedure
resp, err := s.client.Do(req, &v)
return &v, resp, err
}
func (s *ProceduresService) Get(id string) (*Procedure, *http.Response, error) {
req, err := s.client.NewRequest("GET", id, nil, nil)
if err != nil {
return nil, nil, err
}
var v Procedure
resp, err := s.client.Do(req, &v)
return &v, resp, err
}
func (s *ProceduresService) Update(id string, r *ProcedureRequest) (*Procedure, *http.Response, error) {
req, err := s.client.NewRequest("PUT", id, nil, r)
if err != nil {
return nil, nil, err
}
var v Procedure
resp, err := s.client.Do(req, &v)
return &v, resp, err
}