Skip to content

Instantly share code, notes, and snippets.

@MarcelWeidum
Created September 8, 2021 12:15
Show Gist options
  • Save MarcelWeidum/d7a88ea4bf335b11ca76a2fcfd2505cd to your computer and use it in GitHub Desktop.
Save MarcelWeidum/d7a88ea4bf335b11ca76a2fcfd2505cd to your computer and use it in GitHub Desktop.
Get employees
<?php
public function employees()
{
// Init client
$mplusqapiclient = new Mplusqapiclient();
$mplusqapiclient->setApiServer(env('MPLUS_URL'));
$mplusqapiclient->setApiPort(env('MPLUS_PORT'));
$mplusqapiclient->setApiIdent(env('MPLUS_IDENT'));
$mplusqapiclient->setApiSecret(env('MPLUS_SECRET'));
try {
$mplusqapiclient->initClient();
} catch (MplusQAPIException $e) {
exit($e->getMessage());
}
$syncMarker = 1;
$syncMarker = $this->getSyncMarker('employeeSyncMarker');
// Then we call the getEmployees() function wrapped in a try/catch block to intercept any exceptions.
try {
if (false !== ($employees= $mplusqapiclient->getEmployees($syncMarker))) {
// Success, we show the number of retrieved employees.
dd($employees);
exit(sprintf('Retrieved %d employees.', count($employees)));
} else {
exit('Unable to retrieve employees.');
}
} catch (MplusQAPIException $e) {
exit($e->getMessage());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment