diff --git a/api/src/crm/contact/contact.controller.spec.ts b/api/src/crm/contact/contact.controller.spec.ts index 1e019a215..919891fa2 100644 --- a/api/src/crm/contact/contact.controller.spec.ts +++ b/api/src/crm/contact/contact.controller.spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { ContactController } from './contact.controller'; -import { ContactService } from './contact.service'; +import { ContactService } from './services/contact.service'; describe('ContactController', () => { /*let controller: ContactController; diff --git a/api/src/crm/contact/contact.controller.ts b/api/src/crm/contact/contact.controller.ts index f2c21e2b4..7a58a2392 100644 --- a/api/src/crm/contact/contact.controller.ts +++ b/api/src/crm/contact/contact.controller.ts @@ -1,42 +1,16 @@ -import { - Controller, - Get, - Post, - Body, - Patch, - Param, - Delete, -} from '@nestjs/common'; -import { ContactService } from './contact.service'; +import { Controller, Post, Body, Query } from '@nestjs/common'; +import { ContactService } from './services/contact.service'; import { CreateContactDto } from './dto/create-contact.dto'; -import { UpdateContactDto } from './dto/update-contact.dto'; @Controller('crm/contact') export class ContactController { constructor(private readonly contactService: ContactService) {} - @Post() - create(@Body() createContactDto: CreateContactDto) { - return this.contactService.create(createContactDto); - } - - @Get() - findAll() { - return this.contactService.findAll(); - } - - @Get(':id') - findOne(@Param('id') id: string) { - return this.contactService.findOne(+id); - } - - @Patch(':id') - update(@Param('id') id: string, @Body() updateContactDto: UpdateContactDto) { - return this.contactService.update(+id, updateContactDto); - } - - @Delete(':id') - remove(@Param('id') id: string) { - return this.contactService.remove(+id); + @Post('add-contact') + addContact( + @Body() createContactDto: CreateContactDto, + @Query() integrationId: string, + ) { + return this.contactService.addContact(createContactDto, integrationId); } } diff --git a/api/src/crm/contact/contact.module.ts b/api/src/crm/contact/contact.module.ts index fd4144060..b443294a2 100644 --- a/api/src/crm/contact/contact.module.ts +++ b/api/src/crm/contact/contact.module.ts @@ -1,10 +1,11 @@ import { Module } from '@nestjs/common'; -import { ContactService } from './contact.service'; +import { ContactService } from './services/contact.service'; import { ContactController } from './contact.controller'; import { PrismaService } from 'src/prisma/prisma.service'; +import { FreshSalesService } from './services/freshsales'; @Module({ controllers: [ContactController], - providers: [ContactService, PrismaService], + providers: [ContactService, PrismaService, FreshSalesService], }) export class ContactModule {} diff --git a/api/src/crm/contact/contact.service.ts b/api/src/crm/contact/contact.service.ts deleted file mode 100644 index c22b8511f..000000000 --- a/api/src/crm/contact/contact.service.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { CreateContactDto } from './dto/create-contact.dto'; -import { UpdateContactDto } from './dto/update-contact.dto'; -import { PrismaService } from 'src/prisma/prisma.service'; - -@Injectable() -export class ContactService { - constructor(private prisma: PrismaService) {} - - create(createContactDto: CreateContactDto) { - return 'This action adds a new contact'; - } - - findAll() { - return `This action returns all contact`; - } - - findOne(id: number) { - return `This action returns a #${id} contact`; - } - - update(id: number, updateContactDto: UpdateContactDto) { - return `This action updates a #${id} contact`; - } - - remove(id: number) { - return `This action removes a #${id} contact`; - } -} diff --git a/api/src/crm/contact/dto/create-contact.dto.ts b/api/src/crm/contact/dto/create-contact.dto.ts index df0d11b6f..3fff16e85 100644 --- a/api/src/crm/contact/dto/create-contact.dto.ts +++ b/api/src/crm/contact/dto/create-contact.dto.ts @@ -1 +1,6 @@ -export class CreateContactDto {} +export class CreateContactDto { + first_name: string; + last_name: string; + email_addresses: string[]; + phone_numbers: string[]; +} diff --git a/api/src/crm/contact/contact.service.spec.ts b/api/src/crm/contact/services/contact.service.spec.ts similarity index 100% rename from api/src/crm/contact/contact.service.spec.ts rename to api/src/crm/contact/services/contact.service.spec.ts diff --git a/api/src/crm/contact/services/contact.service.ts b/api/src/crm/contact/services/contact.service.ts new file mode 100644 index 000000000..685c42cd9 --- /dev/null +++ b/api/src/crm/contact/services/contact.service.ts @@ -0,0 +1,28 @@ +import { Injectable } from '@nestjs/common'; +import { CreateContactDto } from '../dto/create-contact.dto'; +import { PrismaService } from 'src/prisma/prisma.service'; +import { FreshSalesService } from './freshsales'; + +@Injectable() +export class ContactService { + constructor( + private prisma: PrismaService, + public freshSales: FreshSalesService, + ) {} + + async addContact(createContactDto: CreateContactDto, integrationId: string) { + //TODO: call addToDbBackup() + //TODO: get the destination provider => call destinationCRMInDb() + const dest = {}; + let resp; + switch (dest) { + case 'freshsales': + resp = await this.freshSales.addContact(); + break; + default: + break; + } + //TODO: sanitize the resp to normalize it + return resp; + } +} diff --git a/api/src/crm/contact/services/freshsales/index.ts b/api/src/crm/contact/services/freshsales/index.ts new file mode 100644 index 000000000..8a52264ed --- /dev/null +++ b/api/src/crm/contact/services/freshsales/index.ts @@ -0,0 +1,8 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class FreshSalesService { + async addContact() { + return; + } +} diff --git a/docs/architecture/README.md b/docs/architecture/README.md deleted file mode 100644 index 959100074..000000000 --- a/docs/architecture/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Panora - -![](assets/architecture.png) diff --git a/docs/architecture/assets/architecture.png b/docs/architecture/assets/architecture.png deleted file mode 100644 index 597c6bd31..000000000 Binary files a/docs/architecture/assets/architecture.png and /dev/null differ diff --git a/sdk/index.ts b/sdk/index.ts index 7ade34c66..282850b6a 100644 --- a/sdk/index.ts +++ b/sdk/index.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ //import axios from 'axios'; /*export interface Lib { @@ -13,6 +14,7 @@ type ContactBody = { last_name: string; email_addresses: string[]; phone_numbers: string[]; + other?: any[]; } export default class PanoraApiClient {