forked from laustindasauce/patreon-go-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebhook.go
60 lines (48 loc) · 1.9 KB
/
webhook.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
package patreon
const (
// MemberCreate specifies a create pledge event
MemberCreate = "members:create"
// MemberUpdate specifies an update pledge event
MemberUpdate = "members:update"
// MemberDelete specifies a delete pledge event
MemberDelete = "members:delete"
// MemberCreatePledge specifies a create pledge event
MemberCreatePledge = "members:pledge:create"
// MemberUpdatePledge specifies an update pledge event
MemberUpdatePledge = "members:pledge:update"
// MemberDeletePledge specifies a delete pledge event
MemberDeletePledge = "members:pledge:delete"
)
var (
// WebhookDefaultIncludes specifies default includes for Webhook.
WebhookDefaultIncludes = []string{"campaign", "client"}
// WebhookFields is all fields in the Webhook Attributes struct
WebhookFields = getObjectFields(Webhook{}.Attributes)
)
// Webhook is fired based on events happening on a particular campaign.
type Webhook struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes WebhookAttributes `json:"attributes"`
Relationships struct {
Campaign *CampaignRelationship `json:"campaign,omitempty"`
Memberships *MembershipsRelationship `json:"memberships,omitempty"`
} `json:"relationships"`
}
// WebhookAttributes is the attributes struct for Webhook
type WebhookAttributes struct {
LastAttemptedAt NullTime `json:"last_attempted_at"`
NumConsecutiveTimesFailed int `json:"num_consecutive_times_failed"`
Paused bool `json:"paused"`
Secret string `json:"secret"`
Triggers interface{} `json:"triggers"`
URI string `json:"uri"`
}
// WebhookResponse wraps Patreon's fetch user API response
type WebhookResponse struct {
Data Webhook `json:"data"`
Included Includes `json:"included"`
Links struct {
Self string `json:"self"`
} `json:"links"`
}