mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Karat;
|
|
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class Api
|
|
{
|
|
/**
|
|
* @var array|mixed
|
|
*/
|
|
private static mixed $username;
|
|
/**
|
|
* @var array|mixed
|
|
*/
|
|
private static mixed $password;
|
|
/**
|
|
* @var array|mixed
|
|
*/
|
|
private static mixed $endpoint;
|
|
|
|
public function __construct()
|
|
{
|
|
self::$username = Config::get('services.karat.username');
|
|
self::$password = Config::get('services.karat.password');
|
|
self::$endpoint = Config::get('services.karat.endpoint');
|
|
}
|
|
|
|
private static function doRequest($command)
|
|
{
|
|
$response = Http::timeout(60)
|
|
->withOptions([
|
|
'debug' => true,
|
|
'verify' => false,
|
|
])->withBasicAuth(self::$username, self::$password)
|
|
->post(self::$endpoint, [
|
|
'command' => $command,
|
|
]);
|
|
|
|
return $response->json();
|
|
}
|
|
|
|
public static function getUsers()
|
|
{
|
|
return self::doRequest('TM_GET_USERS')['users'];
|
|
}
|
|
|
|
public static function getClients()
|
|
{
|
|
return self::doRequest('TM_GET_CLIENTS')['clients'];
|
|
}
|
|
|
|
public static function getProjects()
|
|
{
|
|
return self::doRequest('TM_GET_PROJECTS')['projects'];
|
|
}
|
|
}
|