diff --git a/src/client/SmartQueryClient.ts b/src/client/SmartQueryClient.ts index 6cbf5ef..a4391ba 100644 --- a/src/client/SmartQueryClient.ts +++ b/src/client/SmartQueryClient.ts @@ -15,6 +15,7 @@ export interface SmartQueryClientConfig { abTestManager?: AbTestSegmentManager; tenant: string; apiKey?: string; + endpoint?: string; isAbTestActive: boolean; } @@ -43,6 +44,7 @@ export class SmartQueryClient { private readonly customer: string; private readonly channel: string; private readonly apiKey: string | undefined; + private readonly endpoint: string; private readonly isAbTestActive: boolean; private readonly cache?: ICache; @@ -68,6 +70,7 @@ export class SmartQueryClient { this.channel = split[1]; this.apiKey = config.apiKey; this.cache = cache; // Optional cache initialization + this.endpoint = config.endpoint || "https://saas.searchhub.io"; } /** @@ -98,7 +101,7 @@ export class SmartQueryClient { base64Credentials = btoa(this.customer + ":" + this.apiKey); } - return fetch(`https://saas.searchhub.io/smartquery/v2/${this.customer}/${this.channel}?userQuery=${userQuery}`, { + return fetch(`${this.endpoint}/smartquery/v2/${this.customer}/${this.channel}?userQuery=${userQuery}`, { method: "GET", headers: base64Credentials ? { 'Authorization': `Basic ${base64Credentials}`, diff --git a/src/client/SmartSuggestClient.ts b/src/client/SmartSuggestClient.ts index 75af2b1..0689cbb 100644 --- a/src/client/SmartSuggestClient.ts +++ b/src/client/SmartSuggestClient.ts @@ -12,6 +12,7 @@ import {MappingTarget} from "./SmartQueryClient"; export interface SmartSuggestClientConfig { tenant: string; apiKey?: string; + endpoint?: string; } /** @@ -40,6 +41,7 @@ export class SmartSuggestClient { private readonly customer: string; private readonly channel: string; private readonly apiKey: string | undefined; + private readonly endpoint: string; private readonly cache?: ICache; /** @@ -57,6 +59,7 @@ export class SmartSuggestClient { this.channel = split[1]; this.apiKey = config.apiKey; this.cache = cache; // Optional cache initialization + this.endpoint = config.endpoint || "https://saas.searchhub.io"; } /** @@ -72,7 +75,7 @@ export class SmartSuggestClient { base64Credentials = btoa(this.customer + ":" + this.apiKey); } - return fetch(`https://saas.searchhub.io/smartsuggest/v4/${this.customer}/${this.channel}?userQuery=${userQuery}`, { + return fetch(`${this.endpoint}/smartsuggest/v4/${this.customer}/${this.channel}?userQuery=${userQuery}`, { method: "GET", headers: base64Credentials ? { 'Authorization': `Basic ${base64Credentials}`,