Skip to content

Commit f6e5f44

Browse files
Milos ArsikMilos Arsik
Milos Arsik
authored and
Milos Arsik
committed
Adding variable for uri instead of function calls
1 parent a5edebf commit f6e5f44

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

integrations/zoho-sales-iq-hitl/src/client.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export class ZohoApi {
4343
private dataCenter: string;
4444
private ctx: bp.Context;
4545
private bpClient: bp.Client;
46+
private zohoSalesIqServerURI:string;
4647

4748
constructor(refreshToken: string, clientId: string, clientSecret: string, dataCenter: string, ctx: bp.Context, bpClient: bp.Client) {
4849
this.refreshToken = refreshToken;
@@ -51,6 +52,7 @@ export class ZohoApi {
5152
this.dataCenter = dataCenter;
5253
this.ctx = ctx;
5354
this.bpClient = bpClient;
55+
this.zohoSalesIqServerURI = getZohoSalesIQUrl(this.dataCenter)
5456
}
5557

5658
async getStoredCredentials(): Promise<{ accessToken: string } | null> {
@@ -164,7 +166,7 @@ export class ZohoApi {
164166
}
165167

166168
public async createConversation(name: string, email: string, title: string, description: string): Promise<any> {
167-
const { data } = await this.makeHitlRequest(`${getZohoSalesIQUrl(this.dataCenter)}/api/visitor/v1/${this.ctx.configuration.screenName}/conversations`, "POST", {
169+
const { data } = await this.makeHitlRequest(`${this.zohoSalesIqServerURI}/api/visitor/v1/${this.ctx.configuration.screenName}/conversations`, "POST", {
168170
"visitor": {
169171
"user_id": email,
170172
"name": name,
@@ -179,7 +181,7 @@ export class ZohoApi {
179181
}
180182

181183
public async sendMessage(conversationId: string, message: string) {
182-
const endpoint = `${getZohoSalesIQUrl(this.dataCenter)}/api/visitor/v1/${this.ctx.configuration.screenName}/conversations/${conversationId}/messages`;
184+
const endpoint = `${this.zohoSalesIqServerURI}/api/visitor/v1/${this.ctx.configuration.screenName}/conversations/${conversationId}/messages`;
183185

184186
const payload = { text: message };
185187

@@ -200,12 +202,12 @@ export class ZohoApi {
200202
}
201203

202204
public async getApp(): Promise<any> {
203-
const { data } = await this.makeHitlRequest(`${getZohoSalesIQUrl(this.dataCenter)}/api/v2/${this.ctx.configuration.screenName}/apps/${this.ctx.configuration.appId}`);
205+
const { data } = await this.makeHitlRequest(`${this.zohoSalesIqServerURI}/api/v2/${this.ctx.configuration.screenName}/apps/${this.ctx.configuration.appId}`);
204206
return data
205207
}
206208

207209
public async getDepartment(): Promise<any> {
208-
const { data } = await this.makeHitlRequest(`${getZohoSalesIQUrl(this.dataCenter)}/api/v2/${this.ctx.configuration.screenName}/departments/${this.ctx.configuration.departmentId}`);
210+
const { data } = await this.makeHitlRequest(`${this.zohoSalesIqServerURI}/api/v2/${this.ctx.configuration.screenName}/departments/${this.ctx.configuration.departmentId}`);
209211
return data
210212
}
211213
}

0 commit comments

Comments
 (0)