<?php
header('Content-Type: application/json; charset=utf-8');
require_once 'includes/ProxyHelper.php';
$proxy = new ProxyHelper();
$ubrn = '20082692068091735';

$headers = [
    'client: bris',
    'X-CSRF-TOKEN: ' . $proxy->getCsrfToken()
];

$tests = [
    'person_info_dg_1' => "https://bdris.gov.bd/api/br/info/person-info-by-ubrn-and-data-group?ubrn=$ubrn&dataGroup=1",
    'person_info_dg_full' => "https://bdris.gov.bd/api/br/info/person-info-by-ubrn-and-data-group?ubrn=$ubrn&dataGroup=FULL",
    'person_info_dg_none' => "https://bdris.gov.bd/api/br/info/person-info-by-ubrn-and-data-group?ubrn=$ubrn",
    'person_info_nationality_1' => "https://bdris.gov.bd/api/br/info/person-info-with-nationality-by-ubrn-and-data-group?ubrn=$ubrn&dataGroup=1",
    'person_name_en_bn' => "https://bdris.gov.bd/api/br/info/person-name-en-bn-pair-by-ubrn?ubrn=$ubrn",
    'parent_proj' => "https://bdris.gov.bd/api/br/parent-projection-by-ubrn?ubrn=$ubrn",
    'admin_register_search' => "https://bdris.gov.bd/api/br/register/search/by-ubrn?ubrn=$ubrn",
];

$results = [];
foreach ($tests as $key => $url) {
    $res = $proxy->fetch($url, 'GET', [], false, 'https://bdris.gov.bd/admin/br/search', $headers);
    $results[$key] = [
        'status' => $res['status'],
        'body' => json_decode($res['body'], true) ?: substr($res['body'], 0, 500)
    ];
}

echo json_encode($results, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
