<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
  
// database connection will be here
// include database and object files
include_once '../config/database.php';
include_once '../admin/admin.php';
  
// instantiate database and product object
$database = new Database();
$db = $database->getConnection();
  
// initialize object
$admin = new Admin($db);

$request_method=$_SERVER["REQUEST_METHOD"];

switch($request_method)
{
    case 'POST':
        
        $result = $admin->getProgramList();
        
        if (!empty($result)){
            http_response_code(200);
            echo json_encode($result);
        }else{
            http_response_code(404);
            echo json_encode(array("message" => "Empty Result"));
        }
        
        break;
        
        default:
            // set response code - 405 bad request
            http_response_code(405);
            // tell the user
            echo json_encode(array("message" => "Invalid Method"));
            break;
}