mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2025-12-19 05:47:46 +00:00
add new /Callcount endpoint (#480)
* add new /Callcount endpoint * update db-helpers * update endpoint
This commit is contained in:
6
app.js
6
app.js
@@ -48,7 +48,8 @@ const {
|
||||
retrieveKey,
|
||||
deleteKey,
|
||||
incrKey,
|
||||
listConferences
|
||||
listConferences,
|
||||
getCallCount
|
||||
} = require('./lib/helpers/realtimedb-helpers');
|
||||
const {
|
||||
getTtsVoices,
|
||||
@@ -118,7 +119,8 @@ app.locals = {
|
||||
queryAlertsSP,
|
||||
writeCdrs,
|
||||
writeAlerts,
|
||||
AlertType
|
||||
AlertType,
|
||||
getCallCount
|
||||
};
|
||||
|
||||
const unless = (paths, middleware) => {
|
||||
|
||||
@@ -13,7 +13,8 @@ const {
|
||||
deleteKey,
|
||||
incrKey,
|
||||
client: redisClient,
|
||||
listConferences
|
||||
listConferences,
|
||||
getCallCount
|
||||
} = require('@jambonz/realtimedb-helpers')({}, logger);
|
||||
|
||||
module.exports = {
|
||||
@@ -29,5 +30,6 @@ module.exports = {
|
||||
deleteKey,
|
||||
redisClient,
|
||||
incrKey,
|
||||
listConferences
|
||||
listConferences,
|
||||
getCallCount
|
||||
};
|
||||
|
||||
@@ -1220,4 +1220,23 @@ router.get('/:sid/Conferences', async(req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* retrieve counts of calls under an account
|
||||
*/
|
||||
router.get('/:sid/CallCount', async(req, res) => {
|
||||
const {logger, getCallCount} = req.app.locals;
|
||||
try {
|
||||
const accountSid = parseAccountSid(req);
|
||||
await validateRequest(req, accountSid);
|
||||
const count = await getCallCount(accountSid);
|
||||
count.outbound = Number(count.outbound);
|
||||
count.inbound = Number(count.inbound);
|
||||
logger.debug(`retrieved, outbound: ${count.outbound}, inbound: ${count.inbound}, for account sid ${accountSid}`);
|
||||
res.status(200).json(count);
|
||||
updateLastUsed(logger, accountSid, req).catch((err) => {});
|
||||
} catch (err) {
|
||||
sysError(logger, res, err);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -19,7 +19,7 @@
|
||||
"@jambonz/db-helpers": "^0.9.12",
|
||||
"@jambonz/lamejs": "^1.2.2",
|
||||
"@jambonz/mw-registrar": "^0.2.7",
|
||||
"@jambonz/realtimedb-helpers": "^0.8.14",
|
||||
"@jambonz/realtimedb-helpers": "^0.8.15",
|
||||
"@jambonz/speech-utils": "^0.2.13",
|
||||
"@jambonz/time-series": "^0.2.8",
|
||||
"@jambonz/verb-specifications": "^0.0.107",
|
||||
@@ -4145,9 +4145,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@jambonz/realtimedb-helpers": {
|
||||
"version": "0.8.14",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.8.14.tgz",
|
||||
"integrity": "sha512-KW+5f7Tlmx6WQjD2m1TBD3dEOPGhAhVespgy4OlevoXuLK1XGFSpArFePWmMfrOfrQCnFvpQY8A1njmK9TezSg==",
|
||||
"version": "0.8.15",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.8.15.tgz",
|
||||
"integrity": "sha512-gGQrUL9eHO+Gx2nSphl6/GwCo1Vui3GfKvjUYrxxicGPFDV+m8UMvWPKfgL9xHa3GIwGGDGeGDj5jJf77/RT9A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4",
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"@jambonz/db-helpers": "^0.9.12",
|
||||
"@jambonz/lamejs": "^1.2.2",
|
||||
"@jambonz/mw-registrar": "^0.2.7",
|
||||
"@jambonz/realtimedb-helpers": "^0.8.14",
|
||||
"@jambonz/realtimedb-helpers": "^0.8.15",
|
||||
"@jambonz/speech-utils": "^0.2.13",
|
||||
"@jambonz/time-series": "^0.2.8",
|
||||
"@jambonz/verb-specifications": "^0.0.107",
|
||||
|
||||
Reference in New Issue
Block a user