import { Controller, Post, Res, HttpStatus, Body, UseGuards } from '@nestjs/common';
import { Response } from 'express';
import { GetMenuParams, GetParams, LoadNotificationParams, GetGoalParams, SaveGoalParams, GetDigitalParams, PayGoalParams, RegisterGoalsParams } from './home.entity';
import { HomeService } from './home.service';
import { AuthGuard } from 'src/guards/auth/auth.guard';

@Controller('api/app/home')
export class HomeController {

	constructor(private readonly homeService: HomeService) {

	}

	@UseGuards(AuthGuard)
	@Post('/')
	async get(@Body() request: GetParams, @Res() response: Response) {
		return response.status(HttpStatus.OK).json(await this.homeService.get(request));
	}

	@UseGuards(AuthGuard)
	@Post('/menu')
	async getMenu(@Body() request: GetMenuParams, @Res() response: Response) {
		return response.status(HttpStatus.OK).json(await this.homeService.getMenu(request));
	}

	@UseGuards(AuthGuard)
	@Post('/load-notification')
	async loadNotification(@Body() request: LoadNotificationParams, @Res() response: Response) {
		return response.status(HttpStatus.OK).json(await this.homeService.loadNotification(request));
	}

	@UseGuards(AuthGuard)
	@Post('/save-goal')
	async saveGoal(@Body() request: SaveGoalParams, @Res() response: Response) {
		return response.status(HttpStatus.OK).json(await this.homeService.saveGoal(request));
	}

	@UseGuards(AuthGuard)
	@Post('/pay-goal')
	async payGoal(@Body() request: PayGoalParams, @Res() response: Response) {
		return response.status(HttpStatus.OK).json(await this.homeService.payGoal(request));
	}

	@UseGuards(AuthGuard)
	@Post('/register-goals')
	async registerGoals(@Body() request: RegisterGoalsParams, @Res() response: Response) {
		return response.status(HttpStatus.OK).json(await this.homeService.registerGoals(request));
	}

	@UseGuards(AuthGuard)
	@Post('/load-goal')
	async getGoal(@Body() request: GetGoalParams, @Res() response: Response) {
		return response.status(HttpStatus.OK).json(await this.homeService.getGoal(request));
	}

	@UseGuards(AuthGuard)
	@Post('/digital')
	async getDigital(@Body() request: GetDigitalParams, @Res() response: Response) {
		return response.status(HttpStatus.OK).json(await this.homeService.getDigital(request));
	}

}
