Skip to content

Commit

Permalink
Add WorkerSid as accepted param for getTaskQueues
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-murray-anz committed Nov 21, 2023
1 parent 701ac61 commit ba884fb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/Workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,5 @@ export default Workspace;
* @property {string} [AfterSid]
* @property {string} [FriendlyName]
* @property {"DateUpdated:asc" | "DateUpdated:desc"} [Ordering]
* @property {string} [WorkerSid]
*/
2 changes: 1 addition & 1 deletion lib/data/WorkspaceEntity.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export default class WorkspaceEntity {
PageSize: this._pageSize
};

const keys = ['AfterSid', 'FriendlyName', 'Ordering', 'NextToken'];
const keys = ['AfterSid', 'FriendlyName', 'Ordering', 'NextToken', 'WorkerSid'];
keys.forEach(key => {
if (args[key]) {
requestParam[key] = args[key];
Expand Down
26 changes: 24 additions & 2 deletions test/integration/spec/Workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ describe('Workspace', () => {
describe('#fetchTaskQueues', () => {
let taskQueueSids = [];

const createTaskQueues = async(friendlyNames = []) => {
const createTaskQueues = async(friendlyNames = [], targetWorkers = '1==1') => {
const taskQueueSids = [];
for (const name of friendlyNames) {
const queue = await envTwilio.createTaskQueue(workspace.workspaceSid, { friendlyName: name });
const queue = await envTwilio.createTaskQueue(workspace.workspaceSid, { friendlyName: name, targetWorkers });
taskQueueSids.push(queue.sid);
}

Expand Down Expand Up @@ -117,6 +117,28 @@ describe('Workspace', () => {
}
}).timeout(5000);

describe('WorkerSid filter', () => {
before(async() => {
await createTaskQueues(['notBob'], 'missingAttribute = "foo"');
});

it('should not filter by default', async() => {
const queuesMap = await workspace.fetchTaskQueues();
assert.equal(queuesMap.size, 4);
}).timeout(5000);

it('should filter by selected WorkerSid', async() => {
let workerSid = credentials.multiTaskBobSid;

const queuesMap = await workspace.fetchTaskQueues({ WorkerSid: workerSid });
assert.equal(queuesMap.size, 3);
}).timeout(5000);

after(async() => {
await deleteTaskQueues(['notBob']);
});
});

it('should paginate with ordering param', async() => {
workspace = new Workspace(adminToken, { ...options, pageSize: 1 });
const queuesMap = await workspace.fetchTaskQueues({ Ordering: 'DateUpdated:asc' });
Expand Down
1 change: 1 addition & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ type FetchTaskQueuesParams = {
AfterSid?: string;
FriendlyName?: string;
Ordering?: "DateUpdated:asc" | "DateUpdated:desc"
WorkerSid?: string;
}

type FetchWorkersParams = {
Expand Down

0 comments on commit ba884fb

Please sign in to comment.