-
Notifications
You must be signed in to change notification settings - Fork 4
/
audit.go
117 lines (102 loc) · 5.42 KB
/
audit.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
package moysklad
import (
"github.com/google/uuid"
)
// Audit Контексты Аудита.
// Ключевое слово: audit
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/audit/#audit-audit-kontexty
type Audit struct {
Events MetaWrapper `json:"events"`
Meta Meta `json:"meta"`
Moment Timestamp `json:"moment"`
EntityType string `json:"entityType"`
EventType AuditEventType `json:"eventType"`
Info AuditContextInfo `json:"info"`
ObjectType string `json:"objectType"`
Source string `json:"source"`
UID string `json:"uid"`
ObjectCount int `json:"objectCount"`
ID uuid.UUID `json:"id"`
SupportAccess bool `json:"supportAccess"`
}
func (a Audit) String() string {
return Stringify(a)
}
func (a Audit) MetaType() MetaType {
return MetaTypeAudit
}
type AuditContextInfo struct {
AdditionalInfo string `json:"additionalInfo"`
}
// AuditEvent Событие аудита.
// Ключевое слово: auditevent
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/audit/#audit-audit-sobytiq
type AuditEvent struct {
Entity MetaWrapper `json:"entity"`
Audit MetaWrapper `json:"audit"`
Moment Timestamp `json:"moment"`
Diff any `json:"diff"`
EntityType string `json:"entityType"`
EventType AuditEventType `json:"eventType"`
AdditionalInfo string `json:"additionalInfo"`
Name string `json:"name"`
ObjectType string `json:"objectType"`
Source string `json:"source"`
UID string `json:"uid"`
ObjectCount int `json:"objectCount"`
SupportAccess bool `json:"supportAccess"`
}
func (a AuditEvent) String() string {
return Stringify(a)
}
func (a AuditEvent) MetaType() MetaType {
return MetaTypeAuditEvent
}
// TODO: поле diff в событии аудита может иметь разный тип данных: {},[] и ""
// AuditEventDiff Формат поля diff
//
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/audit/#audit-audit-sobytiq-format-polq-diff
type AuditEventDiff struct {
OldValue any `json:"oldValue,omitempty"`
NewValue any `json:"newValue,omitempty"`
Account string `json:"account,omitempty"`
Country string `json:"country,omitempty"`
TemplateName string `json:"templateName,omitempty"`
PublicationHref string `json:"publicationHref,omitempty"`
SenderEmail string `json:"senderEmail,omitempty"`
TargetEmail string `json:"targetEmail,omitempty"`
SubjectEmail string `json:"subjectEmail,omitempty"`
Text string `json:"text,omitempty"`
AttributeName string `json:"attributeName,omitempty"`
}
func (a AuditEventDiff) String() string {
return Stringify(a)
}
// AuditEventType Действие События
type AuditEventType string
const (
AuditEventTypeRegistration AuditEventType = "registration" // Регистрация
AuditEventTypeBulkOperation AuditEventType = "bulkoperation" // Массовая операция
AuditEventTypeClosePublication AuditEventType = "closepublication" // Удаление публикации
AuditEventTypeCreate AuditEventType = "create" // Создание сущностей
AuditEventTypeDelete AuditEventType = "delete" // Удаление сущностей
AuditEventTypeOpenPublication AuditEventType = "openpublication" // Создание публикации
AuditEventTypePrint AuditEventType = "print" // Печать документа
AuditEventTypePutToArchive AuditEventType = "puttoarchive" // Помещение в архив
AuditEventTypePutToRecycleBin AuditEventType = "puttorecyclebin" // Помещение в корзину
AuditEventTypeReplaceToken AuditEventType = "replacetoken" // Смена токена для Точки продаж
AuditEventTypeRestoreFromArchive AuditEventType = "restorefromarchive" // Извлечение из архива
AuditEventTypeRestoreFromRecycleBin AuditEventType = "restorefromrecyclebin" // Извлечение из корзины
AuditEventTypeSendEmailFromEntity AuditEventType = "sendemailfromentity" // Отправка письма
AuditEventTypeUpdate AuditEventType = "update" // Изменение сущностей
)
// AuditFilters Фильтры
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/audit/#audit-audit-fil-try
type AuditFilters struct {
EventType Slice[string] `json:"eventType"` // Действия, по которым могут быть отфильтрованы сущности аудита
Source Slice[string] `json:"source"` // Типы действий, по которым могут быть отфильтрованы сущности аудита
EntityType Slice[string] `json:"entityType"` // Названия сущностей, по которым могут быть отфильтрованы сущности аудита
}
func (a AuditFilters) String() string {
return Stringify(a)
}