-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added desunify + mappersHubspot
- Loading branch information
Showing
18 changed files
with
96 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/api/src/@core/utils/unification/crm/freshsales/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 14 additions & 3 deletions
17
packages/api/src/@core/utils/unification/crm/hubspot/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
import { CrmObject } from 'src/crm/@types'; | ||
import { CrmObjectInput } from '../../types'; | ||
import { CrmObjectInput, Unified } from '../../types'; | ||
import { mapToHubspotContact } from './mappers'; | ||
|
||
export async function desunifyHubspot<T extends Record<string, any>>({ | ||
export async function desunifyHubspot<T extends Unified>({ | ||
sourceObject, | ||
targetType_, | ||
}: { | ||
sourceObject: T; | ||
targetType_: CrmObject; | ||
}): Promise<CrmObjectInput> { | ||
return; | ||
switch (targetType_) { | ||
case CrmObject.contact: | ||
return mapToHubspotContact(sourceObject); | ||
case CrmObject.deal: | ||
//return mapToHubspotDeal(sourceObject); | ||
case CrmObject.company: | ||
//return mapToHubspotCompany(sourceObject); | ||
// Add other cases for different CrmObject types | ||
default: | ||
throw new Error(`Unsupported target type for Hubspot: ${targetType_}`); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/api/src/@core/utils/unification/crm/hubspot/mappers/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { HubspotContactInput } from 'src/crm/@types'; | ||
import { UnifiedContactInput } from 'src/crm/contact/dto/create-contact.dto'; | ||
import { Unified } from '../../../types'; | ||
|
||
export function mapToHubspotContact<T extends Unified>( | ||
source: T, | ||
): HubspotContactInput { | ||
const source_ = source as UnifiedContactInput; | ||
// Assuming 'email_addresses' array contains at least one email and 'phone_numbers' array contains at least one phone number | ||
const primaryEmail = source_.email_addresses?.[0]?.email_address; | ||
const primaryPhone = source_.phone_numbers?.[0]?.phone_number; | ||
|
||
return { | ||
firstname: source_.first_name, | ||
lastname: source_.last_name, | ||
email: primaryEmail, | ||
phone: primaryPhone, | ||
// Map other fields as needed | ||
// If there are fields such as city, country, etc., in your UnifiedContactInput, map them here | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/api/src/@core/utils/unification/crm/pipedrive/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/api/src/@core/utils/unification/crm/zendesk/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export enum AtsObject {} | ||
|
||
export type UnifiedAts = ''; //TODO; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ContactModule } from './contact/contact.module'; | ||
import { DealModule } from './deal/deal.module'; | ||
|
||
@Module({ | ||
imports: [ContactModule], | ||
imports: [ContactModule, DealModule], | ||
}) | ||
export class CrmModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { DealService } from './deal.service'; | ||
|
||
@Module({ | ||
providers: [DealService], | ||
}) | ||
export class DealModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { DealService } from './deal.service'; | ||
|
||
describe('DealService', () => { | ||
let service: DealService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [DealService], | ||
}).compile(); | ||
|
||
service = module.get<DealService>(DealService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class DealService {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class UnifiedDealInput { | ||
id: string; | ||
} |