Skip to content

Instantly share code, notes, and snippets.

@NipunaMarcus
Created February 22, 2021 09:15
Show Gist options
  • Save NipunaMarcus/ec35de5ff4e11b00a5f9f6c28dfbc0c0 to your computer and use it in GitHub Desktop.
Save NipunaMarcus/ec35de5ff4e11b00a5f9f6c28dfbc0c0 to your computer and use it in GitHub Desktop.
calendar trigger
import ballerinax/googleapis_calendar;
import ballerina/websub;
import ballerina/config;
listener websub:Listener googleListener = new websub:Listener(8090);
googleapis_calendar:CalendarConfiguration calendarConfig = {
oauth2Config: {
accessToken: config:getAsString("ACCESS_TOKEN_8865F580_41C3_11EB_B4DB_4EF73BA5BFA5"),
refreshConfig: {
clientId: config:getAsString("CLIENT_ID_8865F580_41C3_11EB_B4DB_4EF73BA5BFA5"),
clientSecret: config:getAsString("CLIENT_SECRET_8865F580_41C3_11EB_B4DB_4EF73BA5BFA5"),
refreshUrl: config:getAsString("TOKEN_ENDPOINT_8865F580_41C3_11EB_B4DB_4EF73BA5BFA5"),
refreshToken: config:getAsString("REFRESH_TOKEN_8865F580_41C3_11EB_B4DB_4EF73BA5BFA5")
}
}
};
googleapis_calendar:CalendarClient calendarClient = new (calendarConfig);
string channelId = "";
string resourceId = "";
googleapis_calendar:WatchConfiguration watchConfig = {
id: "6679863",
token: "asdasioqwnn123128scdasd98",
'type: "webhook",
address: config:getAsString("CHOREO_APP_INVOCATION_URL") + "/websub",
params: {
ttl: "20000"
}
};
function init() {
googleapis_calendar:WatchResponse res = checkpanic calendarClient->watchEvents("nipunac@wso2.com", watchConfig);
channelId = res.id;
resourceId = res.resourceId;
}
@websub:SubscriberServiceConfig {subscribeOnStartUp: false}
service websub:SubscriberService /websub on googleListener {
remote function onNotification(websub:Notification notification) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment