From be5f7f83b58f981d3719255d66110ec505a2e3b5 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Fri, 3 Jan 2025 08:41:18 +0530 Subject: [PATCH] fix: Zoho Bigin not pulling information from booking (#18445) * fix: Zoho Bigin not pulling information from booking * update * missed * fix contactcreation --- .../app-store/zoho-bigin/lib/CrmService.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/app-store/zoho-bigin/lib/CrmService.ts b/packages/app-store/zoho-bigin/lib/CrmService.ts index 05907a7475..8a7710b32d 100644 --- a/packages/app-store/zoho-bigin/lib/CrmService.ts +++ b/packages/app-store/zoho-bigin/lib/CrmService.ts @@ -30,7 +30,7 @@ export type BiginToken = { export type BiginContact = { id: string; - email: string; + Email: string; }; export default class BiginCrmService implements CRM { @@ -140,13 +140,13 @@ export default class BiginCrmService implements CRM { authorization: `Zoho-oauthtoken ${token.access_token}`, }, data: JSON.stringify({ data: contacts }), - }); + }).then((data) => data.data); return response - ? response.data.map((contact: BiginContact) => { + ? response.data.map((contact: any) => { return { - id: contact.id, - email: contact.email, + id: contact.details.id, + email: contact.Email, }; }) : []; @@ -167,13 +167,13 @@ export default class BiginCrmService implements CRM { headers: { authorization: `Zoho-oauthtoken ${token.access_token}`, }, - }).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) => { return { id: contact.id, - email: contact.email, + email: contact.Email, }; }) : []; @@ -182,14 +182,15 @@ export default class BiginCrmService implements CRM { /*** * Sends request to Zoho Bigin API to add new Events. */ - private async createBiginEvent(event: CalendarEvent) { + private async createBiginEvent(event: CalendarEvent, contacts: Contact[]) { const token = await this.auth.getToken(); const biginEvent = { Event_Title: event.title, Start_DateTime: toISO8601String(new Date(event.startTime)), End_DateTime: toISO8601String(new Date(event.endTime)), Description: event.additionalNotes, - Location: getLocation(event), + Venue: getLocation(event), + Who_Id: contacts[0].id, }; return axios({ @@ -209,7 +210,7 @@ export default class BiginCrmService implements CRM { * Handles orchestrating the creation of new events in Zoho Bigin. */ async handleEventCreation(event: CalendarEvent, contacts: Contact[]) { - const meetingEvent = await this.createBiginEvent(event); + const meetingEvent = await this.createBiginEvent(event, contacts); if (meetingEvent.data && meetingEvent.data.length && meetingEvent.data[0].status === "success") { this.log.debug("event:creation:ok", { meetingEvent }); return Promise.resolve({