<?php
require_once('../../vendor/autoload.php');
require_once('../init.php');
$client = new \GuzzleHttp\Client();

define('API_BASE', 'https://smartspeeddata.com');
// define('API_BASE', 'https://sandbox.myidentitypass.com');

function error_res($status, $response_code, $message)
{
    $response = new stdClass;
    $response->status = $status;
    $response->response_code = $response_code;
    $response->message = $message;
    return json_encode($response);
}

if (isset($_SESSION['user_id'])) {
    extract($_POST);


    try {

        $request  = $client->request('GET', API_BASE . '/api/data/', [
            'body' => '{"network": ' . intval($network_id) . ',
                "mobile_number": "' . $phone . '",
                "plan": ' . intval($plan_id)  . ',
                "Ported_number":false}',
            'headers' => [
                'accept' => 'application/json',
                'Authorization' => 'Token 4e3ffd9168558bf97cdd339b23ce70709d6120c1',
                'Content-Type' => 'application/json',
                // 'app-id' => app_id,
            ],
        ]);

        // $response = $client->sendAsync($request)->wait();

        $responses = $request->getBody();
        // echo "<pre>";
        echo ($response_std = ($responses));
        // echo "</pre>";
        exit;
    } catch (\Throwable $th) {
        echo $th;
        // echo error_res(false, "03", "Server Error Contact Administrator!");
        exit;
    }
} else {
    echo error_res(false, "03", "Contact Administrator!");
    exit;
}