Skip to content

Presence

Max Kovpak edited this page Apr 15, 2020 · 3 revisions

Track employee presence

require_once 'vendor/autoload.php';

use Brainfab\MoyGrafik\MoyGrafik;
use Brainfab\MoyGrafik\Presence;
use Brainfab\MoyGrafik\Entity\PresenceTrackManual;
use Brainfab\MoyGrafik\Entity\PresenceTrackManualData;

$OAUTH2_CLIENT_ID = 'your client id';
$OAUTH2_CLIENT_SECRET = 'your client secret';

$client = new MoyGrafik();
$client->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);

$client->authenticate([
    'grant_type' => 'password',
    'username'   => 'your email',
    'password'   => 'your password',
]);

$companies = $client->companies()->listCompanies();
$company = $companies[0];
$employeeId = 123;

$presence = new PresenceTrackManual();
$presence->data = new PresenceTrackManualData();
$presence->data->employeeId = $employeeId;
$presence->trackingDate = date(DATE_ISO8601);
$presence->action = Presence::TRACK_ACTION_TOGGLE;

$track = $client->presence()->track($company->id, $presence);
Clone this wiki locally