<?php
    require_once("../../autoloader.php");
    header('Access-Control-Allow-Origin: *');
    header('Content-Type: application/json');
    header("Access-Control-Allow-Methods: POST");
    header("Allow: POST, OPTIONS, PUT, DELETE");
    header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Access-Control-Allow-Origin");

    $headers = apache_request_headers();
    $response = array();
    $controller = new SubscriberModel;
   
    date_default_timezone_set('Africa/Lagos');
          

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
   
    $id = $_POST['user_id'];

file_put_contents("nolly.txt",json_encode($id, JSON_UNESCAPED_SLASHES));
 

    $result = $controller->setProfileInfo($id);
 
      
    
file_put_contents("airtime_fail_log.txt",json_encode($result, JSON_UNESCAPED_SLASHES));
$jsonString = json_encode($result, JSON_UNESCAPED_SLASHES);
echo $jsonString;
exit();
    
    }

    
 else {
    
    $response = array('status' => 'error', 'message' => 'Invalid request method');
    file_put_contents("airtime_fail_log.txt",json_encode($response))
        ;
    echo json_encode($response);
}

function formatUserType($value)
{
    $value = (float) $value;
    $output = "";
    if ($value == 1) {
        $output = "Smart";
    } elseif ($value == 2) {
        $output = "API";
    } else {
        $output = "Vendor";
    }
    return $output;
}

?>