Closed DeanOutlaw closed 1 year ago
OK I worked it out, so for my future reference and for others, you need to push $employee into an array
so
$newEmployees = [];
array_push($newEmployees, $employee);
$result = $apiInstance->createEmployee($xeroTenantId, $newEmployees);
SDK you're using (please complete the following information):
Describe the bug createEmployee fails with JSON de/serialization
To Reproduce Steps to reproduce the behavior:
$dateOfBirth = new DateTime('2000-10-28');
$homeAddress = new XeroAPI\XeroPHP\Models\PayrollAu\HomeAddress; $homeAddress->setAddressLine1('123 Test st'); $homeAddress->setRegion('VIC'); $homeAddress->setPostalCode(3000); $homeAddress->setCity('Melbourne');
$employee = new XeroAPI\XeroPHP\Models\PayrollAu\Employee; $employee->setFirstName('Adam'); $employee->setLastName('Adamson'); $employee->setDateOfBirthAsDate($dateOfBirth); $employee->setHomeAddress($homeAddress); $result = $apiInstance->createEmployee($xeroTenantId, $employee);
Expected behavior create new employee entry
Additional context I tried copying the sample SDK code found at https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html#api-PayrollAu-createEmployee and that just throws the same error