-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtypes.go
175 lines (155 loc) · 6.8 KB
/
types.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package activiti
import (
"encoding/json"
"fmt"
"io"
"net/http"
"time"
)
type TaskAction string
const (
TASK_ACTION_COMPLETE TaskAction = "complete"
TASK_ACTION_CLAIM TaskAction = "claim"
TASK_ACTION_DELEGATE TaskAction = "delegate"
TASK_ACTION_RESOLVE TaskAction = "resolve"
)
type (
// JSONTime overrides MarshalJson method to format in ISO8601
JSONTime time.Time
// Client represents a Activiti 6.x REST API Client
ActClient struct {
Client *http.Client
Username string
Password string
BaseURL string
Log io.Writer // If user set log file name all requests will be logged there
}
expirationTime int64
// ErrorResponse https://www.activiti.org/userguide/#_error_response_body
ActErrorResponse struct {
Response *http.Response `json:"-"`
statusCode string `json:"statusCode"`
errorMessage string `json:"errorMessage"`
}
ActProcessDefinition struct {
ID string `json:"id,omitempty"`
URL string `json:"url,omitempty"`
Version int `json:"version,omitempty"`
Key string `json:"key,omitempty"`
Category string `json:"category,omitempty"`
Suspended bool `json:"suspended,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
DeploymentId string `json:"deploymentId,omitempty"`
DeploymentUrl string `json:"deploymentUrl,omitempty"`
GraphicalNotationDefined bool `json:"graphicalNotationDefined,omitempty"`
Resource string `json:"resource,omitempty"`
DiagramResource string `json:"diagramResource,omitempty"`
StartFormDefined bool `json:"startFormDefined,omitempty"`
}
ActProcessDefinitions struct {
ProcessDefinitions []ActProcessDefinition `json:"data,omitempty"`
Total int `json:"total,omitempty"`
Start int `json:"start,omitempty"`
Sort string `json:"sort,omitempty"`
Order string `json:"order,omitempty"`
Size int `json:"size,omitempty"`
}
ActProcessInstance struct {
ID string `json:"id,omitempty"`
URL string `json:"url,omitempty"`
BusinessKey string `json:"businessKey,omitempty"`
Suspended bool `json:"suspended,omitempty"`
ProcessDefinitionUrl string `json:"processDefinitionUrl,omitempty"`
ActivityId string `json:"activityId,omitempty"`
TenantId string `json:"tenantId,omitempty"`
}
ActProcessInstances struct {
ProcessInstances []ActProcessInstance `json:"data,omitempty"`
Total int `json:"total,omitempty"`
Start int `json:"start,omitempty"`
Sort string `json:"sort,omitempty"`
Order string `json:"order,omitempty"`
Size int `json:"size,omitempty"`
}
ActStartProcessInstance struct {
ProcessDefinitionId string `json:"processDefinitionId,omitempty"`
ProcessDefinitionKey string `json:"processDefinitionKey,omitempty"`
Message string `json:"message,omitempty"`
BusinessKey string `json:"businessKey,omitempty"`
TenantId string `json:"tenantId,omitempty"`
Variables []ActVariable `json:"variables,omitempty"`
}
ActTask struct {
Assignee string `json:"assignee,omitempty"`
CreateTime string `json:"createTime,omitempty"`
DelegationState string `json:"delegationState,omitempty"`
Description string `json:"description,omitempty"`
DueDate string `json:"dueDate,omitempty"`
Execution string `json:"execution,omitempty"`
Dd string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Owner string `json:"owner,omitempty"`
ParentTask string `json:"parentTask,omitempty"`
Priority int `json:"priority,omitempty"`
ProcessDefinition string `json:"processDefinition,omitempty"`
ProcessInstance string `json:"processInstance,omitempty"`
Suspended bool `json:"suspended,omitempty"`
TaskDefinitionKey string `json:"taskDefinitionKey,omitempty"`
Url string `json:"url,omitempty"`
TenantId string `json:"tenantId,omitempty"`
}
ActTasks struct {
Tasks []ActTask `json:"data,omitempty"`
Total int `json:"total,omitempty"`
Start int `json:"start,omitempty"`
Sort string `json:"sort,omitempty"`
Order string `json:"order,omitempty"`
Size int `json:"size,omitempty"`
}
ActUser struct {
ID string `json:"id,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Email string `json:"email,omitempty"`
URL string `json:"url,omitempty"`
PictureURL string `json:"pictureUrl,omitempty"`
Password string `json:"password,omitempty"`
}
ActUsers struct {
Users []ActUser `json:"data,omitempty"`
Total int `json:"total,omitempty"`
Start int `json:"start,omitempty"`
Sort string `json:"sort,omitempty"`
Order string `json:"order,omitempty"`
Size int `json:"size,omitempty"`
}
ActVariable struct {
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
Operation string `json:"operation,omitempty"`
Type string `json:"type,omitempty"`
}
)
// Error method implementation for ErrorResponse struct
func (r *ActErrorResponse) Error() string {
return fmt.Sprintf("%v %v: %d %s", r.Response.Request.Method, r.Response.Request.URL, r.Response.StatusCode, r.errorMessage)
}
// MarshalJSON for JSONTime
func (t JSONTime) MarshalJSON() ([]byte, error) {
stamp := fmt.Sprintf(`"%s"`, time.Time(t).UTC().Format(time.RFC3339))
return []byte(stamp), nil
}
func (e *expirationTime) UnmarshalJSON(b []byte) error {
var n json.Number
err := json.Unmarshal(b, &n)
if err != nil {
return err
}
i, err := n.Int64()
if err != nil {
return err
}
*e = expirationTime(i)
return nil
}