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
// Builds the url: '/account/~/extension/~', and make a PUT request to it | |
rc.account().extension().put({ status: "Enabled" }).then(function () { | |
console.log("Success to update extension."); | |
}).catch(function () { | |
console.error("Fail to update extension."); | |
}); |
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
// Builds the url: '/account/theAccountId/extension', and make a GET request to it | |
rc.account("theAccountId").extension().list().then(function (extensions) { | |
console.log("The list of extension info", extensions.records); | |
}).catch(function (e) { | |
console.error("Get extension list error", e); | |
}); |
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
// Builds the url: '/account/~/extension/theExtensionId', and make a GET request to it | |
rc.account().extension('theExtensionId').get().then(function (extInfo) { | |
console.log("The extension info", extInfo); | |
}).catch(function (e) { | |
console.error("Get extension error", e); | |
}); |
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
import * as fs from "fs"; | |
// Builds the url: '/account/~/extension/~/fax', and make a POST request to it | |
rc.account().extension().fax().post({ | |
to: [{ phoneNumber: "{receiverPhoneNumber}" }], | |
faxResolution: 'High' | |
}, [ // Second argument is an array of attachments, attachment can be string, Blob, node readable stream. | |
"{Message text}", | |
fs.createReadStream("{filePath}") // In node only | |
]); |
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
// Builds the url: '/account/~/extension/~/sms', and make a POST request to it | |
rc.account().extension().sms().post({ | |
to: [{ | |
phoneNumber: "{receiverPhoneNumber}" | |
}], | |
from: { | |
phoneNumber: "{yourSmsNumber}" | |
}, | |
text: "Sms content" | |
}).then(function (messageInfo) { |
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
let dateFrom = new Date(Date.now() - 24 * 60 * 60 * 1000); // A day ago | |
// Builds the url: '/account/~/extension/~/call-log/', and make a GET request to it | |
rc.account().extension().callLog().list({ dateFrom: dateFrom.toISOString() }).then(results => { | |
console.log("Recent call logs", results.records); | |
}, e => { | |
console.error("Fail to get call logs", e); | |
}); |
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
// Builds the url: '/account/~/extension/~/active-calls/', and make a GET request to it | |
rc.account().extension().activeCalls().list({ | |
page: 1, // Get the 1st page of the result | |
direction: "Inbound" // Specify the direction of the call, omit to get all directions | |
}).then(results => { | |
console.log("Active calls", results.records); | |
}, e => { | |
console.error("Fail to get active calls", e); | |
}); |
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
let subscription = rc.createSubscription(); | |
subscription.onMessage(msg => { | |
let presenceEvt = msg.body; | |
console.log('>> telephonyStatus', presenceEvt.telephonyStatus); | |
console.log('>> activeCalls', presenceEvt.activeCalls); | |
console.log('@@ presence event', presenceEvt); | |
}); | |
subscription.subscribe(['/account/~/extension/~/presence?detailedTelephonyState=true']) | |
.then(subscription => { | |
console.log('Subscription created', subscription); |
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
// Builds the url: '/account/~/extension/~/ringout', and make a POST request to it | |
rc.account().extension().ringout().post({ | |
from: { phoneNumber: 'xxx' }, | |
to: { phoneNumber: 'xxx' }, | |
callerId: { phoneNumber: 'xxx' } | |
}).then(ringout => { | |
console.log('Ringout sucess', ringout); | |
// To check the call status: `rc.account().extension().ringout(ringout.id).get();` | |
}, e => { | |
console.error('Fail to ringout', e); |
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
subscription.subscribe(['/account/~/extension/~/presence?detailedTelephonyState=true']).then(subscription => { | |
console.log('Subscribe successfully.'); | |
}, e => { | |
console.error('Fail to subscribe', e); | |
}); |
NewerOlder