omnichannel-backend/src/modules/admin/customer-contacts.controller.ts

33 lines
982 B
TypeScript
Raw Normal View History

import { Body, Controller, Get, Param, Put } from '@nestjs/common';
import { CustomerContactsService } from './customer-contacts.service';
@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: { phone?: string | null; name?: string | null; company?: string | null; note?: string | null; userId?: number | null },
) {
return this.customerContactsService.saveContact({
chatId: decodeURIComponent(chatId),
phone: body.phone,
name: body.name,
company: body.company,
note: body.note,
userId: body.userId,
});
}
}