28 lines
893 B
TypeScript
28 lines
893 B
TypeScript
|
|
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(':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,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|