-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstructs.go
More file actions
382 lines (326 loc) · 13.4 KB
/
Copy pathstructs.go
File metadata and controls
382 lines (326 loc) · 13.4 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
package planfix
import (
"encoding/xml"
)
// XMLRequester - любая структура запроса
type XMLRequester interface {
SetSid(sid string)
SetAccount(account string)
GetMethod() string
}
// XMLRequestAuth - запрос авторизации
type XMLRequestAuth struct {
XMLName xml.Name `xml:"request"`
Method string `xml:"method,attr"`
Account string `xml:"account"`
Sid string `xml:"sid"`
}
// SetSid задает sid
func (a *XMLRequestAuth) SetSid(sid string) {
a.Sid = sid
}
// SetAccount задает account
func (a *XMLRequestAuth) SetAccount(account string) {
a.Account = account
}
// GetMethod возвращает метод API (название)
func (a *XMLRequestAuth) GetMethod() string {
return a.Method
}
// XMLResponseStatus - любой ответ, подразумевает статус ответа и код ошибки в случае ошибки
type XMLResponseStatus struct {
XMLName xml.Name `xml:"response"`
Status string `xml:"status,attr"`
Code string `xml:"code"`
Message string `xml:"message"`
}
// XMLResponseFile - файл в ответе analitic.get
type XMLResponseFile struct {
ID int `xml:"id"`
Name string `xml:"name"`
}
// XMLResponseActionUser - юзер в ответе analitic.get
type XMLResponseActionUser struct {
ID int `xml:"id,omitempty"`
Name string `xml:"name,omitempty"`
}
// XMLResponseActionAnalitic - аналитика в ответе analitic.get
type XMLResponseActionAnalitic struct {
ID int `xml:"id"`
Key int `xml:"key"`
Name string `xml:"name"`
}
// XMLResponseAnaliticOptions - аналитика в ответе analitic.getOptions
type XMLResponseAnaliticOptions struct {
ID int `xml:"id"`
Name string `xml:"name"`
GroupID int `xml:"group>id"`
Fields []XMLResponseAnaliticOptionsField `xml:"fields>field"`
}
// XMLResponseAnaliticOptionsField - поле аналитики в ответе analitic.getOptions
type XMLResponseAnaliticOptionsField struct {
ID int `xml:"id"`
Num int `xml:"num"`
Name string `xml:"name"`
Type string `xml:"type"`
ListValues []string `xml:"list>value"`
HandbookID int `xml:"handbook>id"`
}
// XMLResponseAnaliticHandbookRecord - запись справочника в ответе analitic.getHandbook
type XMLResponseAnaliticHandbookRecord struct {
Key int `xml:"key"`
ParentKey int `xml:"parentKey"`
IsGroup int `xml:"isGroup"`
Values []XMLResponseAnaliticHandbookRecordValues `xml:"value"`
ValuesMap map[string]string
}
// XMLResponseAnaliticHandbookRecordValues - значения полей в записи справочника в ответе analitic.getHandbook
type XMLResponseAnaliticHandbookRecordValues struct {
Name string `xml:"name,attr"`
Value string `xml:"value,attr"`
IsDisplayed int `xml:"isDisplayed,attr"`
}
// XMLResponseAction - действие в ответе action.getList
type XMLResponseAction struct {
ID int `xml:"id"`
Description string `xml:"description"`
OldStatus int `xml:"statusChange>oldStatus,omitempty"`
NewStatus int `xml:"statusChange>newStatus,omitempty"`
IsNotRead bool `xml:"isNotRead"`
FromEmail bool `xml:"fromEmail"`
DateTime string `xml:"dateTime"`
TaskID int `xml:"task>id"`
TaskTitle string `xml:"task>title"`
ContactGeneral int `xml:"contact>general"`
ContactName string `xml:"contact>name"`
Owner XMLResponseActionUser `xml:"owner"`
ProjectID int `xml:"project>id"`
ProjectTitle string `xml:"project>title"`
TaskExpectDateChangedOldDate string `xml:"taskExpectDateChanged>oldDate"`
TaskExpectDateChangedNewDate string `xml:"taskExpectDateChanged>newDate"`
TaskStartTimeChangedOldDate string `xml:"taskStartTimeChanged>oldDate"`
TaskStartTimeChangedNewDate string `xml:"taskStartTimeChanged>newDate"`
Files []XMLResponseFile `xml:"files>file"`
NotifiedList []XMLResponseActionUser `xml:"notifiedList>user"`
Analitics []XMLResponseActionAnalitic `xml:"analitics>analitic"`
}
// XMLResponseTask - задача в ответе task.get
// TODO: добавить все поля из https://planfix.ru/docs/ПланФикс_API_task.get
type XMLResponseTask struct {
ID int `xml:"id"`
Title string `xml:"title"`
Description string `xml:"description"`
General int `xml:"general"`
ProjectID int `xml:"project>id"`
ProjectTitle string `xml:"project>title"`
OwnerId int `xml:"owner>id"`
ParentId int `xml:"parent>id"`
TemplateId int `xml:"template>id"`
WorkersUsers UsersList `xml:"workers>users,omitempty"`
WorkersGroups GroupsList `xml:"workers>groups,omitempty"`
MembersUsers UsersList `xml:"members>users,omitempty"`
MembersGroups GroupsList `xml:"members>groups,omitempty"`
AuditorsUsers UsersList `xml:"auditors>users,omitempty"`
AuditorsGroups GroupsList `xml:"auditors>groups,omitempty"`
CustomValues []TaskCustomValue `xml:"customData>customValue,omitempty"`
}
type TaskCustomValue struct {
Field IdName `xml:"field"`
Value interface{} `xml:"value,omitempty"`
Text string `xml:"text"`
}
type UsersList struct {
Users []IdName `xml:"user"`
}
type GroupsList struct {
Groups []IdName `xml:"group"`
}
type IdName struct {
ID int `xml:"id"`
Name string `xml:"name,omitempty"`
}
// XMLResponseAnalitic - аналитика в ответе analitic.getList
type XMLResponseAnalitic struct {
ID int `xml:"id"`
Name string `xml:"name"`
GroupID int `xml:"group>id"`
GroupName string `xml:"group>name"`
}
// XMLRequestActionAnalitic - аналитика в запросе на добавление действия analitic.add
type XMLRequestActionAnalitic struct {
ID int `xml:"id"`
ItemData []XMLRequestAnaliticField `xml:"analiticData>itemData"`
}
// XMLRequestAnaliticField - поле аналитики в запросе на добавление действия analitic.add
type XMLRequestAnaliticField struct {
FieldID int `xml:"fieldId"`
Value interface{} `xml:"value"`
}
// XMLRequestAnaliticTimePeriodValue - поле аналитики с типом `TIMEPERIOD` в запросе на добавление действия analitic.add
type XMLRequestAnaliticTimePeriodValue struct {
Begin string `xml:"begin"`
End string `xml:"end"`
}
// XMLResponseUser - юзер в ответе user.get, user.getList
// TODO: добавить все поля из https://planfix.ru/docs/ПланФикс_API_user.get
type XMLResponseUser struct {
ID int `xml:"id"`
Name string `xml:"name"`
LastName string `xml:"lastName"`
Login string `xml:"login"`
Email string `xml:"email"`
}
// XMLRequestAuthLogin - запрос auth.login
type XMLRequestAuthLogin struct {
XMLName xml.Name `xml:"request"`
Method string `xml:"method,attr"`
Account string `xml:"account"`
Login string `xml:"login"`
Password string `xml:"password"`
}
// - SetSid - заглушка, чтобы реализовать интерфейс
func (a *XMLRequestAuthLogin) SetSid(sid string) {}
// SetAccount задает account
func (a *XMLRequestAuthLogin) SetAccount(account string) {
a.Account = account
}
// GetMethod возвращает метод API (название)
func (a *XMLRequestAuthLogin) GetMethod() string {
return a.Method
}
// XMLResponseAuth - ответ auth.login
type XMLResponseAuth struct {
XMLName xml.Name `xml:"response"`
Sid string `xml:"sid"`
}
// XMLRequestActionGet - запрос action.get
type XMLRequestActionGet struct {
XMLRequestAuth
XMLName xml.Name `xml:"request"`
ActionID int `xml:"action>id"`
}
// XMLResponseActionGet - ответ action.get
type XMLResponseActionGet struct {
XMLName xml.Name `xml:"response"`
Action XMLResponseAction `xml:"action"`
}
// XMLRequestActionGetList - запрос action.getList
type XMLRequestActionGetList struct {
XMLRequestAuth
XMLName xml.Name `xml:"request"`
TaskID int `xml:"task>id,omitempty"`
TaskGeneral int `xml:"task>general,omitempty"`
ContactGeneral int `xml:"contact>general,omitempty"`
PageCurrent int `xml:"pageCurrent"`
PageSize int `xml:"pageSize"`
Sort string `xml:"sort"`
}
// XMLResponseActionGetList - ответ action.getList
type XMLResponseActionGetList struct {
XMLName xml.Name `xml:"response"`
Actions struct {
ActionsCount int `xml:"count,attr"`
ActionsTotalCount int `xml:"totalCount,attr"`
Actions []XMLResponseAction `xml:"action"`
} `xml:"actions"`
}
// XMLRequestActionAdd - запрос action.add
type XMLRequestActionAdd struct {
XMLRequestAuth
XMLName xml.Name `xml:"request"`
Description string `xml:"action>description"`
TaskID int `xml:"action>task>id,omitempty"`
TaskGeneral int `xml:"action>task>general,omitempty"`
ContactGeneral int `xml:"action>contact>general,omitempty"`
TaskNewStatus int `xml:"action>taskNewStatus,omitempty"`
NotifiedList []XMLResponseUser `xml:"action>notifiedList>user,omitempty"`
IsHidden int `xml:"action>isHidden"`
Owner XMLResponseUser `xml:"action>owner,omitempty"`
DateTime string `xml:"action>dateTime,omitempty"`
Analitics []XMLRequestActionAnalitic `xml:"action>analitics>analitic,omitempty"`
}
// XMLResponseActionAdd - ответ action.add
type XMLResponseActionAdd struct {
XMLName xml.Name `xml:"response"`
ActionID int `xml:"action>id"`
}
// XMLRequestAnaliticGetList - запрос analitic.getList
type XMLRequestAnaliticGetList struct {
XMLRequestAuth
XMLName xml.Name `xml:"request"`
AnaliticGroupID int `xml:"analiticGroupId,omitempty"`
}
// XMLResponseAnaliticGetList - ответ analitic.getList
type XMLResponseAnaliticGetList struct {
XMLName xml.Name `xml:"response"`
Analitics struct {
AnaliticsCount int `xml:"count,attr"`
AnaliticsTotalCount int `xml:"totalCount,attr"`
Analitics []XMLResponseAnalitic `xml:"analitic"`
} `xml:"analitics"`
}
// XMLRequestAnaliticGetOptions - запрос analitic.getOptions
type XMLRequestAnaliticGetOptions struct {
XMLRequestAuth
XMLName xml.Name `xml:"request"`
AnaliticID int `xml:"analitic>id"`
}
// XMLResponseAnaliticGetOptions - ответ analitic.getOptions
type XMLResponseAnaliticGetOptions struct {
XMLName xml.Name `xml:"response"`
Analitic XMLResponseAnaliticOptions `xml:"analitic"`
}
// XMLRequestAnaliticGetHandbook - запрос analitic.getHandbook
type XMLRequestAnaliticGetHandbook struct {
XMLRequestAuth
XMLName xml.Name `xml:"request"`
HandbookID int `xml:"handbook>id"`
}
// XMLResponseAnaliticGetHandbook - ответ analitic.getHandbook
type XMLResponseAnaliticGetHandbook struct {
XMLName xml.Name `xml:"response"`
Records []XMLResponseAnaliticHandbookRecord `xml:"records>record"`
}
// XMLRequestTaskGet - запрос task.get
type XMLRequestTaskGet struct {
XMLRequestAuth
XMLName xml.Name `xml:"request"`
TaskID int `xml:"task>id,omitempty"`
TaskGeneral int `xml:"task>general,omitempty"`
}
// XMLResponseTaskGet - ответ task.get response
type XMLResponseTaskGet struct {
XMLName xml.Name `xml:"response"`
Task XMLResponseTask `xml:"task"`
}
// XMLRequestUserGet - запрос user.get
type XMLRequestUserGet struct {
XMLRequestAuth
XMLName xml.Name `xml:"request"`
UserID int `xml:"user>id,omitempty"`
}
// XMLResponseUserGet - ответ user.get
type XMLResponseUserGet struct {
XMLName xml.Name `xml:"response"`
User XMLResponseUser `xml:"user"`
}
// XMLRequestUserGetList - запрос user.getList
type XMLRequestUserGetList struct {
XMLRequestAuth
XMLName xml.Name `xml:"request"`
Status string `xml:"status,omitempty"`
OnlyOnline int `xml:"onlyOnline,omitempty"`
UserGroupID int `xml:"userGoup>id,omitempty"`
SortType string `xml:"sortType,omitempty"`
PageCurrent int `xml:"pageCurrent,omitempty"`
PageSize int `xml:"pageSize,omitempty"`
}
// XMLResponseUserGetList - ответ user.getList
type XMLResponseUserGetList struct {
XMLName xml.Name `xml:"response"`
Users struct {
UsersCount int `xml:"count,attr"`
UsersTotalCount int `xml:"totalCount,attr"`
Users []XMLResponseUser `xml:"user"`
} `xml:"users"`
}