Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
const mentor: Mentor = await database.query(sqlQuery, params)
// Record MeetupConfirm event
analytics.meetupConfirm(meetup, mentor)
// fetch mentee info
const [sqlQuery2, params2] = sql.createSQLqueryFromJSON(
'SELECT',
'users',
{ uid: meetup.menteeUID }
)
const mentee: User = await database.query(sqlQuery2, params2)
// create Calendar instance
const googleCalendar = google.calendar({
version: 'v3',
})
// set google options
google.options({
auth: oauth.OAuthClient,
})
const event = {
summary: `Upframe Meetup w/${mentee.name}`,
description: `Meetup with ${mentee.name} at ${meetup.location}`,
location: meetup.location,
status: 'confirmed',
id: meetup.mid,
start: {
dateTime: moment(meetup.start).toISOString(),
timeZone: 'UTC',
},
function deleteEvent(auth, id){
const calendar = google.calendar({version: 'v3', auth});
return new Promise((resolve, reject) => {
calendar.events.delete({
calendarId,
// calendarId: 'primary',
eventId: id
}, function(err) {
if (err) {
reject(`There was an error contacting the Calendar service: ${err}`)
}
resolve(`Event deleted`);
});
}
)
}
try {
let uid: string
if (!req.jwt || !req.jwt.uid) throw 403
else uid = req.jwt.uid
const [sqlQuery, params] = sql.createSQLqueryFromJSON('UPDATE', 'users', json, {uid})
const result = await this.database.query(sqlQuery, params)
if (req.body.upframeCalendarId) { // Adicionar um Webhook caso estejamos a atualizar o calendar id
response.code = 777
this.oauth.setCredentials({
access_token: req.body.googleAccessToken,
refresh_token: req.body.googleRefreshToken,
})
// create Calendar instance
const googleCalendar = google.calendar({
version: 'v3',
})
// set google options
google.options({
auth: this.oauth.OAuthClient,
})
const today = new Date() // We need to use the UNIX timestamp. Google likes to complicate
today.setHours(today.getHours() + 3)
const ttl = Math.round(today.getTime()).toString()
googleCalendar.events.watch({
auth: this.oauth.OAuthClient,
calendarId: req.body.upframeCalendarId,
requestBody: {
kind: 'api#channel',
const functions = require('firebase-functions');
const {google} = require('googleapis');
const {WebhookClient} = require('dialogflow-fulfillment');
// Enter your calendar ID below and service account JSON below, see https://github.com/dialogflow/bike-shop/blob/master/README.md#calendar-setup
const calendarId = ''; // looks like "6ujc6j6rgfk02cp02vg6h38cs0@group.calendar.google.com"
const serviceAccount = {}; // Starts with {"type": "service_account",...
// Set up Google Calendar Service account credentials
const serviceAccountAuth = new google.auth.JWT({
email: serviceAccount.client_email,
key: serviceAccount.private_key,
scopes: 'https://www.googleapis.com/auth/calendar'
});
const calendar = google.calendar('v3');
process.env.DEBUG = 'dialogflow:*'; // enables lib debugging statements
const timeZone = 'America/Los_Angeles';
const timeZoneOffset = '-07:00';
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
function hours (agent) {
if (currentlyOpen()) {
agent.add(`We're open now! We close at 5:30pm today.`);
} else {
agent.add(`We're currently closed, but we open every weekday at 9am!`);
}
}
function listEvents(auth) {
const calendar = google.calendar({version: 'v3', auth});
calendar.events.list({
calendarId: 'primary',
timeMin: (new Date()).toISOString(),
maxResults: 10,
singleEvents: true,
orderBy: 'startTime',
}, (err, res) => {
if (err) return console.log('The API returned an error: ' + err);
const events = res.data.items;
if (events.length) {
console.log('Upcoming 10 events:');
events.map((event, i) => {
const start = event.start.dateTime || event.start.date;
console.log(`${start} - ${event.summary}`);
});
} else {
function createEvent(auth, incidentName, incidentId, incidentDescription, eventHandle){
const calendar = google.calendar({version: 'v3', auth});
var calendarId = process.env.GOOGLE_CALENDAR_ID;
if(!calendarId){
calendarId = 'primary';
}
var calendarTimezone = process.env.GOOGLE_CALENDAR_TIMEZONE;
if(!calendarTimezone){
calendarTimezone = 'Europe/Amsterdam';
}
var start = new Date ();
var end = new Date ( start );
end.setMinutes ( start.getMinutes() + 5 );
var event = {
'summary': incidentName,
'description': incidentDescription,
'start': {
function createEvent(auth, incidentName, incidentId, incidentDescription, onSuccess){
const calendar = google.calendar({version: 'v3', auth});
var calendarId = process.env.GOOGLE_CALENDAR_ID;
if(!calendarId){
calendarId = 'primary';
}
var calendarTimezone = process.env.GOOGLE_CALENDAR_TIMEZONE;
if(!calendarTimezone){
calendarTimezone = 'Europe/Amsterdam';
}
var start = new Date ();
var end = new Date ( start );
end.setMinutes ( start.getMinutes() + 5 );
var event = {
'summary': incidentName,
'description': incidentDescription,
'start': {
async function listEvents(auth: OAuth2Client): Promise {
const calendar = google.calendar({ version: 'v3', auth })
const res = await calendar.events.list({
calendarId: 'primary',
timeMin: new Date().toISOString(),
maxResults: 2500,
singleEvents: true,
orderBy: 'startTime',
})
return res.data.items
}
import { Plugin, command } from 'munar-core'
import { google } from 'googleapis'
import moment from 'moment'
const debug = require('debug')('munar:events')
const gcal = google.calendar('v3')
export default class EventsCalendar extends Plugin {
static description = 'Google Calendar-based event scheduling.'
static defaultOptions = {
key: '',
calendar: ''
}
@command('nextevent')
async showNextEvent (message) {
const body = await gcal.events.list({
key: this.options.key,
calendarId: this.options.calendar,
timeMin: new Date().toISOString(),
maxResults: 1,