import { Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { LoyaltyService } from './loyalty.service';
import { JwtGuard } from '../../common/jwt.guard';

@ApiTags('Loyalty')
@Controller('loyalty')
@UseGuards(JwtGuard)
@ApiBearerAuth('JWT-auth')
export class LoyaltyController {
  constructor(private service: LoyaltyService) {}
  @Get(':passengerId')                                    @ApiOperation({ summary: 'Get loyalty account with tier progress' }) getAccount(@Param('passengerId') id: string) { return this.service.getAccount(id); }
  @Get(':passengerId/rewards')                            @ApiOperation({ summary: 'Get available rewards' })                  getRewards(@Param('passengerId') id: string) { return this.service.getRewards(id); }
  @Post(':passengerId/rewards/:rewardId/redeem')          @ApiOperation({ summary: 'Redeem a loyalty reward' })                redeemReward(@Param('passengerId') pid: string, @Param('rewardId') rid: string) { return this.service.redeemReward(pid, rid); }
}
