diff --git a/packages/api/src/crm/@lib/@types/index.ts b/packages/api/src/crm/@lib/@types/index.ts index 5994c1c68..db3742eb5 100644 --- a/packages/api/src/crm/@lib/@types/index.ts +++ b/packages/api/src/crm/@lib/@types/index.ts @@ -326,6 +326,7 @@ export class Email { }) @IsString() @IsOptional() + @IsIn(['COMPANY', 'CONTACT']) owner_type?: string; } diff --git a/packages/api/src/crm/@lib/@utils/index.ts b/packages/api/src/crm/@lib/@utils/index.ts index 82816b355..7f7444c9e 100644 --- a/packages/api/src/crm/@lib/@utils/index.ts +++ b/packages/api/src/crm/@lib/@utils/index.ts @@ -91,6 +91,21 @@ export class Utils { } } + async getEmailFromUserUuid(uuid: string) { + try { + const res = await this.prisma.crm_users.findFirst({ + where: { + id_crm_user: uuid, + }, + }); + // if (!res) throw new Error(`crm_user not found for uuid ${uuid}`); + if (!res) return; + return res.email; + } catch (error) { + throw error; + } + } + async getUser(uuid: string) { try { const res = await this.prisma.crm_users.findFirst({ diff --git a/packages/api/src/crm/company/services/attio/mappers.ts b/packages/api/src/crm/company/services/attio/mappers.ts index 747b24a08..756e78627 100644 --- a/packages/api/src/crm/company/services/attio/mappers.ts +++ b/packages/api/src/crm/company/services/attio/mappers.ts @@ -7,6 +7,7 @@ import { ICompanyMapper } from '@crm/company/types'; import { Utils } from '@crm/@lib/@utils'; import { Injectable } from '@nestjs/common'; import { MappersRegistry } from '@@core/@core-services/registries/mappers.registry'; +import { getCountryCode, getCountryName } from '@@core/utils/types'; @Injectable() export class AttioCompanyMapper implements ICompanyMapper { @@ -29,31 +30,29 @@ export class AttioCompanyMapper implements ICompanyMapper { ], }, }; - if (source.industry) { + /*todo if (source.industry) { result.values.categories = [ { option: source.industry, }, ]; - } + }*/ if (source.addresses) { const address = source.addresses[0]; if (address) { - // result.city = address.city; - // result.state = address.state; result.values.primary_location = [ { locality: address.city, line_1: address.street_1, - line_2: address.street_2, + line_2: address.street_2 ?? null, line_3: null, line_4: null, - region: address.state + ',' + address.country, + region: address.state, postcode: address.postal_code, latitude: null, longitude: null, - country_code: null, + country_code: getCountryCode(address.country), }, ]; } @@ -158,16 +157,11 @@ export class AttioCompanyMapper implements ICompanyMapper { city: company.values.primary_location[0]?.locality, state: company.values.primary_location[0]?.region, postal_code: company.values.primary_location[0]?.postcode, - country: company.values.primary_location[0]?.country_code, - address_type: 'primary', - owner_type: 'company', - }, - ], - phone_numbers: [ - { - phone_number: null, - phone_type: 'primary', - owner_type: 'company', + country: getCountryName( + company.values.primary_location[0]?.country_code, + ), + address_type: 'WORK', + owner_type: 'COMPANY', }, ], field_mappings, diff --git a/packages/api/src/crm/company/services/close/mappers.ts b/packages/api/src/crm/company/services/close/mappers.ts index be44c1a57..4977a2c77 100644 --- a/packages/api/src/crm/company/services/close/mappers.ts +++ b/packages/api/src/crm/company/services/close/mappers.ts @@ -7,6 +7,7 @@ import { ICompanyMapper } from '@crm/company/types'; import { Utils } from '@crm/@lib/@utils'; import { Injectable } from '@nestjs/common'; import { MappersRegistry } from '@@core/@core-services/registries/mappers.registry'; +import { getCountryCode, getCountryName } from '@@core/utils/types'; @Injectable() export class CloseCompanyMapper implements ICompanyMapper { @@ -28,6 +29,7 @@ export class CloseCompanyMapper implements ICompanyMapper { address_2: address.street_2, city: address.city, state: address.state, + country: getCountryCode(address.country), zipcode: address.postal_code, label: address.address_type, })) as CloseCompanyInput['addresses'], @@ -109,11 +111,10 @@ export class CloseCompanyMapper implements ICompanyMapper { city: address.city, state: address.state, postal_code: address.zipcode, - country: address.country, + country: getCountryName(address.country) || address.country, address_type: address.label, - owner_type: 'company', + owner_type: 'COMPANY', })), - phone_numbers: null, field_mappings, ...opts, }; diff --git a/packages/api/src/crm/company/services/company.service.ts b/packages/api/src/crm/company/services/company.service.ts index 18fa742db..8934526df 100644 --- a/packages/api/src/crm/company/services/company.service.ts +++ b/packages/api/src/crm/company/services/company.service.ts @@ -226,6 +226,7 @@ export class CompanyService { data: { ...email, id_crm_company: companyId, + id_connection: connectionId, }, }); } @@ -249,6 +250,7 @@ export class CompanyService { data: { ...phone, id_crm_company: companyId, + id_connection: connectionId, }, }); } @@ -295,6 +297,7 @@ export class CompanyService { data: { ...email, id_crm_company: companyId, + id_connection: connectionId, }, }), ), @@ -308,6 +311,7 @@ export class CompanyService { data: { ...phone, id_crm_company: companyId, + id_connection: connectionId, }, }), ), @@ -406,10 +410,12 @@ export class CompanyService { }); const remote_data = JSON.parse(resp.data); - res = { - ...res, - remote_data: remote_data, - }; + if (resp && resp.data) { + res = { + ...res, + remote_data: remote_data, + }; + } } if (linkedUserId && integrationId) { await this.prisma.events.create({ @@ -552,8 +558,11 @@ export class CompanyService { ressource_owner_id: company.id, }, }); - const remote_data = JSON.parse(resp.data); - return { ...company, remote_data }; + if (resp && resp.data) { + const remote_data = JSON.parse(resp.data); + return { ...company, remote_data }; + } + return company; }), ); res = remote_array_data; diff --git a/packages/api/src/crm/company/services/hubspot/mappers.ts b/packages/api/src/crm/company/services/hubspot/mappers.ts index 28c62bb21..3eac3f227 100644 --- a/packages/api/src/crm/company/services/hubspot/mappers.ts +++ b/packages/api/src/crm/company/services/hubspot/mappers.ts @@ -20,15 +20,15 @@ export class HubspotCompanyMapper implements ICompanyMapper { remote_id: string; }[], ): Promise { - const result: HubspotCompanyInput = { - city: null, + const result: any = { name: source.name, - phone: null, - state: null, - domain: null, industry: source.industry || null, }; + if (source.number_of_employees) { + result.numberofemployees = source.number_of_employees; + } + // Assuming 'phone_numbers' array contains at least one phone number const primaryPhone = source.phone_numbers?.[0]?.phone_number; if (primaryPhone) { @@ -39,6 +39,9 @@ export class HubspotCompanyMapper implements ICompanyMapper { if (address) { result.city = address.city; result.state = address.state; + result.zip = address.postal_code; + result.address = address.street_1; + result.country = address.country; } } @@ -121,23 +124,23 @@ export class HubspotCompanyMapper implements ICompanyMapper { remote_id: company.id, name: company.properties.name, industry: company.properties.industry, - number_of_employees: null, + number_of_employees: company.properties.numberofemployees, addresses: [ { - street_1: null, + street_1: company.properties.address, city: company.properties.city, state: company.properties.state, - postal_code: null, - country: null, - address_type: 'primary', - owner_type: 'company', + postal_code: company.properties.zip, + country: company.properties.country, + address_type: 'WORK', + owner_type: 'COMPANY', }, - ], // Assuming 'street', 'city', 'state', 'postal_code', 'country' are properties in company.properties + ], phone_numbers: [ { phone_number: company.properties.phone, - phone_type: 'primary', - owner_type: 'company', + phone_type: 'WORK', + owner_type: 'COMPANY', }, ], field_mappings, diff --git a/packages/api/src/crm/company/services/hubspot/types.ts b/packages/api/src/crm/company/services/hubspot/types.ts index 874dd95fe..9c9fb4854 100644 --- a/packages/api/src/crm/company/services/hubspot/types.ts +++ b/packages/api/src/crm/company/services/hubspot/types.ts @@ -2,9 +2,13 @@ export interface HubspotCompanyInput { city: string; name: string; phone: string; - state: string; domain: string; industry: string; + state: string; + country: string; + address: string; + numberofemployees: string; + zip: string; hubspot_owner_id?: string; [key: string]: any; } @@ -21,6 +25,10 @@ export interface HubspotCompanyOutput { name: string; phone: string; state: string; + country: string; + zip: string; + address: string; + numberofemployees: string; [key: string]: string; }; createdAt: string; @@ -36,5 +44,9 @@ export const commonCompanyHubspotProperties = { name: '', phone: '', state: '', + country: '', + zip: '', + address: '', hubspot_owner_id: '', + numberofemployees: '', }; diff --git a/packages/api/src/crm/company/services/pipedrive/mappers.ts b/packages/api/src/crm/company/services/pipedrive/mappers.ts index 2b16e93d8..e2d3b1c43 100644 --- a/packages/api/src/crm/company/services/pipedrive/mappers.ts +++ b/packages/api/src/crm/company/services/pipedrive/mappers.ts @@ -26,10 +26,7 @@ export class PipedriveCompanyMapper implements ICompanyMapper { }; if (source.addresses && source.addresses[0]) { - result.address = source.addresses[0].street_1; - result.address_locality = source.addresses[0].city; - result.address_country = source.addresses[0].country; - result.address_postal_code = source.addresses[0].postal_code; + result.address = `${source.addresses[0].street_1}, ${source.addresses[0].postal_code} ${source.addresses[0].city}, ${source.addresses[0].country}`; } if (source.user_id) { @@ -115,20 +112,32 @@ export class PipedriveCompanyMapper implements ICompanyMapper { } } if (company.address) { - opts.addresses[0] = { - street_1: company.address, - city: company.address_locality, - country: company.address_country, - postal_code: company.address_postal_code, - }; + const addressRegex = /^(.*?), (\d{5}) (.*?), (.*)$/; + const match = company.address.match(addressRegex); + + const [, street, postalCode, city, country] = match; + opts.addresses = [ + { + street_1: street, + city: city, + country: country, + postal_code: postalCode, + }, + ]; + } + if (company.cc_email) { + opts.email_adresses = [ + { + owner_type: 'COMPANY', + email_address: company.cc_email, + email_address_type: 'WORK', + }, + ]; } return { name: company.name, industry: null, - number_of_employees: null, - email_addresses: null, - phone_numbers: null, - addresses: null, + number_of_employees: company.people_count ?? null, field_mappings, remote_id: String(company.id), ...opts, diff --git a/packages/api/src/crm/company/services/zendesk/mappers.ts b/packages/api/src/crm/company/services/zendesk/mappers.ts index ee3d66140..02fd6c0a2 100644 --- a/packages/api/src/crm/company/services/zendesk/mappers.ts +++ b/packages/api/src/crm/company/services/zendesk/mappers.ts @@ -111,17 +111,17 @@ export class ZendeskCompanyMapper implements ICompanyMapper { // Constructing the email and phone details const email_addresses = company.email - ? [{ email_address: company.email, email_address_type: 'primary' }] + ? [{ email_address: company.email, email_address_type: 'WORK' }] : null; const phone_numbers = []; if (company.phone) { - phone_numbers.push({ phone_number: company.phone, phone_type: 'work' }); + phone_numbers.push({ phone_number: company.phone, phone_type: 'WORK' }); } if (company.mobile) { phone_numbers.push({ phone_number: company.mobile, - phone_type: 'mobile', + phone_type: 'MOBILE', }); } diff --git a/packages/api/src/crm/company/services/zoho/index.ts b/packages/api/src/crm/company/services/zoho/index.ts index a074ee68c..3b9c1b24e 100644 --- a/packages/api/src/crm/company/services/zoho/index.ts +++ b/packages/api/src/crm/company/services/zoho/index.ts @@ -49,9 +49,19 @@ export class ZohoService implements ICompanyService { }, }, ); - //this.logger.log('zoho resp is ' + JSON.stringify(resp)); + const final_res = await axios.get( + `${connection.account_url}/Accounts/${resp.data.data[0].details.id}`, + { + headers: { + 'Content-Type': 'application/json', + Authorization: `Zoho-oauthtoken ${this.cryptoService.decrypt( + connection.access_token, + )}`, + }, + }, + ); return { - data: resp.data.data, + data: final_res.data.data[0], message: 'Zoho company created', statusCode: 201, }; diff --git a/packages/api/src/crm/company/services/zoho/mappers.ts b/packages/api/src/crm/company/services/zoho/mappers.ts index 79a9d34db..a2b1be873 100644 --- a/packages/api/src/crm/company/services/zoho/mappers.ts +++ b/packages/api/src/crm/company/services/zoho/mappers.ts @@ -37,7 +37,7 @@ export class ZohoCompanyMapper implements ICompanyMapper { } if (source.phone_numbers) { result.Phone = source.phone_numbers?.find( - (phone) => phone.phone_type === 'primary', + (phone) => phone.phone_type === 'WORK', )?.phone_number; } @@ -116,8 +116,8 @@ export class ZohoCompanyMapper implements ICompanyMapper { phone_numbers: [ { phone_number: company.Phone, - phone_type: 'primary', - owner_type: 'company', + phone_type: 'WORK', + owner_type: 'COMPANY', }, ], addresses: [ @@ -127,8 +127,8 @@ export class ZohoCompanyMapper implements ICompanyMapper { state: company.Billing_State, postal_code: company.Billing_Code, country: company.Billing_Country, - address_type: 'primary', - owner_type: 'company', + address_type: 'PERSONAL', + owner_type: 'COMPANY', }, ], ...opts, diff --git a/packages/api/src/crm/contact/services/contact.service.ts b/packages/api/src/crm/contact/services/contact.service.ts index 11319244c..3eff86be1 100644 --- a/packages/api/src/crm/contact/services/contact.service.ts +++ b/packages/api/src/crm/contact/services/contact.service.ts @@ -414,10 +414,12 @@ export class ContactService { }); const remote_data = JSON.parse(resp.data); - res = { - ...res, - remote_data: remote_data, - }; + if (resp && resp.data) { + res = { + ...res, + remote_data: remote_data, + }; + } } if (linkedUserId && integrationId) { await this.prisma.events.create({ diff --git a/packages/api/src/crm/deal/services/attio/mappers.ts b/packages/api/src/crm/deal/services/attio/mappers.ts index 1357b5c14..12ee00538 100644 --- a/packages/api/src/crm/deal/services/attio/mappers.ts +++ b/packages/api/src/crm/deal/services/attio/mappers.ts @@ -21,45 +21,40 @@ export class AttioDealMapper implements IDealMapper { remote_id: string; }[], ): Promise { - const result: AttioDealInput = { + const result: any = { values: { - name: [ - { - value: source.name, - }, - ], + name: source.name, }, }; + if (source.stage_id) { + const stage_name = await this.utils.getStageNameFromStageUuid( + source.stage_id, + ); + if (stage_name) { + result.values.stage = stage_name; + } + } else { + result.values.stage = 'In Progress'; // todo + } if (source.company_id) { const company_id = await this.utils.getRemoteIdFromCompanyUuid( source.company_id, ); if (company_id) { - result.values.associated_company! = [ - { - target_object: 'companies', - target_record_id: company_id, - }, - ]; + result.values.associated_company! = { + target_object: 'companies', + target_record_id: company_id, + }; } } if (source.user_id) { - const user_id = await this.utils.getRemoteIdFromUserUuid(source.user_id); - if (user_id) { - result.values.owner! = [ - { - referenced_actor_id: user_id, - referenced_actor_type: 'workspace-member', - }, - ]; + const email = await this.utils.getEmailFromUserUuid(source.user_id); + if (email) { + result.values.owner! = email; } } if (source.amount) { - result.values.value = [ - { - currency_value: source.amount, - }, - ]; + result.values.value = source.amount; } if (customFieldMappings && source.field_mappings) { @@ -167,7 +162,7 @@ export class AttioDealMapper implements IDealMapper { return { remote_id: deal.id.record_id, name: deal.values.name.length > 0 ? deal.values.name[0].value : null, - description: null, + description: '', field_mappings, ...opts, }; diff --git a/packages/api/src/crm/deal/services/close/mappers.ts b/packages/api/src/crm/deal/services/close/mappers.ts index 63c695f7f..f5abb1b60 100644 --- a/packages/api/src/crm/deal/services/close/mappers.ts +++ b/packages/api/src/crm/deal/services/close/mappers.ts @@ -150,7 +150,7 @@ export class CloseDealMapper implements IDealMapper { return { remote_id: deal.id, name: deal.note, - description: deal.note, + description: deal.note || '', amount: parseFloat(`${deal.value || 0}`), field_mappings, ...opts, diff --git a/packages/api/src/crm/deal/services/hubspot/index.ts b/packages/api/src/crm/deal/services/hubspot/index.ts index 5e21af27d..8fa655f55 100644 --- a/packages/api/src/crm/deal/services/hubspot/index.ts +++ b/packages/api/src/crm/deal/services/hubspot/index.ts @@ -58,7 +58,7 @@ export class HubspotService implements IDealService { this.logger.log(`Synced hubspot deals !`); return { - data: resp.data.results, + data: resp.data, message: 'Hubspot deal created', statusCode: 201, }; diff --git a/packages/api/src/crm/deal/services/hubspot/mappers.ts b/packages/api/src/crm/deal/services/hubspot/mappers.ts index 60c491b4d..79f9caebc 100644 --- a/packages/api/src/crm/deal/services/hubspot/mappers.ts +++ b/packages/api/src/crm/deal/services/hubspot/mappers.ts @@ -132,7 +132,7 @@ export class HubspotDealMapper implements IDealMapper { return { remote_id: deal.id, name: deal.properties.dealname, - description: null, + description: '', field_mappings, ...opts, }; diff --git a/packages/api/src/crm/deal/services/pipedrive/mappers.ts b/packages/api/src/crm/deal/services/pipedrive/mappers.ts index 7d7603a6c..d20a1fda8 100644 --- a/packages/api/src/crm/deal/services/pipedrive/mappers.ts +++ b/packages/api/src/crm/deal/services/pipedrive/mappers.ts @@ -29,9 +29,18 @@ export class PipedriveDealMapper implements IDealMapper { if (source.user_id) { const owner_id = await this.utils.getRemoteIdFromUserUuid(source.user_id); if (owner_id) { - result.creator_user_id.id = Number(owner_id); + result.user_id = Number(owner_id); } } + if (source.company_id) { + const company_id = await this.utils.getRemoteIdFromCompanyUuid( + source.company_id, + ); + if (company_id) { + result.org_id = Number(company_id); + } + } + if (source.stage_id) { const stage_id = await this.utils.getStageIdFromStageUuid( source.stage_id, @@ -95,7 +104,7 @@ export class PipedriveDealMapper implements IDealMapper { } let opts: any = {}; - if (deal.creator_user_id.id) { + if (deal.creator_user_id && deal.creator_user_id.id) { const owner_id = await this.utils.getUserUuidFromRemoteId( String(deal.creator_user_id.id), connectionId, diff --git a/packages/api/src/crm/deal/services/pipedrive/types.ts b/packages/api/src/crm/deal/services/pipedrive/types.ts index 5cb40ae2e..a5ec0f158 100644 --- a/packages/api/src/crm/deal/services/pipedrive/types.ts +++ b/packages/api/src/crm/deal/services/pipedrive/types.ts @@ -9,15 +9,17 @@ export interface PipedriveDeal { active_flag: boolean; value: number; }; - user_id: { - id: number; - name: string; - email: string; - has_pic: boolean; - pic_hash: null | string; - active_flag: boolean; - value: number; - }; + user_id: + | { + id: number; + name: string; + email: string; + has_pic: boolean; + pic_hash: null | string; + active_flag: boolean; + value: number; + } + | number; person_id: { active_flag: boolean; name: string; @@ -25,15 +27,17 @@ export interface PipedriveDeal { phone: { label: string; value: string; primary: boolean }[]; value: number; }; - org_id: { - name: string; - people_count: number; - owner_id: number; - address: string; - active_flag: boolean; - cc_email: string; - value: number; - }; + org_id: + | { + name: string; + people_count: number; + owner_id: number; + address: string; + active_flag: boolean; + cc_email: string; + value: number; + } + | number; stage_id: number; title: string; value: number; diff --git a/packages/api/src/crm/deal/services/zendesk/index.ts b/packages/api/src/crm/deal/services/zendesk/index.ts index f22f8f29a..cbcbeab0b 100644 --- a/packages/api/src/crm/deal/services/zendesk/index.ts +++ b/packages/api/src/crm/deal/services/zendesk/index.ts @@ -1,16 +1,14 @@ -import { Injectable } from '@nestjs/common'; -import { IDealService } from '@crm/deal/types'; -import { CrmObject } from '@crm/@lib/@types'; -import { ZendeskDealInput, ZendeskDealOutput } from './types'; -import axios from 'axios'; +import { EncryptionService } from '@@core/@core-services/encryption/encryption.service'; import { LoggerService } from '@@core/@core-services/logger/logger.service'; import { PrismaService } from '@@core/@core-services/prisma/prisma.service'; -import { ActionType, handle3rdPartyServiceError } from '@@core/utils/errors'; -import { EncryptionService } from '@@core/@core-services/encryption/encryption.service'; import { ApiResponse } from '@@core/utils/types'; -import { ServiceRegistry } from '../registry.service'; import { SyncParam } from '@@core/utils/types/interface'; -import { OriginalDealOutput } from '@@core/utils/types/original/original.crm'; +import { CrmObject } from '@crm/@lib/@types'; +import { IDealService } from '@crm/deal/types'; +import { Injectable } from '@nestjs/common'; +import axios from 'axios'; +import { ServiceRegistry } from '../registry.service'; +import { ZendeskDealInput, ZendeskDealOutput } from './types'; @Injectable() export class ZendeskService implements IDealService { constructor( @@ -37,6 +35,7 @@ export class ZendeskService implements IDealService { vertical: 'crm', }, }); + const resp = await axios.post( `${connection.account_url}/deals`, { diff --git a/packages/api/src/crm/deal/services/zendesk/mappers.ts b/packages/api/src/crm/deal/services/zendesk/mappers.ts index 5c782690a..fd3491615 100644 --- a/packages/api/src/crm/deal/services/zendesk/mappers.ts +++ b/packages/api/src/crm/deal/services/zendesk/mappers.ts @@ -35,7 +35,7 @@ export class ZendeskDealMapper implements IDealMapper { if (source.user_id) { const owner_id = await this.utils.getRemoteIdFromUserUuid(source.user_id); if (owner_id) { - result.creator_id = Number(owner_id); + result.owner_id = Number(owner_id); } } if (source.stage_id) { @@ -100,9 +100,9 @@ export class ZendeskDealMapper implements IDealMapper { } let opts: any = {}; - if (deal.creator_id) { + if (deal.owner_id) { const owner_id = await this.utils.getUserUuidFromRemoteId( - String(deal.creator_id), + String(deal.owner_id), connectionId, ); if (owner_id) { diff --git a/packages/api/src/crm/deal/services/zoho/index.ts b/packages/api/src/crm/deal/services/zoho/index.ts index d93451044..0dd84e0e0 100644 --- a/packages/api/src/crm/deal/services/zoho/index.ts +++ b/packages/api/src/crm/deal/services/zoho/index.ts @@ -48,9 +48,19 @@ export class ZohoService implements IDealService { }, }, ); - //this.logger.log('zoho resp is ' + JSON.stringify(resp)); + const final_res = await axios.get( + `${connection.account_url}/Deals/${resp.data.data[0].details.id}`, + { + headers: { + 'Content-Type': 'application/json', + Authorization: `Zoho-oauthtoken ${this.cryptoService.decrypt( + connection.access_token, + )}`, + }, + }, + ); return { - data: resp.data.data, + data: final_res.data.data[0], message: 'Zoho deal created', statusCode: 201, }; diff --git a/packages/api/src/crm/deal/services/zoho/mappers.ts b/packages/api/src/crm/deal/services/zoho/mappers.ts index 106898a10..80e0e66e4 100644 --- a/packages/api/src/crm/deal/services/zoho/mappers.ts +++ b/packages/api/src/crm/deal/services/zoho/mappers.ts @@ -11,6 +11,7 @@ import { IngestDataService } from '@@core/@core-services/unification/ingest-data import { CrmObject } from '@crm/@lib/@types'; import { UnifiedStageOutput } from '@crm/stage/types/model.unified'; import { ZohoStageOutput } from '@crm/stage/services/zoho/types'; +import { OriginalDealOutput } from '@@core/utils/types/original/original.crm'; @Injectable() export class ZohoDealMapper implements IDealMapper { @@ -34,12 +35,10 @@ export class ZohoDealMapper implements IDealMapper { Amount: source.amount, }; if (source.company_id) { - result.Account_Name.id = await this.utils.getRemoteIdFromCompanyUuid( - source.company_id, - ); - result.Account_Name.name = await this.utils.getCompanyNameFromUuid( - source.company_id, - ); + result.Account_Name = { + id: await this.utils.getRemoteIdFromCompanyUuid(source.company_id), + name: await this.utils.getCompanyNameFromUuid(source.company_id), + }; } if (source.stage_id) { result.Stage = await this.utils.getStageNameFromStageUuid( @@ -47,9 +46,9 @@ export class ZohoDealMapper implements IDealMapper { ); } if (source.user_id) { - result.Owner.id = await this.utils.getRemoteIdFromUserUuid( - source.user_id, - ); + result.Owner = { + id: await this.utils.getRemoteIdFromUserUuid(source.user_id), + } as any; } if (customFieldMappings && source.field_mappings) { diff --git a/packages/api/src/crm/user/services/zoho/index.ts b/packages/api/src/crm/user/services/zoho/index.ts index 3fcbaab85..955accd3c 100644 --- a/packages/api/src/crm/user/services/zoho/index.ts +++ b/packages/api/src/crm/user/services/zoho/index.ts @@ -47,7 +47,7 @@ export class ZohoService implements IUserService { }, }, ); - //this.logger.log('CONTACTS ZOHO ' + JSON.stringify(resp.data.data)); + this.logger.log('USERS ZOHO ' + JSON.stringify(resp.data)); this.logger.log(`Synced zoho users !`); return { data: resp.data.data,