<?php

namespace App\Helpers;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Storage;


Class Apihelpers
{
    
    
    public static function review_api($locatorID=null)
    {
        $file = Storage::disk('public')->path('key/apikey.dba');

        if (is_file($file)) {

            $fh = fopen($file, 'r') or $this->traceLog('Code Error #: Unable to create .dba file');
            $api_key = fgets($fh);
        }

        $api = config('app.api').$locatorID.'/reviews';
        $client = new Client();
        $response = $client->request('GET', $api,[ 'headers' => [
            'Accept'     => 'application/json',
            'Authorization'  => $api_key]
        ]);
    	$statusCode = $response->getStatusCode();
        $body = $response->getBody()->getContents();
        return $locationDetailAPIdata = json_decode($body,true);
    }

}