<?php
/**
 * Retrieve the state list for a country and return it as a JSON
 *
 * @package Mtc\Core
 * @author Martins Fridenbergs <martins.fridenbergs@mtcmedia.co.uk>
 * @version 26.01.2017
 */

use Mtc\Core\Models\CountryState;

$path = '../../';
require_once $path . 'core/includes/header.inc.php';
header('Content-Type: application/json');

$country = filter_input(INPUT_GET, 'country');

if ($country) {
    $country_state_list = CountryState::getCountryStateList($country);
} else {
    $country_state_list = CountryState::getCountryStateList();
}

echo json_encode($country_state_list);