-
Notifications
You must be signed in to change notification settings - Fork 14
/
company.properties.go
80 lines (68 loc) · 2.58 KB
/
company.properties.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
package gohubspot
import "fmt"
// CompanyPropertiesService Company Properties Service definition
type CompanyPropertiesService service
// GetAll gets all company properties
func (s *CompanyPropertiesService) GetAll() (*ItemProperties, error) {
url := "/properties/v1/companies/properties/"
res := new(ItemProperties)
err := s.client.RunGet(url, res)
return res, err
}
// GetByName gets company property by name
func (s *CompanyPropertiesService) GetByName(name string) (*ItemProperty, error) {
url := fmt.Sprintf("/properties/v1/companies/properties/named/%s", name)
res := new(ItemProperty)
err := s.client.RunGet(url, res)
return res, err
}
// Create create a contact property
func (s *CompanyPropertiesService) Create(property ItemProperty) (*ItemProperty, error) {
url := "/properties/v1/companies/properties/"
res := new(ItemProperty)
if property.Options == nil {
property.Options = []ItemPropertyOption{}
}
err := s.client.RunPost(url, property, res)
return res, err
}
// Update updates an existing property by it name
func (s *CompanyPropertiesService) Update(name string, update ItemProperty) (*ItemProperty, error) {
url := fmt.Sprintf("/properties/v1/companies/properties/named/%s", name)
res := new(ItemProperty)
err := s.client.RunPut(url, update, res)
return res, err
}
// Delete deletes a contact property by name
func (s *CompanyPropertiesService) Delete(name string) error {
url := fmt.Sprintf("/properties/v1/companies/properties/named/%s", name)
err := s.client.RunDelete(url, nil)
return err
}
// GetGroups gets all contacts property groups
func (s *CompanyPropertiesService) GetGroups() (*ItemPropertyGroups, error) {
url := "/properties/v1/companies/groups"
res := new(ItemPropertyGroups)
err := s.client.RunGet(url, res)
return res, err
}
// CreateGroup creates a contact property group
func (s *CompanyPropertiesService) CreateGroup(group ItemPropertyGroup) (*ItemPropertyGroup, error) {
url := "/properties/v1/companies/groups"
res := new(ItemPropertyGroup)
err := s.client.RunPost(url, group, res)
return res, err
}
// UpdateGroup updates contact property group
func (s *CompanyPropertiesService) UpdateGroup(name string, update ItemPropertyGroup) (*ItemPropertyGroup, error) {
url := fmt.Sprintf("/properties/v1/companies/groups/named/%s", name)
res := new(ItemPropertyGroup)
err := s.client.RunPut(url, update, res)
return res, err
}
// DeleteGroup deletes a contact property group
func (s *CompanyPropertiesService) DeleteGroup(name string) error {
url := fmt.Sprintf("/properties/v1/companies/groups/named/%s", name)
err := s.client.RunDelete(url, nil)
return err
}