-
Notifications
You must be signed in to change notification settings - Fork 6
/
companies.go
63 lines (53 loc) · 1.62 KB
/
companies.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 hubspot
import "strconv"
// Companies client
type Companies struct {
Client
}
// Companies constructor (from Client)
func (c Client) Companies() Companies {
return Companies{
Client: c,
}
}
// CompaniesRequest object
type CompaniesRequest struct {
Properties []Property `json:"properties"`
}
// CompaniesResponse object
type CompaniesResponse struct {
ErrorResponse
CompanyID int `json:"companyId"`
PortalID int `json:"portalId"`
Properties CompanyProperties `json:"properties"`
IsDeleted bool `json:"isDeleted"`
}
// CompanyProperties response object
type CompanyProperties struct {
CreateDate ResponseProperty `json:"createdate"`
Name ResponseProperty `json:"name"`
Description ResponseProperty `json:"description"`
}
// Get Company
func (c Companies) Get(companyID int) (CompaniesResponse, error) {
r := CompaniesResponse{}
err := c.Client.Request("GET", "/companies/v2/companies/"+strconv.Itoa(companyID), nil, &r)
return r, err
}
// Create new Company
func (c Companies) Create(data CompaniesRequest) (CompaniesResponse, error) {
r := CompaniesResponse{}
err := c.Client.Request("POST", "/companies/v2/companies/", data, &r)
return r, err
}
// Update Deal
func (c Companies) Update(companyID int, data CompaniesRequest) (CompaniesResponse, error) {
r := CompaniesResponse{}
err := c.Client.Request("PUT", "/companies/v2/companies/"+strconv.Itoa(companyID), data, &r)
return r, err
}
// Delete Deal
func (c Companies) Delete(companyID int) error {
err := c.Client.Request("DELETE", "/companies/v2/companies/"+strconv.Itoa(companyID), nil, nil)
return err
}