-
Notifications
You must be signed in to change notification settings - Fork 0
/
Code.gs
54 lines (44 loc) · 1.36 KB
/
Code.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function onOpen(e) {
DocumentApp.getUi()
.createMenu('Huddle01 Meeting Add-On')
.addItem('Create New Meeting', 'createRoom')
.addItem('Join Meeting', 'joinRoom')
.addToUi();
}
function createRoom() {
var apiKey = "YOUR_API_KEY";
var url = "https://api.huddle01.com/api/v1/create-iframe-room";
var data = {
title: "Huddle01 GDocs Meeting ",
roomLocked: false
};
var headers = {
"Content-Type": "application/json",
"x-api-key": apiKey
};
var options = {
"method" : "post",
"payload" : JSON.stringify(data),
"headers" : headers
};
var response = UrlFetchApp.fetch(url, options);
if (response.getResponseCode() === 200) {
var json = JSON.parse(response.getContentText());
var meetingLink = json.data.meetingLink;
DocumentApp.getUi().alert('Room Created!\nMeeting Link: ' + meetingLink);
} else {
DocumentApp.getUi().alert('Error creating room.', response.getContentText());
}
}
function joinRoom() {
var meetingLink = DocumentApp.getUi().prompt('Enter Meeting Link').getResponseText();
if (meetingLink) {
var html = HtmlService.createTemplateFromFile('Meeting');
html.meetingLink = meetingLink;
var sidebar = html.evaluate()
.setTitle('Huddle01 GDocs Meeting')
.setWidth(400)
.setHeight(600);
DocumentApp.getUi().showSidebar(sidebar);
}
}