Skip to content

Commit

Permalink
Merge pull request #17 from panoratech/issue-4
Browse files Browse the repository at this point in the history
feat: added boilerplate for 1st integration
  • Loading branch information
naelob authored Oct 29, 2023
2 parents 05ca545 + 694a6e0 commit ed62447
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 70 deletions.
2 changes: 1 addition & 1 deletion api/src/crm/contact/contact.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing';

Check warning on line 1 in api/src/crm/contact/contact.controller.spec.ts

View workflow job for this annotation

GitHub Actions / build-api (16.x)

'Test' is defined but never used

Check warning on line 1 in api/src/crm/contact/contact.controller.spec.ts

View workflow job for this annotation

GitHub Actions / build-api (16.x)

'TestingModule' is defined but never used
import { ContactController } from './contact.controller';

Check warning on line 2 in api/src/crm/contact/contact.controller.spec.ts

View workflow job for this annotation

GitHub Actions / build-api (16.x)

'ContactController' is defined but never used
import { ContactService } from './contact.service';
import { ContactService } from './services/contact.service';

Check warning on line 3 in api/src/crm/contact/contact.controller.spec.ts

View workflow job for this annotation

GitHub Actions / build-api (16.x)

'ContactService' is defined but never used

describe('ContactController', () => {
/*let controller: ContactController;
Expand Down
42 changes: 8 additions & 34 deletions api/src/crm/contact/contact.controller.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
5 changes: 3 additions & 2 deletions api/src/crm/contact/contact.module.ts
Original file line number Diff line number Diff line change
@@ -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 {}
29 changes: 0 additions & 29 deletions api/src/crm/contact/contact.service.ts

This file was deleted.

7 changes: 6 additions & 1 deletion api/src/crm/contact/dto/create-contact.dto.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
export class CreateContactDto {}
export class CreateContactDto {
first_name: string;
last_name: string;
email_addresses: string[];
phone_numbers: string[];
}
File renamed without changes.
28 changes: 28 additions & 0 deletions api/src/crm/contact/services/contact.service.ts
Original file line number Diff line number Diff line change
@@ -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) {

Check warning on line 13 in api/src/crm/contact/services/contact.service.ts

View workflow job for this annotation

GitHub Actions / build-api (16.x)

'createContactDto' is defined but never used

Check warning on line 13 in api/src/crm/contact/services/contact.service.ts

View workflow job for this annotation

GitHub Actions / build-api (16.x)

'integrationId' is defined but never used
//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;
}
}
8 changes: 8 additions & 0 deletions api/src/crm/contact/services/freshsales/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class FreshSalesService {
async addContact() {
return;
}
}
3 changes: 0 additions & 3 deletions docs/architecture/README.md

This file was deleted.

Binary file removed docs/architecture/assets/architecture.png
Binary file not shown.
2 changes: 2 additions & 0 deletions sdk/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
//import axios from 'axios';

/*export interface Lib {
Expand All @@ -13,6 +14,7 @@ type ContactBody = {
last_name: string;
email_addresses: string[];
phone_numbers: string[];
other?: any[];
}

export default class PanoraApiClient {
Expand Down

0 comments on commit ed62447

Please sign in to comment.