diff --git a/src/resources/objects/index.ts b/src/resources/objects/index.ts index b6c46d0..61cde61 100644 --- a/src/resources/objects/index.ts +++ b/src/resources/objects/index.ts @@ -6,7 +6,12 @@ import { ChannelType, } from "../../common/interfaces"; import { Knock } from "../../knock"; -import { BulkSetObjectOption, Object, SetObjectProperties } from "./interfaces"; +import { + BulkSetObjectOption, + ListObjectOptions, + Object, + SetObjectProperties, +} from "./interfaces"; import { BulkOperation } from "../bulk_operations/interfaces"; import { ListMessagesOptions, Message } from "../messages/interfaces"; import { @@ -45,6 +50,17 @@ export class Objects { return data; } + async list( + collection: string, + filteringOptions: ListObjectOptions = {}, + ): Promise>> { + const { data } = await this.knock.get( + `/v1/objects/${collection}`, + filteringOptions, + ); + return data; + } + async bulkSet( collection: string, objects: BulkSetObjectOption[], diff --git a/src/resources/objects/interfaces.ts b/src/resources/objects/interfaces.ts index cb32ea3..417f3ee 100644 --- a/src/resources/objects/interfaces.ts +++ b/src/resources/objects/interfaces.ts @@ -1,4 +1,4 @@ -import { CommonMetadata } from "../../common/interfaces"; +import { CommonMetadata, PaginationOptions } from "../../common/interfaces"; export interface ObjectRef { collection: string; @@ -23,3 +23,8 @@ export interface BulkSetObjectOption { name?: string; [key: string]: any; } + +export interface ListObjectOptions extends PaginationOptions { + object_id?: string; + name?: string; +} diff --git a/src/resources/users/index.ts b/src/resources/users/index.ts index 67cc0e2..99dfafc 100644 --- a/src/resources/users/index.ts +++ b/src/resources/users/index.ts @@ -23,6 +23,7 @@ import { Knock } from "../../knock"; import { BulkIdentifyUser, IdentifyProperties, + ListUserOptions, User, UserFeedOptions, } from "./interfaces"; @@ -63,6 +64,13 @@ export class Users { return data; } + async list( + filteringOptions: ListUserOptions = {}, + ): Promise> { + const { data } = await this.knock.get(`/v1/users`, filteringOptions); + return data; + } + async delete(userId: string): Promise { if (!userId) { throw new Error(`Incomplete arguments. You must provide a 'userId'`); diff --git a/src/resources/users/interfaces.ts b/src/resources/users/interfaces.ts index 166076b..77967df 100644 --- a/src/resources/users/interfaces.ts +++ b/src/resources/users/interfaces.ts @@ -30,3 +30,9 @@ export interface UserFeedOptions extends PaginationOptions { archived?: "include" | "exclude" | "only"; status?: "unread" | "unseen" | "all"; } + +export interface ListUserOptions extends PaginationOptions { + name?: string; + email?: string; + user_id?: string; +}