feat(virtualq/actions): add properties JSON field
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import isPlainObject from 'lodash/isPlainObject.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create waiter',
|
||||
@@ -97,6 +98,16 @@ export default defineAction({
|
||||
required: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Properties',
|
||||
key: 'properties',
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: false,
|
||||
valueType: 'parse',
|
||||
description: 'JSON for the additional properties.',
|
||||
value: '{}',
|
||||
},
|
||||
],
|
||||
async run($) {
|
||||
const {
|
||||
@@ -107,6 +118,7 @@ export default defineAction({
|
||||
appointment,
|
||||
appointmentTime,
|
||||
servicePhoneToCall,
|
||||
properties = {},
|
||||
} = $.step.parameters;
|
||||
|
||||
const body = {
|
||||
@@ -119,6 +131,7 @@ export default defineAction({
|
||||
source,
|
||||
appointment,
|
||||
servicePhoneToCall,
|
||||
properties,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -127,6 +140,12 @@ export default defineAction({
|
||||
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);
|
||||
|
||||
$.setActionItem({ raw: data });
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import isPlainObject from 'lodash/isPlainObject.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Update waiter',
|
||||
@@ -104,6 +105,15 @@ export default defineAction({
|
||||
required: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Properties',
|
||||
key: 'properties',
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: false,
|
||||
valueType: 'parse',
|
||||
description: 'JSON for the additional properties.',
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
@@ -117,6 +127,7 @@ export default defineAction({
|
||||
talkTime,
|
||||
agentId,
|
||||
servicePhoneToCall,
|
||||
properties,
|
||||
} = $.step.parameters;
|
||||
|
||||
const body = {
|
||||
@@ -150,6 +161,16 @@ export default defineAction({
|
||||
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);
|
||||
|
||||
$.setActionItem({ raw: data });
|
||||
|
||||
Reference in New Issue
Block a user