import { Body, Controller, Get, Param, Put } from '@nestjs/common'; import { CustomerContactsService } from './customer-contacts.service'; interface SaveContactBody { phone?: string | null; whatsappPhone?: string | null; callSmsPhone?: string | null; email?: string | null; name?: string | null; company?: string | null; note?: string | null; userId?: number | null; } @Controller('contacts') export class CustomerContactsController { constructor(private readonly customerContactsService: CustomerContactsService) {} @Get() listContacts() { return this.customerContactsService.listContacts(); } @Get(':chatId') getContact(@Param('chatId') chatId: string) { return this.customerContactsService.getContact(decodeURIComponent(chatId)); } @Put(':chatId') saveContact( @Param('chatId') chatId: string, @Body() body: SaveContactBody, ) { return this.customerContactsService.saveContact({ chatId: decodeURIComponent(chatId), phone: body.whatsappPhone || body.phone, callSmsPhone: body.callSmsPhone, email: body.email, name: body.name, company: body.company, note: body.note, userId: body.userId, }); } }