-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathcrm_tickets_test.go
105 lines (94 loc) · 2.43 KB
/
crm_tickets_test.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package hubspot
import (
"fmt"
"os"
"testing"
)
func TestListTickets(t *testing.T) {
t.SkipNow()
cli, _ := NewClient(SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN")))
opt := &RequestQueryOption{}
opt.Properties = []string{"Content"}
res, err := cli.CRM.Tickets.List(opt)
if err != nil {
t.Error(err)
}
fmt.Printf("%+v\n", res)
fmt.Printf("%+v\n", res.Results[0])
}
func TestGetCrmTicket(t *testing.T) {
t.SkipNow()
cli, _ := NewClient(SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN")))
opt := &RequestQueryOption{}
opt.Properties = []string{"Content", "associated_contact_lifecycle_stage", "hubspot_owner_id"}
res, err := cli.CRM.Tickets.Get("1594949554", opt)
if err != nil {
t.Error(err)
}
fmt.Printf("%+v\n", res)
}
func TestCreateCrmTicket(t *testing.T) {
t.SkipNow()
cli, _ := NewClient(SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN")))
props := make(map[string]interface{})
props["hs_pipeline"] = "30440034"
props["hs_pipeline_stage"] = "69304142"
props["hubspot_owner_id"] = "301296186"
props["hs_ticket_priority"] = "LOW"
props["content"] = "this would be some content"
props["subject"] = "testing, please ignore"
req := &CrmTicketCreateRequest{
Properties: props,
}
res, err := cli.CRM.Tickets.Create(req)
if err != nil {
t.Error(err)
}
fmt.Printf("%+v\n", res)
}
func TestDeleteCrmTicket(t *testing.T) {
t.SkipNow()
cli, _ := NewClient(SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN")))
err := cli.CRM.Tickets.Archive("1594967688")
if err != nil {
t.Error(err)
}
}
func TestUpdateCrmTicket(t *testing.T) {
t.SkipNow()
cli, _ := NewClient(SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN")))
props := make(map[string]interface{})
props["hs_ticket_priority"] = "HIGH"
req := &CrmTicketCreateRequest{
Properties: props,
}
res, err := cli.CRM.Tickets.Update("1594957134", req)
if err != nil {
t.Error(err)
}
fmt.Printf("%+v\n", res)
}
func TestSearchCrmTicket(t *testing.T) {
t.SkipNow()
cli, _ := NewClient(SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN")))
req := &CrmTicketSearchRequest{
FilterGroups: []*CrmTicketSearchFilterGroup{
{
Filters: []*CrmTicketSearchFilter{
{
Value: NewString("LOW"),
PropertyName: NewString("hs_ticket_priority"),
Operator: NewString("EQ"),
},
},
},
},
}
res, err := cli.CRM.Tickets.Search(req)
if err != nil {
t.Error(err)
}
for _, ticket := range res.Results {
fmt.Printf("%+v\n", ticket)
}
}