<?php

include_once __ROOT_DIR . '/libs/php-jwt/src/BeforeValidException.php';
include_once __ROOT_DIR . '/libs/php-jwt/src/ExpiredException.php';
include_once __ROOT_DIR . '/libs/php-jwt/src/SignatureInvalidException.php';
include_once __ROOT_DIR . '/libs/php-jwt/src/JWT.php';
use \Firebase\JWT\JWT;

class GamesController extends Controller {

    public function __construct($name, $request) {
        parent::__construct($name, $request);
    }

    // ==============
    // Actions
    // ==============

    public function processRequest()
    {
        switch ($this->request->getHttpMethod()) {
            case 'GET':
                return $this->getList();
                break;
        }
        return Response::errorResponse("unsupported parameters or method in game");
    }

    public function getList()
    {
        $games = Game::getList();
        $response = new Response(200,json_encode($games));
        return $response;
    }

}