Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simultatneous Interpretation code added for create #22

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions meetings/create/create_si_meeting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/**
* _
* __ _____| |__ _____ __
* \ \ /\ / / _ \ '_ \ / _ \ \/ /
* \ V V / __/ |_) | __/> < @WebexDevs
* \_/\_/ \___|_.__/ \___/_/\_\
*
* CREATE a meeting in Webex with the REST API in Node
* https://developer.webex.com/docs/api/v1/meetings/create-a-meeting
*
* Step 0: Have a (free) Webex account: https://cart.webex.com/sign-up
* Step 1: Log in to https://developer.webex.com/login
* Step 2: Find your bearer token at
* https://developer.webex.com/docs/getting-started under "Your
* Personal Access Token" in the middle of the page.
* Step 3: Replace the string on the line that defines const myWebexDeveloperToken
* and interpreterAry values for an interpreter object,
* just below, with your personal bearer (access) token. Hit "save".
* Step 4: Run this file with node from within
* this directory on the command line:
*
* node ./create_si_meeting.js
*
* Step 5: Profit. Get your app listed in the Webex App Hub!
* https://apphub.webex.com/
*
*/

const https = require('https'); // https://nodejs.org/api/https.html

const myWebexDeveloperToken = 'REPLACE ME WITH YOUR WEBEX DEVELOPER PERSONAL ACCESS TOKEN';
//REPLACE languageCode1/2 VARIABLES WITH REQUIRED LANGUAGES, BELOW IS EXAMPLE OF ENGLISH TO SPANSISH AND SPANISH TO ENGLISH
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there links to docs we can add to this? Listing of supported language codes?

interpreterAry = [
{"languageCode1":"en", "languageCode2":"es", "email":"REPLACE WITH INTERPRETER EMAIL", "displayName":"REPLACE WITH INTERPRETER DISPLAY NAME"},
{"languageCode1":"es", "languageCode2":"en", "email":"REPLACE WITH INTERPRETER EMAIL", "displayName":"REPLACE WITH INTERPRETER DISPLAY NAME"}
];

const body = JSON.stringify({
title: 'WebDev Meeting w/ Simultaneous Interpretation', // String, Required | Meeting title. The title can be a maximum of 128 characters long.
start: '2022-08-12T13:51:43-04:00', // String, Required | https://en.wikipedia.org/wiki/ISO_8601 format
end: '2022-08-12T14:38:16-04:00', // String, Required | Replace the start/end with the times you'd like
simultaneousInterpretation: {"enabled":true,"interpreters":interpreterAry}
});

const options = {
method: 'POST', // https://en.wikipedia.org/wiki/Representational_state_transfer#Semantics_of_HTTP_methods
hostname: 'webexapis.com', // https://developer.webex.com/docs/basics
path: '/v1/meetings', // https://developer.webex.com/docs/meetings
port: 443, // https://en.wikipedia.org/wiki/HTTPS#Technical
headers: {
Authorization: `Bearer ${myWebexDeveloperToken}`, // https://oauth.net/2/bearer-tokens/
'Content-Type': 'application/json', // https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON
'Content-Length': body.length, // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Length
},
};

const req = https.request(options, (res) => {
console.log(`statusCode: ${res.statusCode}`); // https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

let data = '';

res.on('data', (chunk) => {
data += chunk;
});

res.on('end', () => {
console.log(JSON.parse(data)); // https://nodejs.org/en/knowledge/javascript-conventions/what-is-json/
});

res.on('error', (e) => {
console.error(`Error: ${e.message}`); // https://nodejs.org/api/errors.html#errormessage_1
});
});

req.on('error', (e) => {
console.error(e);
});

req.write(body);

req.end();

/**
* Expected output:
*
* The HTTPS request should receive a status code. We expect a 200.
*
* The body of the response is JSON text. We expect a single object
* containing details of the newly-created meeting. These details
* should include at least the following fields:
*
* - id
* - meetingNumber
* - title
* - password
* - phoneAndVideoSystemPassword
* - meetingType
* - state
* - timezone
* - start
* - end
* - hostUserId
* - hostDisplayName
* - hostEmail
* - hostKey
* - siteUrl
* - webLink
* - sipAddress
* - dialInIpAddress
* - enabledAutoRecordMeeting
* - allowAnyUserToBeCoHost
* - allowFirstUserToBeCoHost
* - allowAuthenticatedDevices
* - enabledJoinBeforeHost
* - joinBeforeHostMinutes
* - enableConnectAudioBeforeHost
* - excludePassword
* - publicMeeting
* - enableAutomaticLock
* - telephony
* - accessCode
* - callInNumbers
* - links
*
* An example of the response JSON may be found
* in this directory: ./example_response.json
*
*/

135 changes: 135 additions & 0 deletions meetings/update/update_si_meeting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/**
* _
* __ _____| |__ _____ __
* \ \ /\ / / _ \ '_ \ / _ \ \/ /
* \ V V / __/ |_) | __/> < @WebexDevs
* \_/\_/ \___|_.__/ \___/_/\_\
*
* UPDATE a meeting in Webex with the REST API in Node
* https://developer.webex.com/docs/api/v1/meetings/create-a-meeting
*
* Step 0: Have a (free) Webex account: https://cart.webex.com/sign-up
* Step 1: Log in to https://developer.webex.com/login
* Step 2: Find your bearer token at
* https://developer.webex.com/docs/getting-started under "Your
* Personal Access Token" in the middle of the page.
* Step 3: Replace the string on the line that defines const myWebexDeveloperToken,
* just below, with your personal bearer (access) token. Hit "save".
* Step 4: Run an example from https://github.com/WebexSamples/rest-api-samples/tree/main/meetings/read
* to obtain a meeting ID and password. Replace lines that define
* const `meetingID` & `meetingPassword` with your meeting ID & password.
* Step 5: Run this file with node from within
* this directory on the command line:
*
* node ./update_si_meeting.js
*
* Step 6: Profit. Get your app listed in the Webex App Hub!
* https://apphub.webex.com/
*
*/

const https = require('https'); // https://nodejs.org/api/https.html

const myWebexDeveloperToken = 'REPLACE WITH API KEY';
const meetingID = 'REPLACE WITH MEETING ID';
const meetingPassword = 'REPLACE WITH MEETING PASSWORD';
//REPLACE languageCode1/2 VARIABLES WITH REQUIRED LANGUAGES, BELOW IS EXAMPLE OF ENGLISH TO SPANSISH AND SPANISH TO ENGLISH
interpreterAry = [
{"languageCode1":"en", "languageCode2":"es", "email":"REPLACE WITH INTERPRETER EMAIL", "displayName":"REPLACE WITH INTERPRETER DISPLAY NAME"},
{"languageCode1":"es", "languageCode2":"en", "email":"REPLACE WITH INTERPRETER EMAIL", "displayName":"REPLACE WITH INTERPRETER DISPLAY NAME"}
];

const body = JSON.stringify({
title: 'WebDev Update a Meeting w/ Simultaneous Interpretation', // String, Required | Meeting title. The title can be a maximum of 128 characters long.
agenda: 'This meeting\'s agenda includes discussing plans to incorporate new, extremely conductive copper alloys which create their own electro-magnetic fields. This meeting should be MARVELous! *wink*', // example of one of many options to update
password: meetingPassword, // String, Required
start: '2022-06-19T19:00:00Z', // String, Required | https://en.wikipedia.org/wiki/ISO_8601 format
end: '2022-06-19T21:00:00Z', // String, Required | Replace the start/end with the times you'd like
simultaneousInterpretation: {"enabled":true,"interpreters":interpreterAry}
});

const options = {
method: 'PUT', // https://en.wikipedia.org/wiki/Representational_state_transfer#Semantics_of_HTTP_methods
hostname: 'webexapis.com', // https://developer.webex.com/docs/basics
path: `/v1/meetings/${meetingID}`, // https://developer.webex.com/docs/meetings
port: 443, // https://en.wikipedia.org/wiki/HTTPS#Technical
headers: {
Authorization: `Bearer ${myWebexDeveloperToken}`, // https://oauth.net/2/bearer-tokens/
'Content-Type': 'application/json', // https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON
'Content-Length': body.length, // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Length
},
};

const req = https.request(options, (res) => {
console.log(`statusCode: ${res.statusCode}`); // https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

let data = '';

res.on('data', (chunk) => {
data += chunk;
});

res.on('end', () => {
console.log(JSON.parse(data)); // https://nodejs.org/en/knowledge/javascript-conventions/what-is-json/
});

res.on('error', (e) => {
console.error(`Error: ${e.message}`); // https://nodejs.org/api/errors.html#errormessage_1
});
});

req.on('error', (e) => {
console.error(e);
});

req.write(body);

req.end();

/**
* Expected output:
*
* The HTTPS request should receive a status code. We expect a 200.
*
* The body of the response is JSON text. We expect a single object
* containing details of the newly-created meeting. These details
* should include at least the following fields:
*
* - id
* - meetingNumber
* - title
* - password
* - phoneAndVideoSystemPassword
* - meetingType
* - state
* - timezone
* - start
* - end
* - hostUserId
* - hostDisplayName
* - hostEmail
* - hostKey
* - siteUrl
* - webLink
* - sipAddress
* - dialInIpAddress
* - enabledAutoRecordMeeting
* - allowAnyUserToBeCoHost
* - allowFirstUserToBeCoHost
* - allowAuthenticatedDevices
* - enabledJoinBeforeHost
* - joinBeforeHostMinutes
* - enableConnectAudioBeforeHost
* - excludePassword
* - publicMeeting
* - enableAutomaticLock
* - telephony
* - accessCode
* - callInNumbers
* - links
*
* An example of the response JSON may be found
* in this directory: ./example_response.json
*
*/