mirror of
https://github.com/jambonz/jambonz-node.git
synced 2025-12-19 05:17:49 +00:00
allow 200 response to client.calls.update
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'`);
|
||||
|
||||
Reference in New Issue
Block a user