The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/tests/data/livechat/inquiries.ts

31 lines
902 B

import type { ILivechatInquiryRecord } from '@rocket.chat/core-typings';
import type { PaginatedResult } from '@rocket.chat/rest-typings';
import { api, request } from '../api-data';
export const fetchAllInquiries = async (credentials: { 'X-Auth-Token': string; 'X-User-Id': string; }, department?: string): Promise<ILivechatInquiryRecord[]> => {
const inquiries: ILivechatInquiryRecord[] = [];
let hasMore = true;
let offset = 0;
while (hasMore) {
const { body } = (await request
.get(api('livechat/inquiries.queuedForUser'))
.set(credentials)
.query({
...(department && { department }),
offset,
})
.expect('Content-Type', 'application/json')
.expect(200)) as { body: PaginatedResult<{ inquiries: Array<ILivechatInquiryRecord> }> };
inquiries.push(...body.inquiries);
hasMore = body.total > inquiries.length;
offset += body.count;
}
return inquiries;
}