<?php

function rcFull($vehicalNumber){
    $url = 'https://sandbox.surepass.io/api/v1/rc/rc-full';
    $token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTcyMTgxNzc0MCwianRpIjoiNGQ0N2Q3ZTItMmNhMC00NTAyLTg2ZmItZDVlMDY4ZGNlNTM5IiwidHlwZSI6ImFjY2VzcyIsImlkZW50aXR5IjoiZGV2LmF0ZWxpZXJAc3VyZXBhc3MuaW8iLCJuYmYiOjE3MjE4MTc3NDAsImV4cCI6MTcyNDQwOTc0MCwiZW1haWwiOiJhdGVsaWVyQHN1cmVwYXNzLmlvIiwidGVuYW50X2lkIjoibWFpbiIsInVzZXJfY2xhaW1zIjp7InNjb3BlcyI6WyJ1c2VyIl19fQ.x9q-3aHuKkff25AVAxJtPAzM8oj_dYGvTQpkb7WK0YI';
    $id_number = $vehicalNumber;
    // $id_number = 'UK01B4843';
    $data = array('id_number' => $id_number);
    $data_json = json_encode($data);
    $headers = array(
        'Content-Type: application/json',
        'Authorization: Bearer ' . $token
    );
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
    $response = curl_exec($ch);
    if (curl_errno($ch)) {
        echo 'Error:' . curl_error($ch);
    } else {
        $response =  json_decode($response, true);
        return $response;
    }
    curl_close($ch);
}

// rcTophone('UK01B4843');

function rcTophone($vehicalNumber){
    $url = 'https://sandbox.surepass.io/api/v1/rc/rc-to-mobile-number';
    $authorizationToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTcyMTgxNzc0MCwianRpIjoiNGQ0N2Q3ZTItMmNhMC00NTAyLTg2ZmItZDVlMDY4ZGNlNTM5IiwidHlwZSI6ImFjY2VzcyIsImlkZW50aXR5IjoiZGV2LmF0ZWxpZXJAc3VyZXBhc3MuaW8iLCJuYmYiOjE3MjE4MTc3NDAsImV4cCI6MTcyNDQwOTc0MCwiZW1haWwiOiJhdGVsaWVyQHN1cmVwYXNzLmlvIiwidGVuYW50X2lkIjoibWFpbiIsInVzZXJfY2xhaW1zIjp7InNjb3BlcyI6WyJ1c2VyIl19fQ.x9q-3aHuKkff25AVAxJtPAzM8oj_dYGvTQpkb7WK0YI';
    $rcNumber = $vehicalNumber;
    // $rcNumber = "UK01B4843"; 
    $apiUrl = "https://sandbox.surepass.io/api/v1/rc/rc-to-mobile-number";
    // $authorizationToken = "YOUR_BEARER_TOKEN"; // Replace with your actual token

    $data = [
        "rc_number" => $rcNumber
    ];

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $apiUrl);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'Authorization: Bearer ' . $authorizationToken
    ]);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

    $response = curl_exec($ch);
    curl_close($ch);

    if ($response === false) {
        die('Error fetching data from SurePass API');
    }

    $responseData = json_decode($response, true);
    if (json_last_error() !== JSON_ERROR_NONE) {
        die('Error decoding JSON response');
    }
    return $responseData['data']['mobile_number'];
}

?>

