allow 200 response to client.calls.update

This commit is contained in:
Dave Horton
2022-03-05 13:12:18 -05:00
parent b88e697d61
commit 847c3a4571
4 changed files with 6 additions and 5 deletions

View File

@@ -20,7 +20,7 @@ class Jambonz {
const headers = {'Authorization': `Bearer ${apiKey}`};
const post = bent(baseUrl, 'POST', 'json', headers, 201);
const put = bent(baseUrl, 'PUT', headers, 202, 204);
const put = bent(baseUrl, 'PUT', headers, 200, 202, 204);
const get = bent(baseUrl, 'GET', 'json', headers, 200);
const del = bent(baseUrl, 'DELETE', headers, 204);

View File

@@ -19,7 +19,7 @@ class RestEntity {
if (this.validators.update) this.validators.update(opts);
const res = await this.put(`Accounts/${this.accountSid}/${this.name}/${sid}`, opts);
if (res.statusCode === 404) throw new Error(`${this.name}.update: sid ${sid} not found`);
if (![202, 204].includes(res.statusCode)) {
if (![200, 202, 204].includes(res.statusCode)) {
throw new Error(`${this.name}.update: unexpected status code ${res.statusCode}`);
}
}

View File

@@ -85,8 +85,9 @@ const validateCallUpdate = (opts) => {
sip_request
} = opts;
assert.ok(call_hook || child_call_hook || call_status || listen_status || mute_status || whisper || conf_hold_status,
`calls.update: invalid request ${JSON.stringify(opts)}`);
assert.ok(call_hook || child_call_hook || call_status ||
listen_status || mute_status || whisper ||
conf_hold_status || sip_request, `calls.update: invalid request ${JSON.stringify(opts)}`);
if (call_status) assert.ok(['completed', 'no-answer'].includes(call_status),
`invalid call_status: ${call_status}, must be 'completed' or 'no-answer'`);

View File

@@ -1,6 +1,6 @@
{
"name": "@jambonz/node-client",
"version": "0.3.11",
"version": "0.3.12",
"description": "Node.js client for building jambonz applications (jambonz.org)",
"main": "lib/index.js",
"scripts": {