-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_fields.go
64 lines (55 loc) · 1.57 KB
/
custom_fields.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
package activecampaign
import (
"context"
"encoding/json"
"net/http"
)
type Fields struct {
FieldOptions interface{} `json:"fieldOptions"`
FieldRelations []FieldRelation `json:"fieldRels"`
Fields []Field `json:"fields"`
Meta FieldsMeta `json:"meta"`
}
type FieldsMeta struct {
Total string `json:"total"`
}
type FieldRelation struct {
Field string `json:"field"`
RelationID string `json:"relid"`
DOrder string `json:"dorder"`
CreateDate string `json:"cdate"`
//Links interface{} `json:"links"`
ID string `json:"id"`
}
type Field struct {
Title string `json:"title"`
Description string `json:"descript"`
IsRequired string `json:"isrequired"`
Perstag string `json:"perstag"`
DefaultValue string `json:"defval"`
Visible string `json:"visible"`
Service string `json:"service"`
Ordernum string `json:"ordernum"`
CreateDate string `json:"cdate"`
UpdateDate string `json:"udate"`
//Options interface{} `json:"options"`
Relations []string `json:"relations"`
Links FieldLink `json:"links"`
ID string `json:"id"`
}
type FieldLink struct {
Options string `json:"options"`
Relations string `json:"Relations"`
}
func (a *ActiveCampaign) Fields(ctx context.Context, pof *POF) (*Fields, error) {
res, err := a.send(ctx, http.MethodGet, "fields", pof, nil)
if err != nil {
return nil, &Error{Op: "fields", Err: err}
}
var fields Fields
err = json.NewDecoder(res.Body).Decode(&fields)
if err != nil {
return nil, &Error{Op: "fields", Err: err}
}
return &fields, nil
}