From a02cebb528d1e88712e6b1f3a8cbd767ad0f8636 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu Date: Thu, 2 Jan 2025 15:55:54 +0000 Subject: [PATCH] update --- .../app-store/zoho-bigin/lib/CrmService.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/app-store/zoho-bigin/lib/CrmService.ts b/packages/app-store/zoho-bigin/lib/CrmService.ts index be88b6d3c7dd2a..f6cca57eb9b07b 100644 --- a/packages/app-store/zoho-bigin/lib/CrmService.ts +++ b/packages/app-store/zoho-bigin/lib/CrmService.ts @@ -37,6 +37,8 @@ export default class BiginCrmService implements CRM { private readonly integrationName = "zoho-bigin"; private readonly auth: { getToken: () => Promise }; private log: typeof logger; + private eventsSlug = "/bigin/v1/Events"; + private contactsSlug = "/bigin/v1/Contacts"; constructor(credential: CredentialPayload) { this.auth = this.biginAuth(credential); @@ -132,7 +134,7 @@ export default class BiginCrmService implements CRM { const response = await axios({ method: "post", - url: "https://www.zohoapis.in/bigin/v1/Contacts", + url: token.api_domain + this.contactsSlug, headers: { "content-type": "application/json", authorization: `Zoho-oauthtoken ${token.access_token}`, @@ -161,15 +163,11 @@ export default class BiginCrmService implements CRM { const response = await axios({ method: "get", - url: `https://www.zohoapis.in/bigin/v1/Contacts/search?criteria=${searchCriteria}`, + url: `${token.api_domain}${this.contactsSlug}/search?criteria=${searchCriteria}`, headers: { authorization: `Zoho-oauthtoken ${token.access_token}`, }, - }) - .then((data) => data.data) - .catch((e) => { - this.log.error("Error searching contact:", JSON.stringify(e), e.response?.data); - }); + }).then((data) => data.data); return response ? response.data.map((contact: BiginContact) => { @@ -197,7 +195,7 @@ export default class BiginCrmService implements CRM { return axios({ method: "post", - url: "https://www.zohoapis.in/bigin/v1/Events", + url: token.api_domain + this.eventsSlug, headers: { "content-type": "application/json", authorization: `Zoho-oauthtoken ${token.access_token}`, @@ -255,7 +253,7 @@ export default class BiginCrmService implements CRM { }; return axios - .put("https://www.zohoapis.in/bigin/v1/Events", JSON.stringify({ data: [biginEvent] }), { + .put(token.api_domain + this.eventsSlug, JSON.stringify({ data: [biginEvent] }), { headers: { "content-type": "application/json", authorization: `Zoho-oauthtoken ${token.access_token}`, @@ -270,7 +268,7 @@ export default class BiginCrmService implements CRM { async deleteEvent(uid: string): Promise { const token = await this.auth.getToken(); return axios - .delete(`https://www.zohoapis.in/bigin/v1/Events?ids=${uid}`, { + .delete(`${token.api_domain}${this.eventsSlug}?ids=${uid}`, { headers: { "content-type": "application/json", authorization: `Zoho-oauthtoken ${token.access_token}`,