Skip to content

Commit

Permalink
feat(deliverybox-model): add pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
ntdoJanneck committed Nov 4, 2024
1 parent ad7311d commit 6f5c9f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/models/src/mail/DeliveryBox/DeliveryBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,13 @@ export class DeliveryBoxListQuery extends ListQueryModel<DeliveryBoxListQueryMod
}

public execute = provideReact(async () => {
const { ...query } = this.query;
const { items, totalCount } = await config.behaviors.deliveryBox.query(
this.project.id,
{
limit: config.defaultPaginationLimit,
...query,
},
);
return new DeliveryBoxList(
this.project,
Expand Down
3 changes: 2 additions & 1 deletion packages/models/src/mail/DeliveryBox/behaviors/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion packages/models/src/mail/DeliveryBox/behaviors/types.ts
Original file line number Diff line number Diff line change
@@ -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<DeliveryBoxData | undefined>;
query: (
projectId: string,
query?: DeliveryBoxListQueryData,
) => Promise<QueryResponseData<DeliveryBoxListItemData>>;

create: (
Expand Down

0 comments on commit 6f5c9f5

Please sign in to comment.