<?php

use Illuminate\Support\Facades\Http;

if (!function_exists('getFromGest')) {
    function getFromGest($url, $body = [], $is_with_client = 2)
    {
        $headers = [
            'Accept' => 'application/json',
            'Content-Type' => 'application/json'
        ];
        if ($is_with_client == 1) {
            $headers = array_merge($headers, [
                'Authorization' => 'Bearer '.config('app.api_key')//$authorization//config('app.api_key')
            ]);
        } elseif ($is_with_client == 2) { // add here client Key
            $headers = array_merge($headers, [
                'Authorization' => 'Bearer '.config('app.api_key'),//$authorization,//config('app.api_key'),
                'X-Client-Reference' => config('app.client_key')
            ]);
        }

        $base_url = config('app.geststudent_api');
        // [
        //     'Accept' => 'application/json',
        //     'Content-Type' => 'application/json',
        //     'Authorization' => $authorization
        // ]

        $req = Http::withHeaders($headers)->get($base_url . $url);//->json();
        return $req;// && isset($req['success']) && $req['success'] ? encryptable($req, false) : $req;
        // return Http::withHeaders($headers)->get($base_url . $url, $body);
    }
}
