<?php
/*
 * api-global - Global API
 *
 * This file is used to create global API
 */


//Get list of cass-group
function cass_group_list_endpoint() {
    register_rest_route('wp-cass/v1', '/cass-group-list', array(
        'methods' => 'GET',
        'callback' => 'get_cass_group_list',
    ));
}

add_action('rest_api_init', 'cass_group_list_endpoint');

function get_cass_group_list($request) {
    return Group::selectAll();
}


//Get list of cass-level
function cass_level_list_endpoint() {
    register_rest_route('wp-cass/v1', '/cass-level-list', array(
        'methods' => 'GET',
        'callback' => 'get_cass_level_list',
    ));
}

add_action('rest_api_init', 'cass_level_list_endpoint');

function get_cass_level_list($request) {
    return Level::selectAll();
}

//Get list of all races

function cass_race_list_endpoint() {
    register_rest_route('wp-cass/v1', '/cass-race-list', array(
        'methods' => 'GET',
        'callback' => 'get_cass_race_list',
    ));
}

add_action('rest_api_init', 'cass_race_list_endpoint');

function get_cass_race_list($request) {
    return Race::selectAllStructured();
}



