-
Notifications
You must be signed in to change notification settings - Fork 0
/
webhook_helpers.go
95 lines (75 loc) · 1.77 KB
/
webhook_helpers.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
package axcelerate
import (
"net/url"
"strconv"
)
type WebhookBooking struct {
ContactID int
StatusID int
NewStatus string
CurrentStatus string
EventType string
WorkshopID int
}
type WebhookContact struct {
ContactID int
EventType string
ContactName string
}
type WebhookWorkshop struct {
WorkshopTriggerID int
ProcessGUID string
PDataID int
}
func GetWebHookBooking(payload []byte) (WebhookBooking, error) {
var b WebhookBooking
params, err := url.ParseQuery(string(payload))
if err != nil {
return b, err
}
contactID, err := strconv.Atoi(params.Get("contactID"))
if err != nil {
return b, err
}
b.ContactID = contactID
statusID, err := strconv.Atoi(params.Get("statusID"))
if err != nil {
return b, err
}
b.StatusID = statusID
PDataID, err := strconv.Atoi(params.Get("PDataID"))
if err != nil {
return b, err
}
b.WorkshopID = PDataID
b.NewStatus = params.Get("new_status")
b.CurrentStatus = params.Get("current_status")
b.EventType = params.Get("eventType")
return b, nil
}
func GetWebHookContact(payload []byte) (WebhookContact, error) {
var c WebhookContact
params, err := url.ParseQuery(string(payload))
if err != nil {
return c, err
}
i, err := strconv.Atoi(params.Get("contactID"))
if err != nil {
return c, err
}
c.ContactID = i
c.EventType = params.Get("eventType")
c.ContactName = params.Get("contactName")
return c, nil
}
func GetWebHookWorkshop(payload []byte) (WebhookWorkshop, error) {
var w WebhookWorkshop
params, err := url.ParseQuery(string(payload))
if err != nil {
return w, err
}
w.WorkshopTriggerID, _ = strconv.Atoi(params.Get("workshopTriggerID"))
w.ProcessGUID = params.Get("processGUID")
w.PDataID, _ = strconv.Atoi(params.Get("PDataID"))
return w, nil
}