import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import {
  ChampionSuggestionQueryDto,
  CollectMatchesDto,
  RiotAccountSuggestionQueryDto,
  SearchRiotUserDto,
} from './dto/search-riot-user.dto';
import { RiotAccountService } from './riot-account.service';
import { RiotMatchService } from './riot-match.service';

@Controller('v1/riot')
export class RiotController {
  constructor(
    private readonly accountService: RiotAccountService,
    private readonly matchService: RiotMatchService,
  ) {}

  @Post('search')
  search(@Body() dto: SearchRiotUserDto) {
    return this.accountService.findOrSyncAccount(dto);
  }

  @Get('suggestions')
  suggestions(@Query() query: RiotAccountSuggestionQueryDto) {
    return this.accountService.getSuggestions(query);
  }

  @Get('champions')
  champions(@Query() query: ChampionSuggestionQueryDto) {
    return this.accountService.getChampionSuggestions(query);
  }

  @Post('matches/collect')
  collectMatches(@Body() dto: CollectMatchesDto) {
    return this.matchService.collectRecentMatches(dto);
  }
}
