Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/client/SmartQueryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface SmartQueryClientConfig {
abTestManager?: AbTestSegmentManager;
tenant: string;
apiKey?: string;
endpoint?: string;
isAbTestActive: boolean;
}

Expand Down Expand Up @@ -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<MappingTarget>;

Expand All @@ -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";
}

/**
Expand Down Expand Up @@ -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}`,
Expand Down
5 changes: 4 additions & 1 deletion src/client/SmartSuggestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {MappingTarget} from "./SmartQueryClient";
export interface SmartSuggestClientConfig {
tenant: string;
apiKey?: string;
endpoint?: string;
}

/**
Expand Down Expand Up @@ -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<MappingTarget>;

/**
Expand All @@ -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";
}

/**
Expand All @@ -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}`,
Expand Down