-
Notifications
You must be signed in to change notification settings - Fork 28
/
association.go
72 lines (59 loc) · 2.19 KB
/
association.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
package hubspot
import (
"fmt"
)
// Associate associates HubSpot objects like Deal and Contact.
// Object type and IDs are required for making the association.
// Using a custom object is also possible.
// Reference: https://developers.hubspot.com/docs/api/crm/associations
const (
associationBasePath = "associations"
)
// ObjectType is the name used in object association.
type ObjectType string
// Default Object types
const (
ObjectTypeContact ObjectType = "contacts"
ObjectTypeDeal ObjectType = "deals"
ObjectTypeCompany ObjectType = "company"
)
// AssociationType is the name of the key used to associate the objects together.
type AssociationType string
// Default association types
// Reference: https://legacydocs.hubspot.com/docs/methods/crm-associations/crm-associations-overview
const (
AssociationTypeContactToCompany AssociationType = "contact_to_company"
AssociationTypeContactToDeal AssociationType = "contact_to_deal"
AssociationTypeContactToEngagement AssociationType = "contact_to_engagement"
AssociationTypeContactToTicket AssociationType = "contact_to_ticket"
AssociationTypeDealToContact AssociationType = "deal_to_contact"
AssociationTypeDealToCompany AssociationType = "deal_to_company"
AssociationTypeDealToEngagement AssociationType = "deal_to_engagement"
AssociationTypeDealToLineItem AssociationType = "deal_to_line_item"
AssociationTypeDealToTicket AssociationType = "deal_to_ticket"
AssociationTypeCompanyToContact AssociationType = "company_to_contact"
AssociationTypeCompanyToDeal AssociationType = "company_to_deal"
)
type AssociationConfig struct {
ToObject ObjectType
ToObjectID string
Type AssociationType
}
func (c *AssociationConfig) makeAssociationPath() string {
return fmt.Sprintf("%s/%s/%s/%s", associationBasePath, c.ToObject, c.ToObjectID, c.Type)
}
type Associations struct {
Contacts struct {
Results []AssociationResult `json:"results"`
} `json:"contacts"`
Deals struct {
Results []AssociationResult `json:"results"`
} `json:"deals"`
Companies struct {
Results []AssociationResult `json:"results"`
} `json:"companies"`
}
type AssociationResult struct {
ID string `json:"id"`
Type string `json:"type"`
}