<?php

function rcFull($vehicalNumber){
     $url = 'https://kyc-api.surepass.io/api/v1/rc/rc-full';
    $token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTcyMjgzOTMxMywianRpIjoiZjhjYTdjNzQtY2ZjMi00NDA5LWJmOTItYWQwZDM4ZTYxMzMzIiwidHlwZSI6ImFjY2VzcyIsImlkZW50aXR5IjoiZGV2LmF0ZWxpZXJAc3VyZXBhc3MuaW8iLCJuYmYiOjE3MjI4MzkzMTMsImV4cCI6MjAzODE5OTMxMywiZW1haWwiOiJhdGVsaWVyQHN1cmVwYXNzLmlvIiwidGVuYW50X2lkIjoibWFpbiIsInVzZXJfY2xhaW1zIjp7InNjb3BlcyI6WyJ1c2VyIl19fQ.5EMINwSYbmv-GFr8OCPQJV0M9ZquKO66B5ZdUG8Q74k';
    $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://kyc-api.surepass.io/api/v1/rc/rc-to-mobile-number';
    $authorizationToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTcyMjgzOTMxMywianRpIjoiZjhjYTdjNzQtY2ZjMi00NDA5LWJmOTItYWQwZDM4ZTYxMzMzIiwidHlwZSI6ImFjY2VzcyIsImlkZW50aXR5IjoiZGV2LmF0ZWxpZXJAc3VyZXBhc3MuaW8iLCJuYmYiOjE3MjI4MzkzMTMsImV4cCI6MjAzODE5OTMxMywiZW1haWwiOiJhdGVsaWVyQHN1cmVwYXNzLmlvIiwidGVuYW50X2lkIjoibWFpbiIsInVzZXJfY2xhaW1zIjp7InNjb3BlcyI6WyJ1c2VyIl19fQ.5EMINwSYbmv-GFr8OCPQJV0M9ZquKO66B5ZdUG8Q74k';
  
    $rcNumber = $vehicalNumber;
    // $rcNumber = "UK01B4843"; 
    $apiUrl = "https://kyc-api.surepass.io/api/v1/rc/rc-to-mobile-number";

    $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'];
    //return $responseData;
}

?>