File: /home/awaldron/_accomods/apidev.accomods.com/v1/school.php
<?php
//**********************************************************************************************************//
// Method: GET
// Endpoint: school/code/args[0]
// Params:
function get_v1_school_code( $args, $body, $uid, $is_admin, $db ) {
$school_code = $args[0];
$sql = "SELECT * FROM school_codes WHERE UPPER(school_code)='".strtoupper($school_code)."'";
$school = qRow( $db, $sql );
if (!$school) {
$data = ['success'=>false, 'msg'=>'School Code not found.'];
}
else if ( !$school['code_active'] ) {
$data = ['success'=>false, 'msg'=>'This school code has been disabled'];
}
else if ( strtotime($school['code_expires'])+86400 < time()) {
$data = ['success'=>false, 'msg'=>'This school code has expired. Please contact Accomods to renew.' ];
}
else if ($school) {
$data = ['success'=>true, 'payload'=>$school];
}
else {
$data = ['success'=>false, 'msg'=>'An unknown error occurred.'];
}
response(200, $data);
}