forked from slack-go/slack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathouter_events.go
67 lines (58 loc) · 2.22 KB
/
outer_events.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
// outer_events.go provides EventsAPI particular outer events
package slackevents
import (
"encoding/json"
)
// EventsAPIEvent is the base EventsAPIEvent
type EventsAPIEvent struct {
Token string `json:"token"`
TeamID string `json:"team_id"`
Type string `json:"type"`
Data interface{}
InnerEvent EventsAPIInnerEvent
}
// EventsAPIURLVerificationEvent received when configuring a EventsAPI driven app
type EventsAPIURLVerificationEvent struct {
Token string `json:"token"`
Challenge string `json:"challenge"`
Type string `json:"type"`
}
// ChallengeResponse is a response to a EventsAPIEvent URLVerification challenge
type ChallengeResponse struct {
Challenge string
}
// EventsAPICallbackEvent is the main (outer) EventsAPI event.
type EventsAPICallbackEvent struct {
Type string `json:"type"`
Token string `json:"token"`
TeamID string `json:"team_id"`
APIAppID string `json:"api_app_id"`
InnerEvent *json.RawMessage `json:"event"`
AuthedUsers []string `json:"authed_users"`
EventID string `json:"event_id"`
EventTime int `json:"event_time"`
}
// EventsAPIAppRateLimited indicates your app's event subscriptions are being rate limited
type EventsAPIAppRateLimited struct {
Type string `json:"type"`
Token string `json:"token"`
TeamID string `json:"team_id"`
MinuteRateLimited int `json:"minute_rate_limited"`
APIAppID string `json:"api_app_id"`
}
const (
// CallbackEvent is the "outer" event of an EventsAPI event.
CallbackEvent = "event_callback"
// URLVerification is an event used when configuring your EventsAPI app
URLVerification = "url_verification"
// AppRateLimited indicates your app's event subscriptions are being rate limited
AppRateLimited = "app_rate_limited"
)
// EventsAPIEventMap maps OUTTER Event API events to their corresponding struct
// implementations. The structs should be instances of the unmarshalling
// target for the matching event type.
var EventsAPIEventMap = map[string]interface{}{
CallbackEvent: EventsAPICallbackEvent{},
URLVerification: EventsAPIURLVerificationEvent{},
AppRateLimited: EventsAPIAppRateLimited{},
}