1. Go to this page and download the library: Download clockster/sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$clockster->users->upsert(['users' => [[
'external_id' => 'HR-1',
'first_name' => 'Aisulu',
'role' => 'employee',
'location_id' => 3,
'position_id' => null, // clears the stored position
// department_id is not there at all, so the stored department stays.
]]]);
use Clockster\Write;
$clockster->users->upsert(['users' => [Write::filled([
'external_id' => $row['external_id'],
'first_name' => $row['first_name'],
'role' => UsersRole::EMPLOYEE,
'location_id' => $locations[$row['location_code']],
'email' => $row['email'], // blank in the file, so not sent, so not overwritten
'position_id' => null, // null is kept: clearing is a thing you may mean
])]]);
/** @return UsersListResponse */
public function list(?int $perPage = null, /* … */): array
use Clockster\Generated\Enum\UsersInclude;
use Clockster\Generated\Enum\UsersRole;
use Clockster\Generated\Enum\UsersStatus;
$clockster->users->upsert(['users' => [['role' => UsersRole::EMPLOYEE, /* … */]]]);
$clockster->users->list(status: UsersStatus::ACTIVE,
use Clockster\Exception\InvalidBodyException;
$clockster = new Client(getenv('CLOCKSTER_TOKEN'), validate: true);
try {
$clockster->users->upsert(['users' => $people]);
} catch (InvalidBodyException $refused) {
// ['body.users.4.first_nane' => ['is not a field the document names here. It names …']]
report($refused->errors());
}
use Clockster\Exception\WebhookVerificationException;
use Clockster\Webhooks;
try {
$event = Webhooks::verifyGlobals(getenv('CLOCKSTER_WEBHOOK_SECRET'));
} catch (WebhookVerificationException $refused) {
http_response_code(400);
exit;
}
http_response_code(200);
use Clockster\Http\Psr18Transport;
$clockster = new Client($token, transport: new Psr18Transport(
$guzzle, // Psr\Http\Client\ClientInterface
$requestFactory, // Psr\Http\Message\RequestFactoryInterface
$streamFactory, // Psr\Http\Message\StreamFactoryInterface
));
$clockster = new Client(
token: getenv('CLOCKSTER_TOKEN'),
baseUrl: 'https://demo.clockster.com', // a demo stand instead of production
timeout: 60.0, // seconds, applied to each request
userAgent: 'acme-hr/1.4', // names your integration in our request log
validate: true, // read a body against the document before sending it
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.