Files
jandl-taskmanager-app/be/app/Services/Karat/Api.php
T
2023-02-23 07:39:29 +01:00

48 lines
1006 B
PHP

<?php
namespace App\Services\Karat;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Http;
class Api
{
/**
* @var array|mixed
*/
private mixed $username;
/**
* @var array|mixed
*/
private mixed $password;
/**
* @var array|mixed
*/
private mixed $endpoint;
public function __construct()
{
$this->username = Config::get('services.karat.username');
$this->password = Config::get('services.karat.password');
$this->endpoint = Config::get('services.karat.endpoint');
}
private function doRequest($command)
{
$response = Http::withOptions([
'debug' => true,
'verify' => false,
])->withBasicAuth($this->username, $this->password)
->post($this->endpoint, [
'command' => $command,
]);
return $response->json();
}
public function getUsers()
{
return $this->doRequest('TM_GET_USERS');
}
}