-
Notifications
You must be signed in to change notification settings - Fork 4
/
attribute.go
63 lines (54 loc) · 2.31 KB
/
attribute.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
package moysklad
import (
"github.com/google/uuid"
)
// Attribute Доп поле.
// Ключевое слово: attributemetadata
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/workbook/#workbook-rabota-s-dopolnitel-nymi-polqmi-cherez-json-api
type Attribute struct {
Value any `json:"value,omitempty"`
CustomEntityMeta *Meta `json:"customEntityMeta,omitempty"`
Description *string `json:"description,omitempty"`
ID *uuid.UUID `json:"id,omitempty"`
Meta *Meta `json:"meta,omitempty"`
Name *string `json:"name,omitempty"`
Required *bool `json:"required,omitempty"`
Show *bool `json:"show,omitempty"`
File *File `json:"file,omitempty"`
Type AttributeType `json:"type,omitempty"`
}
func (a Attribute) String() string {
return Stringify(a)
}
// GetMeta удовлетворяет интерфейсу HasMeta
func (a Attribute) GetMeta() *Meta {
return a.Meta
}
func (a Attribute) MetaType() MetaType {
return MetaTypeAttribute
}
type Attributes []*Attribute
// Push добавляет элементы в срез.
func (a *Attributes) Push(elements ...*Attribute) *Attributes {
*a = append(*a, elements...)
return a
}
// AttributeType Тип доп. поля
type AttributeType string
const (
AttributeTypeTime AttributeType = "time"
AttributeTypeLink AttributeType = "link"
AttributeTypeString AttributeType = "string"
AttributeTypeText AttributeType = "text"
AttributeTypeFile AttributeType = "file"
AttributeTypeBoolean AttributeType = "boolean"
AttributeTypeDouble AttributeType = "double"
AttributeTypeLong AttributeType = "long"
AttributeTypeDictionaryContract AttributeType = "contract"
AttributeTypeDictionaryCounterParty AttributeType = "counterparty"
AttributeTypeDictionaryProject AttributeType = "project"
AttributeTypeDictionaryStore AttributeType = "store"
AttributeTypeDictionaryEmployee AttributeType = "employee"
AttributeTypeDictionaryProduct AttributeType = "product"
AttributeTypeDictionaryCustom AttributeType = "customentity"
)