diff --git a/lib/session/call-info.js b/lib/session/call-info.js index f15c1765..01a6bf09 100644 --- a/lib/session/call-info.js +++ b/lib/session/call-info.js @@ -144,6 +144,9 @@ class CallInfo { if (typeof this.duration === 'number') obj.duration = this.duration; if (this._customerData) { + Object.assign(obj, {customerData: this._customerData}); + // Duplicate customer data here to respect API contract that was created by bug + //https://github.com/jambonz/jambonz-feature-server/issues/406 Object.assign(obj, {customerdata: this._customerData}); } diff --git a/lib/utils/http-requestor.js b/lib/utils/http-requestor.js index 4e523605..877bf37e 100644 --- a/lib/utils/http-requestor.js +++ b/lib/utils/http-requestor.js @@ -87,7 +87,7 @@ class HttpRequestor extends BaseRequestor { assert(HookMsgTypes.includes(type)); - const payload = params ? snakeCaseKeys(params, ['customerdata', 'sip']) : null; + const payload = params ? snakeCaseKeys(params, ['customerdata', 'customerData', 'sip']) : null; const url = hook.url || hook; const method = hook.method || 'POST'; let buf = ''; diff --git a/test/create-call-test.js b/test/create-call-test.js index 7de8cd4d..d8147f56 100644 --- a/test/create-call-test.js +++ b/test/create-call-test.js @@ -114,10 +114,14 @@ test('test create-call call-hook basic authentication', async(t) => { 'create-call: call-hook contains basic authentication header'); t.ok(obj.body.customerdata.callCount === 10, 'create-call: call-hook contains correct format for customerData'); + t.ok(obj.body.customerData.callCount === 10, + 'create-call: call-hook contains correct format for customerData'); obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}_callStatus`); t.ok(obj.body.customerdata.callCount === 10, - 'create-call: call-hook contains correct format for customerData'); + 'create-call: status-hook contains correct format for customerData'); + t.ok(obj.body.customerData.callCount === 10, + 'create-call: status-hook contains correct format for customerData'); disconnect(); } catch (err) { console.log(`error received: ${err}`);