-
Notifications
You must be signed in to change notification settings - Fork 2
/
formfield.go
51 lines (41 loc) · 1.47 KB
/
formfield.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
package files_sdk
import (
"encoding/json"
lib "github.com/Files-com/files-sdk-go/v2/lib"
)
type FormField struct {
Id int64 `json:"id,omitempty" path:"id"`
Label string `json:"label,omitempty" path:"label"`
Required *bool `json:"required,omitempty" path:"required"`
HelpText string `json:"help_text,omitempty" path:"help_text"`
FieldType string `json:"field_type,omitempty" path:"field_type"`
OptionsForSelect []string `json:"options_for_select,omitempty" path:"options_for_select"`
DefaultOption string `json:"default_option,omitempty" path:"default_option"`
FormFieldSetId int64 `json:"form_field_set_id,omitempty" path:"form_field_set_id"`
}
type FormFieldCollection []FormField
func (f *FormField) UnmarshalJSON(data []byte) error {
type formField FormField
var v formField
if err := json.Unmarshal(data, &v); err != nil {
return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
}
*f = FormField(v)
return nil
}
func (f *FormFieldCollection) UnmarshalJSON(data []byte) error {
type formFields FormFieldCollection
var v formFields
if err := json.Unmarshal(data, &v); err != nil {
return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
}
*f = FormFieldCollection(v)
return nil
}
func (f *FormFieldCollection) ToSlice() *[]interface{} {
ret := make([]interface{}, len(*f))
for i, v := range *f {
ret[i] = v
}
return &ret
}