Skip to content

Commit

Permalink
feat: Added new query methods to listing files
Browse files Browse the repository at this point in the history
  • Loading branch information
stevedylandev committed Sep 11, 2024
1 parent 697bf90 commit 58cf7d0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/core/files/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,15 @@ export const listFiles = async (
const params = new URLSearchParams();

if (options) {
const { limit, pageToken, cidPending } = options;
const { name, group, cid, order, limit, mimeType, pageToken, cidPending } =
options;

if (limit) params.append("limit", limit.toString());
if (name) params.append("name", name);
if (group) params.append("group", group);
if (cid) params.append("cid", cid);
if (mimeType) params.append("mimeType", mimeType);
if (order) params.append("order", order);
if (pageToken) params.append("pageToken", pageToken);
if (cidPending) params.append("cidPending", "true");
}
Expand Down
25 changes: 25 additions & 0 deletions src/core/pinataSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,31 @@ class FilterFiles {
this.config = config;
}

name(name: string): FilterFiles {
this.query.name = name;
return this;
}

group(group: string): FilterFiles {
this.query.group = group;
return this;
}

cid(cid: string): FilterFiles {
this.query.cid = cid;
return this;
}

mimeType(mimeType: string): FilterFiles {
this.query.mimeType = mimeType;
return this;
}

order(order: "ASC" | "DESC"): FilterFiles {
this.query.order = order;
return this;
}

limit(limit: number): FilterFiles {
this.query.limit = limit;
return this;
Expand Down
7 changes: 6 additions & 1 deletion src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ export type FileListResponse = {
};

export type FileListQuery = {
name?: string;
group?: string;
mimeType?: string;
cid?: string;
cidPending?: boolean;
order?: "ASC" | "DESC";
limit?: number;
pageToken?: string;
cidPending?: boolean;
};

export type PinJobQuery = {
Expand Down

0 comments on commit 58cf7d0

Please sign in to comment.