feat(virtualq/actions): add properties JSON field
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import defineAction from '../../../../helpers/define-action.js';
|
import defineAction from '../../../../helpers/define-action.js';
|
||||||
|
import isPlainObject from 'lodash/isPlainObject.js';
|
||||||
|
|
||||||
export default defineAction({
|
export default defineAction({
|
||||||
name: 'Create waiter',
|
name: 'Create waiter',
|
||||||
@@ -97,6 +98,16 @@ export default defineAction({
|
|||||||
required: false,
|
required: false,
|
||||||
variables: true,
|
variables: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Properties',
|
||||||
|
key: 'properties',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
variables: false,
|
||||||
|
valueType: 'parse',
|
||||||
|
description: 'JSON for the additional properties.',
|
||||||
|
value: '{}',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
async run($) {
|
async run($) {
|
||||||
const {
|
const {
|
||||||
@@ -107,6 +118,7 @@ export default defineAction({
|
|||||||
appointment,
|
appointment,
|
||||||
appointmentTime,
|
appointmentTime,
|
||||||
servicePhoneToCall,
|
servicePhoneToCall,
|
||||||
|
properties = {},
|
||||||
} = $.step.parameters;
|
} = $.step.parameters;
|
||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
@@ -119,6 +131,7 @@ export default defineAction({
|
|||||||
source,
|
source,
|
||||||
appointment,
|
appointment,
|
||||||
servicePhoneToCall,
|
servicePhoneToCall,
|
||||||
|
properties,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -127,6 +140,12 @@ export default defineAction({
|
|||||||
body.data.attributes.appointmentTime = appointmentTime;
|
body.data.attributes.appointmentTime = appointmentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isPlainObject(properties)) {
|
||||||
|
throw new Error(
|
||||||
|
`The "properties" field must have a valid JSON. The current value: ${properties}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const { data } = await $.http.post('/v2/waiters', body);
|
const { data } = await $.http.post('/v2/waiters', body);
|
||||||
|
|
||||||
$.setActionItem({ raw: data });
|
$.setActionItem({ raw: data });
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import defineAction from '../../../../helpers/define-action.js';
|
import defineAction from '../../../../helpers/define-action.js';
|
||||||
|
import isPlainObject from 'lodash/isPlainObject.js';
|
||||||
|
|
||||||
export default defineAction({
|
export default defineAction({
|
||||||
name: 'Update waiter',
|
name: 'Update waiter',
|
||||||
@@ -104,6 +105,15 @@ export default defineAction({
|
|||||||
required: false,
|
required: false,
|
||||||
variables: true,
|
variables: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Properties',
|
||||||
|
key: 'properties',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
variables: false,
|
||||||
|
valueType: 'parse',
|
||||||
|
description: 'JSON for the additional properties.',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
async run($) {
|
async run($) {
|
||||||
@@ -117,6 +127,7 @@ export default defineAction({
|
|||||||
talkTime,
|
talkTime,
|
||||||
agentId,
|
agentId,
|
||||||
servicePhoneToCall,
|
servicePhoneToCall,
|
||||||
|
properties,
|
||||||
} = $.step.parameters;
|
} = $.step.parameters;
|
||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
@@ -150,6 +161,16 @@ export default defineAction({
|
|||||||
body.data.attributes.wait_time_when_up = waitTimeWhenUp;
|
body.data.attributes.wait_time_when_up = waitTimeWhenUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (properties) {
|
||||||
|
if (!isPlainObject(properties)) {
|
||||||
|
throw new Error(
|
||||||
|
`The "properties" field must have a valid JSON. The current value: ${properties}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.data.attributes.properties = properties;
|
||||||
|
}
|
||||||
|
|
||||||
const { data } = await $.http.put(`/v2/waiters/${waiterId}`, body);
|
const { data } = await $.http.put(`/v2/waiters/${waiterId}`, body);
|
||||||
|
|
||||||
$.setActionItem({ raw: data });
|
$.setActionItem({ raw: data });
|
||||||
|
|||||||
Reference in New Issue
Block a user