-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: updated conversation snippets
- Loading branch information
Showing
21 changed files
with
137 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_APPLICATION_PRIVATE_KEY_PATH = __dirname +'/../../'+ process.env.VONAGE_APPLICATION_PRIVATE_KEY_PATH; | ||
const CONVERSATION_ID = process.env.CONVERSATION_ID; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const VONAGE_PRIVATE_KEY = __dirname +'/../../'+ process.env.VONAGE_PRIVATE_KEY; | ||
const CONV_ID = process.env.CONV_ID; | ||
|
||
const vonage = new Vonage({ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}); | ||
|
||
vonage.conversations.deleteConversation(CONVERSATION_ID) | ||
vonage.conversations.deleteConversation(CONV_ID) | ||
.then(() => console.log('Conversation deleted')) | ||
.catch((error) => console.error(error)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_APPLICATION_PRIVATE_KEY_PATH = __dirname +'/../../'+ process.env.VONAGE_APPLICATION_PRIVATE_KEY_PATH; | ||
const CONVERSATION_ID = process.env.CONVERSATION_ID; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const VONAGE_PRIVATE_KEY = __dirname +'/../../'+ process.env.VONAGE_PRIVATE_KEY; | ||
const CONV_ID = process.env.CONV_ID; | ||
|
||
const vonage = new Vonage({ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}); | ||
|
||
vonage.conversations.getConversation(CONVERSATION_ID) | ||
vonage.conversations.getConversation(CONV_ID) | ||
.then((conversation) => console.log(conversation)) | ||
.catch((error) => console.error(error)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,36 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_APPLICATION_PRIVATE_KEY_PATH = __dirname +'/../../'+ process.env.VONAGE_APPLICATION_PRIVATE_KEY_PATH; | ||
const CONV_NEW_NAME = process.env.CONV_NEW_NAME; | ||
const CONV_NEW_DISPLAY_NAME = process.env.CONV_NEW_DISPLAY_NAME; | ||
const VONAGE_PRIVATE_KEY = __dirname +'/../../'+ process.env.VONAGE_PRIVATE_KEY; | ||
const CONV_NAME = process.env.CONV_NAME; | ||
const CONV_DISPLAY_NAME = process.env.CONV_DISPLAY_NAME; | ||
const CONVERSATION_ID = process.env.CONVERSATION_ID; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
|
||
const vonage = new Vonage({ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}); | ||
|
||
const run = async () => { | ||
// Load the conversation to prevent overwriting | ||
const conversation = await vonage.conversations.getConversation(CONVERSATION_ID); | ||
conversation.name = CONV_NEW_NAME; | ||
conversation.displayName = CONV_NEW_DISPLAY_NAME; | ||
await vonage.conversations.update(conversation); | ||
let conversation; | ||
try { | ||
// Load the conversation to prevent overwriting | ||
conversation= await vonage.conversations.getConversation(CONVERSATION_ID); | ||
} catch (error) { | ||
console.error('Error loading conversation', error); | ||
return; | ||
} | ||
|
||
conversation.name = CONV_NAME; | ||
conversation.displayName = CONV_DISPLAY_NAME; | ||
|
||
try { | ||
await vonage.conversations.update(conversation); | ||
console.log('Conversation updated'); | ||
} catch (error) { | ||
console.error('Error updating conversation', error); | ||
} | ||
}; | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_APPLICATION_PRIVATE_KEY_PATH = __dirname + '/../../' + process.env.VONAGE_APPLICATION_PRIVATE_KEY_PATH; | ||
const CONVERSATION_ID = process.env.CONVERSATION_ID; | ||
const EVENT_ID = process.env.EVENT_ID; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const VONAGE_PRIVATE_KEY = __dirname + '/../../' + process.env.VONAGE_PRIVATE_KEY; | ||
const CONV_ID = process.env.CONV_ID; | ||
const CONV_EVENT_ID = process.env.CONV_EVENT_ID; | ||
|
||
const vonage = new Vonage({ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}); | ||
|
||
vonage.conversations.deleteEvent(CONVERSATION_ID, EVENT_ID) | ||
vonage.conversations.deleteEvent(CONV_ID, CONV_EVENT_ID) | ||
.then(() => console.log('Event deleted')) | ||
.catch((error) => console.error(error)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_APPLICATION_PRIVATE_KEY_PATH = __dirname + '/../../' + process.env.VONAGE_APPLICATION_PRIVATE_KEY_PATH; | ||
const CONVERSATION_ID = process.env.CONVERSATION_ID; | ||
const EVENT_ID = process.env.EVENT_ID; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const VONAGE_PRIVATE_KEY = __dirname + '/../../' + process.env.VONAGE_PRIVATE_KEY; | ||
const CONV_ID = process.env.CONV_ID; | ||
const CONV_EVENT_ID = process.env.CONV_EVENT_ID; | ||
|
||
const vonage = new Vonage({ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}); | ||
|
||
vonage.conversations.getEvent(CONVERSATION_ID, EVENT_ID) | ||
vonage.conversations.getEvent(CONV_ID, CONV_EVENT_ID) | ||
.then((event) => console.log(event)) | ||
.catch((error) => console.error(error)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_APPLICATION_PRIVATE_KEY_PATH = __dirname + '/../../' + process.env.VONAGE_APPLICATION_PRIVATE_KEY_PATH; | ||
const CONVERSATION_ID = process.env.CONVERSATION_ID; | ||
const MEMBER_ID = process.env.MEMBER_ID; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const VONAGE_PRIVATE_KEY = __dirname + '/../../' + process.env.VONAGE_PRIVATE_KEY; | ||
const CONV_ID = process.env.CONV_ID; | ||
const CONV_MEMBER_ID = process.env.CONV_MEMBER_ID; | ||
|
||
const vonage = new Vonage({ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}); | ||
|
||
vonage.conversations.deleteMember( | ||
CONVERSATION_ID, | ||
MEMBER_ID, | ||
CONV_ID, | ||
CONV_MEMBER_ID, | ||
) | ||
.then(() => console.log('Memeber deleted')) | ||
.catch((error) => console.error(error)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_APPLICATION_PRIVATE_KEY_PATH = __dirname +'/../../'+ process.env.VONAGE_APPLICATION_PRIVATE_KEY_PATH; | ||
const CONVERSATION_ID = process.env.CONVERSATION_ID; | ||
const MEMBER_ID = process.env.MEMBER_ID; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const VONAGE_PRIVATE_KEY = __dirname +'/../../'+ process.env.VONAGE_PRIVATE_KEY; | ||
const CONV_ID = process.env.CONV_ID; | ||
const CONV_MEMBER_ID = process.env.CONV_MEMBER_ID; | ||
|
||
const vonage = new Vonage({ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}); | ||
|
||
vonage.conversations.getMember(CONVERSATION_ID, MEMBER_ID) | ||
vonage.conversations.getMember(CONV_ID, CONV_MEMBER_ID) | ||
.then((member) => console.log(member)) | ||
.catch((error) => console.log(error)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.