<?php
// Include the common cUrl file
require_once('curl_helper.php'); http://localhost:8888/hrorbn-api/
// $restApiBasedUrl = 'http://localhost/REST-API';
$restApiBasedUrl = 'http://localhost:8888/hrorbn-api/';
//fetch url: https://basic.ng/hrorbn/api/index.php/students 
try {
    // Get All employees
    $employees = sendRequest($restApiBasedUrl.'/api.php/employees', 'GET');
    $employees = json_encode($employees, true);
    // Process the response 
    // Get Employee By Id
    $employeeId = 1;
    $employee = sendRequest($restApiBasedUrl."/api.php/employees/$employeeId", 'GET');
    $employee = json_encode($employee, true);
    // Process the response
    // Add new employee
    $data =[
        'emp_name' => 'Muhammad Kabir Abubakar',
        'emp_code' => 001,
        'emp_email'=> 'muhammadkabircs@gmail.com',
        'emp_phone'=> '07068704737',
        'emp_address' => 'Gombe',
        'emp_designation' => 'Director',
        'emp_joining_date' => '2024-01-01'
    ];
    $employee = sendRequest($restApiBasedUrl."/api.php/employees", 'POST', $data);
    $employee = json_encode($employee, true);
    // Process the response
    // Update employee by Id
    $employeeId = 1;
    $data =[
        'emp_name' => 'M. K Abubakar',
        'emp_code' => 001,
        'emp_email'=> 'muhammadkabircs@gmail.com',
        'emp_phone'=> '07068704737',
        'emp_address' => 'Abuja',
        'emp_designation' => 'CEO',
        'emp_joining_date' => '2024-01-01'
    ];
    $employee = sendRequest($restApiBasedUrl."/api.php/employees/$employeeId", 'PUT', $data);
    $employee = json_encode($employee, true);
    // Process the response
    // Delete employee by Id
    $employeeId = 1;
    $employee = sendRequest($restApiBasedUrl."/api.php/employees/$employeeId", 'DELETE');
    $employee = json_encode($employee, true);
     // Process the response
    // Handle any additional logic or data processing
    
}catch (Exception $e){
    // Handle any acceptions that occur during the API Call
}