From 48a3e606237326a9ada51004f425a64747ab5251 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Mon, 15 Mar 2021 11:57:10 -0600 Subject: [PATCH] Change env variables RC_* to RINGCENTRAL_* APP_KEY and APP_SECRET repalced with CLIENT_ID and CLIENT_SECRET to reflect RingCentral's descriptions Change RC_SANDBOX to RINGCENTRAL_SERVER and changed its behaviour. --- README.md | 15 ++++++++------- src/index.ts | 25 ++++++++++++++----------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 13ad088..e9e8cb9 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,15 @@ # Required API endpoint/authentication variables SONAR_URL=https://instance.sonar.software/api/graphql SONAR_TOKEN= -RC_APP_KEY= -RC_APP_SECRET= -RC_LOGIN_USERNAME= -RC_LOGIN_EXT= -RC_LOGIN_PASSWORD= +RINGCENTRAL_CLIENT_ID= +RINGCENTRAL_CLIENT_SECRET= +RINGCENTRAL_USERNAME= +RINGCENTRAL_EXTENSION= +RINGCENTRAL_PASSWORD= -# Set to any value to enable use of RingCentral's sandbox API -RC_SANDBOX= +# Set to 'sandbox' to use RingCentral's sandbox API +# Any other value will result in using RingCentral's production API +RINGCENTRAL_SERVER=production # The database to use # valid options: pg, sqlite diff --git a/src/index.ts b/src/index.ts index daab062..b34dd6c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,11 +9,11 @@ function checkEnv() { [ "SONAR_URL", "SONAR_TOKEN", - "RC_APP_KEY", - "RC_APP_SECRET", - "RC_LOGIN_USERNAME", - "RC_LOGIN_EXT", - "RC_LOGIN_PASSWORD", + "RINGCENTRAL_CLIENT_ID", + "RINGCENTRAL_CLIENT_SECRET", + "RINGCENTRAL_USERNAME", + "RINGCENTRAL_EXTENSION", + "RINGCENTRAL_PASSWORD", "EXTENSION_TICKET_GROUPS", ].forEach((env) => { if (process.env[env] === undefined) { @@ -65,16 +65,19 @@ async function initSonar() { async function initRingCentralSDK() { const sdk = new SDK({ - server: SDK.server[process.env.RC_SANDBOX ? "sandbox" : "production"], - clientId: process.env.RC_APP_KEY, - clientSecret: process.env.RC_APP_SECRET, + server: + SDK.server[ + process.env.RINGCENTRAL_SERVER === "sandbox" ? "sandbox" : "production" + ], + clientId: process.env.RINGCENTRAL_CLIENT_ID, + clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET, }); const login = () => sdk.login({ - username: process.env.RC_LOGIN_USERNAME, - extension: process.env.RC_LOGIN_EXT, - password: process.env.RC_LOGIN_PASSWORD, + username: process.env.RINGCENTRAL_USERNAME, + extension: process.env.RINGCENTRAL_EXTENSION, + password: process.env.RINGCENTRAL_PASSWORD, }); if (DEBUG) {