Skip to content

Instantly share code, notes, and snippets.

@ilgooz
Last active July 23, 2018 10:33
Show Gist options
  • Save ilgooz/84d5f6b526a749ad0479ee8215310efc to your computer and use it in GitHub Desktop.
Save ilgooz/84d5f6b526a749ad0479ee8215310efc to your computer and use it in GitHub Desktop.
// Package main is an application that uses functionalities from following services:
// https://github.com/mesg-foundation/service-webhook
// https://github.com/mesg-foundation/service-discord-invitation
package main
import (
"fmt"
"log"
"github.com/ilgooz/mesg-go/application"
)
var webhookServiceID = "v1_b16eeffb4a39d0cf84ffbb179c9efa77"
var discordInvServiceID = "v1_a42f899344ea211436adf2e8f8d3ccaa"
var sendgridKey = "SG.XXX"
var email = "ilkergoktugozturk@gmail.com"
func main() {
app, err := application.New()
if err != nil {
log.Fatal(err)
}
ln := app.WhenEvent(webhookServiceID, "request")
ln.Provide(sendgridRequest{
Email: email,
SendgridAPIKey: sendgridKey,
})
executions := ln.Execute(discordInvServiceID, "send")
// you don't need to listen for executions. only do if you want to access to executionID or errors
for execution := range executions {
fmt.Println(execution.ID)
// closes listening for further events which also causes executions channel to close.
ln.Close()
}
}
type sendgridRequest struct {
Email string `json:"email"`
SendgridAPIKey string `json:"sendgridAPIKey"`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment