From 00328f5967222674721e9a5bf9cf77c27a4e670e Mon Sep 17 00:00:00 2001 From: jozanini Date: Tue, 31 May 2022 14:39:27 -0700 Subject: [PATCH 1/3] Simultatneous Interpretation code added for create --- meetings/create/create_si_meeting.js | 86 ++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 meetings/create/create_si_meeting.js diff --git a/meetings/create/create_si_meeting.js b/meetings/create/create_si_meeting.js new file mode 100644 index 0000000..864319d --- /dev/null +++ b/meetings/create/create_si_meeting.js @@ -0,0 +1,86 @@ +/** + * _ + * __ _____| |__ _____ __ + * \ \ /\ / / _ \ '_ \ / _ \ \/ / + * \ 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 + 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: + */ + \ No newline at end of file From eea1a6e142581be6cc1b8e1c2875a3a9de3cbe48 Mon Sep 17 00:00:00 2001 From: jozanini Date: Tue, 31 May 2022 15:04:11 -0700 Subject: [PATCH 2/3] added response data --- meetings/create/create_si_meeting.js | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/meetings/create/create_si_meeting.js b/meetings/create/create_si_meeting.js index 864319d..485fa5c 100644 --- a/meetings/create/create_si_meeting.js +++ b/meetings/create/create_si_meeting.js @@ -82,5 +82,55 @@ /** * Expected output: + * statusCode: 200 + * { + * id: 'd22a9f343201470f8443b0ab01c81855', + * meetingNumber: '25710538727', + * title: 'WebDev Meeting w/ Simultaneous Interpretation', + * password: 'x8YPCFimS73', + * phoneAndVideoSystemPassword: '98972346', + * meetingType: 'meetingSeries', + * state: 'active', + * timezone: 'UTC', + * start: '2022-08-12T17:51:00Z', + * end: '2022-08-12T18:38:00Z', + * hostUserId: 'Y2lzY29zcGFyazovL3VzL1BFT1BMRS9iMWQ4ZGQ2MC0yZDRjLTQxNmYtYWVkNS03NjQ2NjcxZTIwMzM', + * hostDisplayName: 'Joe Zanini', + * hostEmail: 'jozanini@cisco.com', + * hostKey: '154507', + * siteUrl: 'cisco.webex.com', + * webLink: 'https://cisco.webex.com/cisco/j.php?MTID=med3b9c0ae544ea8d015d2df2361ccc52', + * sipAddress: '25710538727@webex.com', + * dialInIpAddress: '173.243.2.68', + * enabledAutoRecordMeeting: false, + * allowAnyUserToBeCoHost: false, + * allowFirstUserToBeCoHost: false, + * allowAuthenticatedDevices: false, + * enabledJoinBeforeHost: true, + * joinBeforeHostMinutes: 5, + * enableConnectAudioBeforeHost: true, + * excludePassword: false, + * publicMeeting: false, + * enableAutomaticLock: false, + * unlockedMeetingJoinSecurity: 'allowJoin', + * telephony: { + * accessCode: '25710538727', + * callInNumbers: [ [Object] ], + * links: [ [Object] ] + * }, + * meetingOptions: { + * enabledChat: true, + * enabledVideo: true, + * enabledPolling: false, + * enabledNote: true, + * noteType: 'allowAll', + * enabledClosedCaptions: false, + * enabledFileTransfer: true, + * enabledUCFRichMedia: true + * }, + * sessionTypeId: 159, + * scheduledType: 'meeting', + * simultaneousInterpretation: { enabled: true, interpreters: [ [Object], [Object] ] } + * } */ \ No newline at end of file From 88f092def73db794f016a55f2bba388921900d8f Mon Sep 17 00:00:00 2001 From: jozanini Date: Tue, 31 May 2022 15:22:18 -0700 Subject: [PATCH 3/3] update meeting with Simultaneous Interpretation --- meetings/create/create_si_meeting.js | 97 +++++++++---------- meetings/update/update_si_meeting.js | 135 +++++++++++++++++++++++++++ 2 files changed, 180 insertions(+), 52 deletions(-) create mode 100644 meetings/update/update_si_meeting.js diff --git a/meetings/create/create_si_meeting.js b/meetings/create/create_si_meeting.js index 485fa5c..b788924 100644 --- a/meetings/create/create_si_meeting.js +++ b/meetings/create/create_si_meeting.js @@ -81,56 +81,49 @@ req.end(); /** - * Expected output: - * statusCode: 200 - * { - * id: 'd22a9f343201470f8443b0ab01c81855', - * meetingNumber: '25710538727', - * title: 'WebDev Meeting w/ Simultaneous Interpretation', - * password: 'x8YPCFimS73', - * phoneAndVideoSystemPassword: '98972346', - * meetingType: 'meetingSeries', - * state: 'active', - * timezone: 'UTC', - * start: '2022-08-12T17:51:00Z', - * end: '2022-08-12T18:38:00Z', - * hostUserId: 'Y2lzY29zcGFyazovL3VzL1BFT1BMRS9iMWQ4ZGQ2MC0yZDRjLTQxNmYtYWVkNS03NjQ2NjcxZTIwMzM', - * hostDisplayName: 'Joe Zanini', - * hostEmail: 'jozanini@cisco.com', - * hostKey: '154507', - * siteUrl: 'cisco.webex.com', - * webLink: 'https://cisco.webex.com/cisco/j.php?MTID=med3b9c0ae544ea8d015d2df2361ccc52', - * sipAddress: '25710538727@webex.com', - * dialInIpAddress: '173.243.2.68', - * enabledAutoRecordMeeting: false, - * allowAnyUserToBeCoHost: false, - * allowFirstUserToBeCoHost: false, - * allowAuthenticatedDevices: false, - * enabledJoinBeforeHost: true, - * joinBeforeHostMinutes: 5, - * enableConnectAudioBeforeHost: true, - * excludePassword: false, - * publicMeeting: false, - * enableAutomaticLock: false, - * unlockedMeetingJoinSecurity: 'allowJoin', - * telephony: { - * accessCode: '25710538727', - * callInNumbers: [ [Object] ], - * links: [ [Object] ] - * }, - * meetingOptions: { - * enabledChat: true, - * enabledVideo: true, - * enabledPolling: false, - * enabledNote: true, - * noteType: 'allowAll', - * enabledClosedCaptions: false, - * enabledFileTransfer: true, - * enabledUCFRichMedia: true - * }, - * sessionTypeId: 159, - * scheduledType: 'meeting', - * simultaneousInterpretation: { enabled: true, interpreters: [ [Object], [Object] ] } - * } - */ + * 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 + * + */ \ No newline at end of file diff --git a/meetings/update/update_si_meeting.js b/meetings/update/update_si_meeting.js new file mode 100644 index 0000000..540da5c --- /dev/null +++ b/meetings/update/update_si_meeting.js @@ -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 + * + */ + \ No newline at end of file