Created
September 8, 2021 12:15
-
-
Save MarcelWeidum/d7a88ea4bf335b11ca76a2fcfd2505cd to your computer and use it in GitHub Desktop.
Get employees
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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