<?php
include_once '../config/header.php';
include_once '../config/database.php';
include_once '../objects/api_auth.php';
include_once '../token/validatetoken.php';
$database = new Database();
$db = $database->getConnection();
 
$api_auth = new Api_Auth($db);

$api_auth->pageNo = isset($_GET['pageno']) ? $_GET['pageno'] : 1;
$api_auth->no_of_records_per_page = isset($_GET['pagesize']) ? $_GET['pagesize'] : 30;

$stmt = $api_auth->read();
$num = $stmt->rowCount();
if($num>0){
    $api_auth_arr=array();
	$api_auth_arr["pageno"]=$api_auth->pageNo;
	$api_auth_arr["pagesize"]=$api_auth->no_of_records_per_page;
    $api_auth_arr["total_count"]=$api_auth->total_record_count();
    $api_auth_arr["records"]=array();
    
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
        extract($row);
 
        $api_auth_item=array(
            
"id" => $id,
"user" => html_entity_decode($user),
"pass" => html_entity_decode($pass)
        );
         array_push($api_auth_arr["records"], $api_auth_item);
    }
    http_response_code(200);
	echo json_encode(array("status" => "success", "code" => 1,"message"=> "api_auth found","document"=> $api_auth_arr));
}else{
    http_response_code(404);
	echo json_encode(array("status" => "error", "code" => 0,"message"=> "No api_auth found.","document"=> ""));
}
 


