<?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'];


 

    $result = $controller->getApi();
  $r = json_encode($result);
    $data = json_decode($r);

$response = array();

foreach ($data as $item) {
    $name = $item->name;
    $value = $item->value;

    switch ($name) {
        case 'monifyStatus':
            $response['monnifyStatus'] = $value;
            break;
        case 'PayvesselStatus':
            $response['payvesselstatus'] = $value;
            break;
        case 'monifyWeStatus':
            $response['monnifywestatus'] = $value;
            break;
             case 'kudaStatus':
            $response['kudastatus'] = $value;
            break;
             case 'monifyMoStatus':
            $response['monnifyMostatus'] = $value;
              $response['status'] = 'success';
            break;
        default:
            break;
    }

}

//echo json_encode($response);

file_put_contents("airtime__log.txt",json_encode($response, JSON_UNESCAPED_SLASHES));
$jsonString = json_encode($response, JSON_UNESCAPED_SLASHES);
echo $jsonString;
exit();
    
    }

    




?>