mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
Karat service
This commit is contained in:
1 parent
e575fabff0
commit
cba2118366
6 files changed
+181
No files matched your search
@@ -0,0 +1,47 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Karat;
|
||||
|
||||
class KaratService
|
||||
{
|
||||
private Api $api;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->api = new Api();
|
||||
}
|
||||
|
||||
public function syncUsers()
|
||||
{
|
||||
$users = $this->api->getUsers();
|
||||
|
||||
dd($users);
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user