Skip to content

Commit

Permalink
Merge pull request #969 from norabal/fix/add_enterprise_property
Browse files Browse the repository at this point in the history
Add Enterprise Grid related property
  • Loading branch information
kanata2 committed Sep 16, 2021
2 parents 09bb1e4 + 3760a81 commit 4981f65
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
6 changes: 6 additions & 0 deletions interactions.go
Expand Up @@ -53,6 +53,7 @@ type InteractionCallback struct {
APIAppID string `json:"api_app_id"`
BlockID string `json:"block_id"`
Container Container `json:"container"`
Enterprise Enterprise `json:"enterprise"`
DialogSubmissionCallback
ViewSubmissionCallback
ViewClosedCallback
Expand Down Expand Up @@ -128,6 +129,11 @@ type Container struct {
IsAppUnfurl bool `json:"is_app_unfurl"`
}

type Enterprise struct {
ID string `json:"id"`
Name string `json:"name"`
}

// ActionCallback is a convenience struct defined to allow dynamic unmarshalling of
// the "actions" value in Slack's JSON response, which varies depending on block type
type ActionCallbacks struct {
Expand Down
13 changes: 7 additions & 6 deletions slackevents/outer_events.go
Expand Up @@ -8,12 +8,13 @@ import (

// EventsAPIEvent is the base EventsAPIEvent
type EventsAPIEvent struct {
Token string `json:"token"`
TeamID string `json:"team_id"`
Type string `json:"type"`
APIAppID string `json:"api_app_id"`
Data interface{}
InnerEvent EventsAPIInnerEvent
Token string `json:"token"`
TeamID string `json:"team_id"`
Type string `json:"type"`
APIAppID string `json:"api_app_id"`
EnterpriseID string `json:"enterprise_id"`
Data interface{}
InnerEvent EventsAPIInnerEvent
}

// EventsAPIURLVerificationEvent received when configuring a EventsAPI driven app
Expand Down
12 changes: 12 additions & 0 deletions slackevents/parsers.go
Expand Up @@ -39,6 +39,7 @@ func parseOuterEvent(rawE json.RawMessage) (EventsAPIEvent, error) {
"",
"unmarshalling_error",
"",
"",
&slack.UnmarshallingErrorEvent{ErrorObj: err},
EventsAPIInnerEvent{},
}, err
Expand All @@ -52,6 +53,7 @@ func parseOuterEvent(rawE json.RawMessage) (EventsAPIEvent, error) {
"",
"unmarshalling_error",
"",
"",
&slack.UnmarshallingErrorEvent{ErrorObj: err},
EventsAPIInnerEvent{},
}, err
Expand All @@ -61,6 +63,7 @@ func parseOuterEvent(rawE json.RawMessage) (EventsAPIEvent, error) {
e.TeamID,
e.Type,
e.APIAppID,
e.EnterpriseID,
cbEvent,
EventsAPIInnerEvent{},
}, nil
Expand All @@ -73,6 +76,7 @@ func parseOuterEvent(rawE json.RawMessage) (EventsAPIEvent, error) {
"",
"unmarshalling_error",
"",
"",
&slack.UnmarshallingErrorEvent{ErrorObj: err},
EventsAPIInnerEvent{},
}, err
Expand All @@ -82,6 +86,7 @@ func parseOuterEvent(rawE json.RawMessage) (EventsAPIEvent, error) {
e.TeamID,
e.Type,
e.APIAppID,
e.EnterpriseID,
urlVE,
EventsAPIInnerEvent{},
}, nil
Expand All @@ -97,6 +102,7 @@ func parseInnerEvent(e *EventsAPICallbackEvent) (EventsAPIEvent, error) {
e.TeamID,
"unmarshalling_error",
e.APIAppID,
"",
&slack.UnmarshallingErrorEvent{ErrorObj: err},
EventsAPIInnerEvent{},
}, err
Expand All @@ -108,6 +114,7 @@ func parseInnerEvent(e *EventsAPICallbackEvent) (EventsAPIEvent, error) {
e.TeamID,
iE.Type,
e.APIAppID,
"",
nil,
EventsAPIInnerEvent{},
}, fmt.Errorf("Inner Event does not exist! %s", iE.Type)
Expand All @@ -121,6 +128,7 @@ func parseInnerEvent(e *EventsAPICallbackEvent) (EventsAPIEvent, error) {
e.TeamID,
"unmarshalling_error",
e.APIAppID,
"",
&slack.UnmarshallingErrorEvent{ErrorObj: err},
EventsAPIInnerEvent{},
}, err
Expand All @@ -130,6 +138,7 @@ func parseInnerEvent(e *EventsAPICallbackEvent) (EventsAPIEvent, error) {
e.TeamID,
e.Type,
e.APIAppID,
"",
e,
EventsAPIInnerEvent{iE.Type, recvEvent},
}, nil
Expand Down Expand Up @@ -196,6 +205,7 @@ func ParseEvent(rawEvent json.RawMessage, opts ...Option) (EventsAPIEvent, error
"",
"unmarshalling_error",
"",
"",
&slack.UnmarshallingErrorEvent{ErrorObj: err},
EventsAPIInnerEvent{},
}, err
Expand All @@ -210,6 +220,7 @@ func ParseEvent(rawEvent json.RawMessage, opts ...Option) (EventsAPIEvent, error
"",
"unmarshalling_error",
"",
"",
&slack.UnmarshallingErrorEvent{ErrorObj: err},
EventsAPIInnerEvent{},
}, err
Expand All @@ -219,6 +230,7 @@ func ParseEvent(rawEvent json.RawMessage, opts ...Option) (EventsAPIEvent, error
e.TeamID,
e.Type,
e.APIAppID,
e.EnterpriseID,
urlVerificationEvent,
EventsAPIInnerEvent{},
}, nil
Expand Down

0 comments on commit 4981f65

Please sign in to comment.