From 6f5c9f526a6803ef1a43a4f3b6047593e2bfe056 Mon Sep 17 00:00:00 2001 From: ntdoJanneck Date: Wed, 30 Oct 2024 11:20:57 +0100 Subject: [PATCH] feat(deliverybox-model): add pagination --- packages/models/src/mail/DeliveryBox/DeliveryBox.ts | 5 +++++ packages/models/src/mail/DeliveryBox/behaviors/api.ts | 3 ++- packages/models/src/mail/DeliveryBox/behaviors/types.ts | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/models/src/mail/DeliveryBox/DeliveryBox.ts b/packages/models/src/mail/DeliveryBox/DeliveryBox.ts index 13f1cd36..5f744f49 100644 --- a/packages/models/src/mail/DeliveryBox/DeliveryBox.ts +++ b/packages/models/src/mail/DeliveryBox/DeliveryBox.ts @@ -118,8 +118,13 @@ export class DeliveryBoxListQuery extends ListQueryModel { + const { ...query } = this.query; const { items, totalCount } = await config.behaviors.deliveryBox.query( this.project.id, + { + limit: config.defaultPaginationLimit, + ...query, + }, ); return new DeliveryBoxList( this.project, diff --git a/packages/models/src/mail/DeliveryBox/behaviors/api.ts b/packages/models/src/mail/DeliveryBox/behaviors/api.ts index 0f9b6c82..113fdb2f 100644 --- a/packages/models/src/mail/DeliveryBox/behaviors/api.ts +++ b/packages/models/src/mail/DeliveryBox/behaviors/api.ts @@ -15,9 +15,10 @@ export const apiDeliveryBoxBehaviors = ( } assertOneOfStatus(response, [404]); }, - query: async (projectId: string) => { + query: async (projectId: string, query = {}) => { const response = await client.mail.listDeliveryBoxes({ projectId, + queryParameters: query, }); assertStatus(response, 200); return { diff --git a/packages/models/src/mail/DeliveryBox/behaviors/types.ts b/packages/models/src/mail/DeliveryBox/behaviors/types.ts index b70e712b..f118c876 100644 --- a/packages/models/src/mail/DeliveryBox/behaviors/types.ts +++ b/packages/models/src/mail/DeliveryBox/behaviors/types.ts @@ -1,10 +1,15 @@ -import { DeliveryBoxData, DeliveryBoxListItemData } from "../types.js"; +import { + DeliveryBoxData, + DeliveryBoxListItemData, + DeliveryBoxListQueryData, +} from "../types.js"; import { QueryResponseData } from "../../../base/index.js"; export interface DeliveryBoxBehaviors { find: (deliveryBoxId: string) => Promise; query: ( projectId: string, + query?: DeliveryBoxListQueryData, ) => Promise>; create: (