support filtering for retrieve info endpoint (#153)

* support filtering for retrieve info endpoint

* bump realtimedb-helpers
This commit is contained in:
Anton Voylenko
2023-04-19 14:33:24 +03:00
committed by GitHub
parent 5b1b50c3a3
commit af3d03bef9
4 changed files with 53 additions and 10 deletions

View File

@@ -737,11 +737,17 @@ router.post('/:sid/Calls', async(req, res) => {
*/
router.get('/:sid/Calls', async(req, res) => {
const {logger, listCalls} = req.app.locals;
const {direction, from, to, callStatus} = req.query || {};
try {
const accountSid = parseAccountSid(req);
await validateRequest(req, accountSid);
const calls = await listCalls(accountSid);
const calls = await listCalls({
accountSid,
direction,
from,
to,
callStatus
});
logger.debug(`retrieved ${calls.length} calls for account sid ${accountSid}`);
res.status(200).json(coerceNumbers(snakeCase(calls)));
updateLastUsed(logger, accountSid, req).catch((err) => {});

View File

@@ -3793,6 +3793,43 @@ paths:
required: true
schema:
type: string
- in: query
name: direction
required: false
schema:
type: string
enum:
- inbound
- outbound
description: call direction to retrieve
- in: query
name: from
required: false
schema:
type: string
description: calling number to retrieve
- in: query
name: to
required: false
schema:
type: string
description: called number to retrieve
- in: query
name: callStatus
required: false
schema:
type: string
enum:
- trying
- ringing
- early-media
- in-progress
- completed
- failed
- busy
- no-answer
- queued
description: call status to retrieve
responses:
200:
description: list of calls for a specified account