Skip to content

Commit

Permalink
Tests. Simplified transitionAgentParticipants logic, updated to jest 29.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenhand committed Jun 12, 2024
1 parent a87f5cb commit 5b0f4a0
Show file tree
Hide file tree
Showing 4 changed files with 1,846 additions and 1,665 deletions.
14 changes: 7 additions & 7 deletions functions/interaction/transitionAgentParticipants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export const handler = TokenValidator(
if (!targetStatus) return resolve(error400('targetStatus'));

const client = context.getTwilioClient();
const task = await client.taskrouter
.workspaces(context.TWILIO_WORKSPACE_SID)
.tasks(taskSid)
const task = await client.taskrouter.workspaces
.get(context.TWILIO_WORKSPACE_SID)
.tasks.get(taskSid)
.fetch();
const { flexInteractionSid, flexInteractionChannelSid } = JSON.parse(task.attributes);

Expand All @@ -68,9 +68,9 @@ export const handler = TokenValidator(
),
);
}
const interactionParticipantContext = client.flexApi.v1
.interaction(flexInteractionSid)
.channels(flexInteractionChannelSid).participants;
const interactionParticipantContext = client.flexApi.v1.interaction
.get(flexInteractionSid)
.channels.get(flexInteractionChannelSid).participants;
const interactionAgentParticipants = (await interactionParticipantContext.list()).filter(
(p) => p.type === 'agent',
);
Expand All @@ -83,7 +83,7 @@ export const handler = TokenValidator(
p.interactionSid,
p.channelSid,
);
return interactionParticipantContext(p.sid).update({ status: targetStatus });
return p.update({ status: targetStatus });
}),
);
return resolve(success({ message: 'Transitioned agent participants' }));
Expand Down
Loading

0 comments on commit 5b0f4a0

Please sign in to comment.