diff --git a/subscriptions.go b/subscriptions.go new file mode 100644 index 0000000..2fcee1f --- /dev/null +++ b/subscriptions.go @@ -0,0 +1,20 @@ +package skill + +import ( + "olympos.io/encoding/edn" +) + +func (e *EventContextSubscription) GetResultInMapForm() []map[edn.Keyword]edn.RawMessage { + return decode[[]map[edn.Keyword]edn.RawMessage](e.Result) +} + +func (e *EventContextSubscription) GetResultInListForm() [][]edn.RawMessage { + return decode[[][]edn.RawMessage](e.Result) +} + +func decode[P interface{}](event edn.RawMessage) P { + ednboby, _ := edn.Marshal(event) + var decoded P + edn.Unmarshal(ednboby, &decoded) + return decoded +} diff --git a/types.go b/types.go index cf26771..5bb68f3 100644 --- a/types.go +++ b/types.go @@ -19,7 +19,6 @@ package skill import ( "context" - "github.com/atomist-skills/go-skill/util" "olympos.io/encoding/edn" ) @@ -51,14 +50,6 @@ type EventContextSubscription struct { } `edn:"metadata"` } -func (e *EventContextSubscription) GetResultInMapForm() []map[edn.Keyword]edn.RawMessage { - return util.Decode[[]map[edn.Keyword]edn.RawMessage](e.Result) -} - -func (e *EventContextSubscription) GetResultInListForm() [][]edn.RawMessage { - return util.Decode[[][]edn.RawMessage](e.Result) -} - type EventContextWebhook struct { Name string `edn:"name"` Configuration Configuration `edn:"configuration"`