Merge pull request #2315 from automatisch/add-properties-field-in-virtualq
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 = {
|
||||||
@@ -118,7 +130,8 @@ export default defineAction({
|
|||||||
channel,
|
channel,
|
||||||
source,
|
source,
|
||||||
appointment,
|
appointment,
|
||||||
servicePhoneToCall,
|
service_phone_to_call: 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',
|
||||||
@@ -49,7 +50,7 @@ export default defineAction({
|
|||||||
description: 'Used to find caller if 0 is used for waiter field',
|
description: 'Used to find caller if 0 is used for waiter field',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'EWT',
|
label: 'Estimated waiting time',
|
||||||
key: 'serviceWaiterEwt',
|
key: 'serviceWaiterEwt',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'EWT as calculated by the service',
|
description: 'EWT as calculated by the service',
|
||||||
@@ -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 });
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ export default defineApp({
|
|||||||
iconUrl: '{BASE_URL}/apps/virtualq/assets/favicon.svg',
|
iconUrl: '{BASE_URL}/apps/virtualq/assets/favicon.svg',
|
||||||
authDocUrl: '{DOCS_URL}/apps/virtualq/connection',
|
authDocUrl: '{DOCS_URL}/apps/virtualq/connection',
|
||||||
supportsConnections: true,
|
supportsConnections: true,
|
||||||
baseUrl: 'https://www.virtualq.io',
|
baseUrl: 'https://www.virtualq.tech',
|
||||||
apiBaseUrl: 'https://api.virtualq.io/api/',
|
apiBaseUrl: 'https://api.virtualq.tech/api/',
|
||||||
primaryColor: '#2E3D59',
|
primaryColor: '#2E3D59',
|
||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
|
|||||||
@@ -51,8 +51,6 @@ export const processAction = async (options) => {
|
|||||||
const shouldNotConsiderAsError = shouldEarlyExit || shouldNotProcess;
|
const shouldNotConsiderAsError = shouldEarlyExit || shouldNotProcess;
|
||||||
|
|
||||||
if (!shouldNotConsiderAsError) {
|
if (!shouldNotConsiderAsError) {
|
||||||
logger.error(error);
|
|
||||||
|
|
||||||
if (error instanceof HttpError) {
|
if (error instanceof HttpError) {
|
||||||
$.actionOutput.error = error.details;
|
$.actionOutput.error = error.details;
|
||||||
} else {
|
} else {
|
||||||
@@ -62,6 +60,8 @@ export const processAction = async (options) => {
|
|||||||
$.actionOutput.error = { error: error.message };
|
$.actionOutput.error = { error: error.message };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ export const processFlow = async (options) => {
|
|||||||
const shouldNotConsiderAsError = shouldEarlyExit || shouldNotProcess;
|
const shouldNotConsiderAsError = shouldEarlyExit || shouldNotProcess;
|
||||||
|
|
||||||
if (!shouldNotConsiderAsError) {
|
if (!shouldNotConsiderAsError) {
|
||||||
logger.error(error);
|
|
||||||
|
|
||||||
if (error instanceof HttpError) {
|
if (error instanceof HttpError) {
|
||||||
$.triggerOutput.error = error.details;
|
$.triggerOutput.error = error.details;
|
||||||
} else {
|
} else {
|
||||||
@@ -42,6 +40,8 @@ export const processFlow = async (options) => {
|
|||||||
$.triggerOutput.error = { error: error.message };
|
$.triggerOutput.error = { error: error.message };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user