From 49f4faf71d9b033421eabe235cfa6dac2fc90134 Mon Sep 17 00:00:00 2001 From: kang Date: Mon, 23 Dec 2024 15:33:12 +0800 Subject: [PATCH] Refine `SingleFilterSearchRequest` interface to permit array values for the `IN` and `NIN` operators --- src/api/types/SingleFilterSearchRequest.ts | 24 ++++++++++++++++------ tests/integration/conversations.test.ts | 21 ++++++++++++++++++- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/api/types/SingleFilterSearchRequest.ts b/src/api/types/SingleFilterSearchRequest.ts index 95f869c..bf09a0c 100644 --- a/src/api/types/SingleFilterSearchRequest.ts +++ b/src/api/types/SingleFilterSearchRequest.ts @@ -2,18 +2,30 @@ * This file was auto-generated by Fern from our API Definition. */ -/** - * Search using Intercoms Search APIs with a single filter. - */ -export interface SingleFilterSearchRequest { +interface SingleFilterSearchRequestWithStringValue { /** The accepted field that you want to search on. */ field?: string; - /** The accepted operators you can use to define how you want to search for the value. */ - operator?: SingleFilterSearchRequest.Operator; + /** The operator for single value types */ + operator?: "=" | "!=" | "<" | ">" | "~" | "!~" | "^" | "$"; /** The value that you want to search on. */ value?: string; } +interface SingleFilterSearchRequestWithArrayValue { + /** The accepted field that you want to search on. */ + field?: string; + /** The operator specifically for array value types */ + operator?: "IN" | "NIN"; + /** The value that you want to search on. */ + value?: string[]; +} +/** + * Search using Intercoms Search APIs with a single filter. + */ +export type SingleFilterSearchRequest = + SingleFilterSearchRequestWithStringValue | + SingleFilterSearchRequestWithArrayValue; + export namespace SingleFilterSearchRequest { /** * The accepted operators you can use to define how you want to search for the value. diff --git a/tests/integration/conversations.test.ts b/tests/integration/conversations.test.ts index c204cd8..2e81be1 100644 --- a/tests/integration/conversations.test.ts +++ b/tests/integration/conversations.test.ts @@ -265,7 +265,7 @@ describe("Conversations", () => { expect(response).toBeDefined(); }); - it("search", async () => { + it("search with string value", async () => { // act const response = await client.conversations.search({ query: { @@ -283,4 +283,23 @@ describe("Conversations", () => { // assert expect(response).toBeDefined(); }); + + it("search with array value", async () => { + // act + const response = await client.conversations.search({ + query: { + operator: "AND", + value: [ + { + field: "id", + operator: "IN", + value: ["123", '321'], + }, + ], + }, + }); + + // assert + expect(response).toBeDefined(); + }); });