46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Post, Query } from '@nestjs/common';
|
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { NudgeService } from './nudge.service';
|
|
import type { CreateNudgeDto, NudgeSessionFilters } from '@life-platform/shared';
|
|
|
|
@ApiTags('Nudges')
|
|
@Controller('nudges')
|
|
export class NudgeController {
|
|
constructor(private readonly service: NudgeService) {}
|
|
|
|
@Post()
|
|
@ApiOperation({ summary: 'Start a nudge session' })
|
|
start(@Body() dto: CreateNudgeDto) {
|
|
return this.service.start(dto);
|
|
}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'List nudge sessions' })
|
|
findAll(@Query() query: NudgeSessionFilters) {
|
|
return this.service.findAll(query);
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: 'Get nudge session details' })
|
|
findOne(@Param('id') id: string) {
|
|
return this.service.findOne(id);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@ApiOperation({ summary: 'Cancel a nudge session' })
|
|
stop(@Param('id') id: string) {
|
|
return this.service.stop(id);
|
|
}
|
|
|
|
@Post(':id/pause')
|
|
@ApiOperation({ summary: 'Pause a nudge session' })
|
|
pause(@Param('id') id: string) {
|
|
return this.service.pause(id);
|
|
}
|
|
|
|
@Post(':id/resume')
|
|
@ApiOperation({ summary: 'Resume a paused nudge session' })
|
|
resume(@Param('id') id: string) {
|
|
return this.service.resume(id);
|
|
}
|
|
}
|