### PHP SDK example for updateFile Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/files/index.html PHP example using XeroAPI\XeroPHP\Api\FilesApi to call updateFile. Requires OAuth2 access token, xero-tenant-id, fileId, and idempotency key. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\FilesApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "YOUR_XERO_TENANT_ID"; $fileId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c"; $idempotencyKey = "KEY_VALUE"; try { $result = $apiInstance->updateFile($xeroTenantId, $fileId, $fileObject, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling FilesApi->updateFile: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK example for updateFolder Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/files/index.html PHP example using XeroAPI\XeroPHP\Api\FilesApi to call updateFolder. Requires OAuth2 access token, xero-tenant-id, folderId, and idempotency key. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\FilesApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "YOUR_XERO_TENANT_ID"; $folderId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c"; $idempotencyKey = "KEY_VALUE"; try { $result = $apiInstance->updateFolder($xeroTenantId, $folderId, $folder, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling FilesApi->updateFolder: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK example for getAssetSettings Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/assets/index.html PHP example using the Xero PHP SDK to call getAssetSettings. Requires OAuth2 access token and Xero tenant ID. Outputs an exception message on failure. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\AssetApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "YOUR_XERO_TENANT_ID"; try { $result = $apiInstance->getAssetSettings($xeroTenantId); } catch (Exception $e) { echo 'Exception when calling AssetApi->getAssetSettings: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK Example for updateLeaveApplication Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html PHP example using the Xero PHP SDK to call updateLeaveApplication. Requires OAuth2 access token, Xero tenant ID, leave application ID, and optional idempotency key. The example creates a LeaveApplication object with employee ID, leave type ID, title, start date, and end date, then calls the API and catches exceptions. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $leaveApplicationID = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c"; $idempotencyKey = "KEY_VALUE"; $startDate = new DateTime('2020-10-28'); $endDate = new DateTime('2020-10-30'); $leaveApplication = new XeroAPI\XeroPHP\Models\PayrollAu\LeaveApplication; $leaveApplication->setEmployeeId('00000000-0000-0000-0000-000000000000'); $leaveApplication->setLeaveTypeId('00000000-0000-0000-0000-000000000000'); $leaveApplication->setTitle('Annual Leave'); $leaveApplication->setStartDate($startDate); $leaveApplication->setEndDate($endDate); try { $result = $apiInstance->updateLeaveApplication($xeroTenantId, $leaveApplicationID, $leaveApplication, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->updateLeaveApplication: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK Example: updateSuperfund Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html PHP example using the Xero PHP SDK to update a superfund. Requires OAuth2 access token, Xero tenant ID, superfund ID, and optional idempotency key. The example sets the superfund type and USI, then calls updateSuperfund. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $superFundID = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c"; $idempotencyKey = "KEY_VALUE"; $superFund = new XeroAPI\XeroPHP\Models\PayrollAu\SuperFund; $superfund->setType(XeroAPI\XeroPHP\Models\PayrollAu\SuperFundType::REGULATED); $superfund->setUSI('40022701955002'); try { $result = $apiInstance->updateSuperfund($xeroTenantId, $superFundID, $superFund, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->updateSuperfund: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK Example for getLeaveApplicationsV2 Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html PHP example using the Xero PHP OAuth2 SDK to call getLeaveApplicationsV2. Requires OAuth2 access token and Xero tenant ID. Demonstrates optional If-Modified-Since, where, order, and page parameters. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $ifModifiedSince = new DateTime("2020-02-06T12:17:43.202-08:00"); $where = "Status==\"ACTIVE\""; $order = "EmailAddress%20DESC"; $page = 56; try { $result = $apiInstance->getLeaveApplicationsV2($xeroTenantId, $ifModifiedSince, $where, $order, $page); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->getLeaveApplicationsV2: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### getTasks PHP SDK Example Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/projects/index.html Retrieves all tasks for a specific project. Supports pagination (page, pageSize), filtering by taskIds, and chargeType. The example shows the required parameters and the API call. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\ProjectApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $projectId = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; $page = 1; $pageSize = 10; $taskIds = "taskIds_example"; $chargeType = ; try { $result = $apiInstance->getTasks($xeroTenantId, $projectId, $page, $pageSize, $taskIds, $chargeType); } catch (Exception $e) { echo 'Exception when calling ProjectApi->getTasks: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK Example for createPayItem Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html PHP example using the Xero PHP SDK to create a pay item. It configures OAuth2, sets up the PayrollAuApi, and constructs a PayItem with earnings rates, deduction types, leave types, and reimbursement types before calling createPayItem. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $idempotencyKey = "KEY_VALUE"; $earningsRate = new XeroAPI\XeroPHP\Models\PayrollAu\EarningsRate; $earningsRate->setName('Ordinary Hours 123'); $earningsRate->setAccountCode('477'); $earningsRate->setTypeOfUnits('Hours'); $earningsRate->setIsExemptFromTax(true); $earningsRate->setIsExemptFromSuper(true); $earningsRate->setIsQualifyingEarnings(false); $earningsRate->setEarningsType(XeroAPI\XeroPHP\Models\PayrollAu\EarningsType::OVERTIMEEARNINGS); $deductionType = new XeroAPI\XeroPHP\Models\PayrollAu\DeductionType; $deductionType->setName('Union Fees'); $deductionType->setAccountCode('826'); $deductionType->setReducesTax(true); $deductionType->setReducesSuper(true); $leaveType = new XeroAPI\XeroPHP\Models\PayrollAu\LeaveType; $leaveType->setName('Annual Leave'); $leaveType->setTypeOfUnits('Hours'); $leaveType->setIsPaidLeave(true); $leaveType->setShowOnPayslip(true); $reimbursementType = new XeroAPI\XeroPHP\Models\PayrollAu\ReimbursementType; $reimbursementType->setName('Annual Leave'); $reimbursementType->setAccountCode('850'); $earningsRates = []; array_push($earningsRates, $earningsRate); $deductionTypes = []; $leaveTypes = []; array_push($leaveTypes, $leaveType); $reimbursementTypes = []; array_push($reimbursementTypes, $reimbursementType); $payItem = new XeroAPI\XeroPHP\Models\PayrollAu\PayItem; $payItem->setEarningsRates($earningsRates); $payItem->setDeductionTypes($deductionTypes); $payItem->setLeaveTypes($leaveTypes); $payItem->setReimbursementTypes($reimbursementTypes); try { $result = $apiInstance->createPayItem($xeroTenantId, $payItem, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->createPayItem: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### getTask PHP SDK Example Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/projects/index.html Retrieves a specific project task by projectId and taskId. Uses OAuth2 access token and ProjectApi. The example shows the required Xero-Tenant-Id header and UUID parameters. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\ProjectApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $projectId = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; $taskId = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; try { $result = $apiInstance->getTask($xeroTenantId, $projectId, $taskId); } catch (Exception $e) { echo 'Exception when calling ProjectApi->getTask: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK example for getAssetById Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/assets/index.html PHP example using the Xero PHP SDK to call getAssetById. Requires OAuth2 access token, Xero tenant ID, and asset ID. Outputs an exception message on failure. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\AssetApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "YOUR_XERO_TENANT_ID"; $id = "00000000-0000-0000-0000-000000000000"; try { $result = $apiInstance->getAssetById($xeroTenantId, $id); } catch (Exception $e) { echo 'Exception when calling AssetApi->getAssetById: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### getTimeEntries PHP SDK Example Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/projects/index.html Retrieves all time entries associated with a specific project. The example shows the required parameters and the API call to ProjectApi->getTimeEntries. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\ProjectApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $projectId = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; $userId = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; $taskId = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; $invoiceId = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; $contactId = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; $page = 1; $pageSize = 10; $states = array() $isChargeable = true; $dateAfterUtc = new DateTime("2013-10-20T19:20:30+01:00"); $dateBeforeUtc = new DateTime("2013-10-20T19:20:30+01:00"); try { $result = $apiInstance->getTimeEntries($xeroTenantId, $projectId, $userId, $taskId, $invoiceId, $contactId, $page, $pageSize, $states, $isChargeable, $dateAfterUtc, $dateBeforeUtc); } catch (Exception $e) { echo 'Exception when calling ProjectApi->getTimeEntries: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Install SDK with Composer: composer require xeroapi/xero-php-oauth2 Source: https://xeroapi.github.io/xero-php-oauth2 Run this command in your project directory to install the Xero PHP OAuth2 SDK via Composer. Requires PHP 8.1 or later. ```bash composer require xeroapi/xero-php-oauth2 ``` -------------------------------- ### Initialize Composer: composer init Source: https://xeroapi.github.io/xero-php-oauth2 Run this command to create a composer.json file if one does not exist. Requires Composer to be installed. ```bash composer init ``` -------------------------------- ### PHP SDK Example for updateTimesheet Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html PHP example using the Xero PHP SDK to update a timesheet. Requires OAuth2 access token and Xero tenant ID. The example sets timesheet properties and calls the API, catching exceptions. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $timesheetID = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c"; $idempotencyKey = "KEY_VALUE"; $startDate = new DateTime('2020-10-23'); $endDate = new DateTime('2020-10-30'); $timesheet = new XeroAPI\XeroPHP\Models\PayrollAu\Timesheet; $timesheet->setEmployeeID('00000000-0000-0000-0000-000000000000'); $timesheet->setStartDate($startDate); $timesheet->setEndDate($endDate); $timesheet->setStatus(XeroAPI\XeroPHP\Models\PayrollAu\TimesheetStatus::DRAFT); try { $result = $apiInstance->updateTimesheet($xeroTenantId, $timesheetID, $timesheet, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->updateTimesheet: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### getFileContent PHP SDK example Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/files/index.html PHP example using XeroAPI\XeroPHP\Api\FilesApi to call getFileContent. Requires OAuth2 access token and xero-tenant-id. The fileId is a UUID. Outputs an exception message on failure. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\FilesApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "YOUR_XERO_TENANT_ID"; $fileId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c"; try { $result = $apiInstance->getFileContent($xeroTenantId, $fileId); } catch (Exception $e) { echo 'Exception when calling FilesApi->getFileContent: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Create a payroll calendar with PayrollAuApi::createPayrollCalendar (PHP) Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html PHP example using the Xero PHP SDK to create a payroll calendar. Configures OAuth2 access token, sets tenant ID and idempotency key, creates a PayrollCalendar object with name, calendar type, start date, and payment date, then calls createPayrollCalendar. Requires the 'payroll.settings' scope. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $idempotencyKey = "KEY_VALUE"; $startDate = new DateTime('2020-10-28'); $paymentDate = new DateTime('2020-10-30'); $payrollCalendar = new XeroAPI\XeroPHP\Models\PayrollAu\PayrollCalendar; $payrollCalendar->setName('Weekly'); $payrollCalendar->setCalendarType(XeroAPI\XeroPHP\Models\PayrollAu\CalendarType::WEEKLY); $payrollCalendar->setStartDate($startDate); $payrollCalendar->setPaymentDate($paymentDate); $payrollCalendars = []; array_push($payrollCalendars, $payrollCalendar); try { $result = $apiInstance->createPayrollCalendar($xeroTenantId, $payrollCalendar, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->createPayrollCalendar: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK Sample for createFileAssociation Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/files/index.html PHP code example using the Xero PHP SDK to call createFileAssociation. Requires a valid OAuth2 access token and Xero tenant ID. The example includes setting up the API client, providing required parameters (fileId, association, idempotencyKey), and handling exceptions. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\FilesApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "YOUR_XERO_TENANT_ID"; $fileId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c"; $idempotencyKey = "KEY_VALUE"; try { $result = $apiInstance->createFileAssociation($xeroTenantId, $fileId, $association, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling FilesApi->createFileAssociation: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK call for getSettings Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html PHP example using XeroAPI\XeroPHP\Api\PayrollAuApi to call getSettings. Requires OAuth2 access token and Xero-Tenant-Id. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; try { $result = $apiInstance->getSettings($xeroTenantId); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->getSettings: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### getFileAssociations PHP SDK example Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/files/index.html PHP example using XeroAPI\XeroPHP\Api\FilesApi to call getFileAssociations. Requires OAuth2 access token and xero-tenant-id. The fileId is a UUID. Outputs an exception message on failure. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\FilesApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "YOUR_XERO_TENANT_ID"; $fileId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c"; try { $result = $apiInstance->getFileAssociations($xeroTenantId, $fileId); } catch (Exception $e) { echo 'Exception when calling FilesApi->getFileAssociations: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Approve a leave application - PHP SDK example Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html PHP example using the Xero PHP SDK to call approveLeaveApplication. Requires OAuth2 access token, Xero-Tenant-Id, and LeaveApplicationID. The idempotency key is optional. Outputs an exception message on failure. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $leaveApplicationID = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c"; $idempotencyKey = "KEY_VALUE"; try { $result = $apiInstance->approveLeaveApplication($xeroTenantId, $leaveApplicationID, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->approveLeaveApplication: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Create Superfund - PHP SDK Example Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html PHP example using XeroAPI\XeroPHP\Api\PayrollAuApi to create a superfund. Requires OAuth2 access token and Xero-Tenant-Id. Sets superfund type to REGULATED and USI. Calls createSuperfund with idempotency key. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $idempotencyKey = "KEY_VALUE"; $superFund = new XeroAPI\XeroPHP\Models\PayrollAu\SuperFund; $superfund->setType(XeroAPI\XeroPHP\Models\PayrollAu\SuperFundType::REGULATED); $superfund->setUSI('40022701955002'); try { $result = $apiInstance->createSuperfund($xeroTenantId, $superFund, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->createSuperfund: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Create Timesheet - PHP SDK Example Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html PHP example using XeroAPI\XeroPHP\Api\PayrollAuApi to create a timesheet. Requires OAuth2 access token and Xero-Tenant-Id. Sets timesheet employee ID, start/end dates, and status to DRAFT. Calls createTimesheet with idempotency key. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $idempotencyKey = "KEY_VALUE"; $startDate = new DateTime('2020-10-23'); $endDate = new DateTime('2020-10-30'); $timesheet = new XeroAPI\XeroPHP\Models\PayrollAu\Timesheet; $timesheet->setEmployeeID('00000000-0000-0000-0000-000000000000'); $timesheet->setStartDate($startDate); $timesheet->setEndDate($endDate); $timesheet->setStatus(XeroAPI\XeroPHP\Models\PayrollAu\TimesheetStatus::DRAFT); try { $result = $apiInstance->createTimesheet($xeroTenantId, $timesheet, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->createTimesheet: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK sample for deleteFile Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/files/index.html PHP example using XeroAPI\XeroPHP\Api\FilesApi to delete a file. Requires OAuth2 access token, Xero tenant ID, and a file ID. The file ID is provided as a UUID example. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\FilesApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "YOUR_XERO_TENANT_ID"; $fileId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c"; try { $apiInstance->deleteFile($xeroTenantId, $fileId); } catch (Exception $e) { echo 'Exception when calling FilesApi->deleteFile: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### getPayRuns - PHP SDK example Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html Retrieves pay runs using the PayrollAuApi. Requires OAuth2 access token and Xero-Tenant-Id. Optional parameters include If-Modified-Since, where, order, and page. The example shows how to call the API and handle exceptions. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $ifModifiedSince = new DateTime("2020-02-06T12:17:43.202-08:00"); $where = "Status=="ACTIVE""; $order = "EmailAddress%20DESC"; $page = 56; try { $result = $apiInstance->getPayRuns($xeroTenantId, $ifModifiedSince, $where, $order, $page); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->getPayRuns: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK sample for createEmployee Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html Shows how to call the PayrollAuApi createEmployee method with OAuth2 access token, tenant ID, idempotency key, and employee details. The example sets up the API client, creates an employee with home address, and handles exceptions. ```PHP setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $idempotencyKey = "KEY_VALUE"; $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->setDateOfBirth($dateOfBirth); $employee->setHomeAddress($homeAddress); try { $result = $apiInstance->createEmployee($xeroTenantId, $employee, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->createEmployee: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK call to getLeaveApplication Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html PHP example using the Xero PHP SDK to retrieve a leave application. Requires OAuth2 access token and Xero tenant ID. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $leaveApplicationID = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c"; try { $result = $apiInstance->getLeaveApplication($xeroTenantId, $leaveApplicationID); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->getLeaveApplication: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK Sample for updateTimeEntry Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/projects/index.html PHP example using the Xero PHP SDK to call the updateTimeEntry method. Requires OAuth2 access token and tenant ID. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\ProjectApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $projectId = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; $timeEntryId = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; $idempotencyKey = "KEY_VALUE"; try { $apiInstance->updateTimeEntry($xeroTenantId, $projectId, $timeEntryId, $timeEntryCreateOrUpdate, $idempotencyKey); } catch (Exception $e) { echo 'Exception when calling ProjectApi->updateTimeEntry: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK sample for deleteFolder Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/files/index.html PHP example using XeroAPI\XeroPHP\Api\FilesApi to call deleteFolder. Requires OAuth2 access token and xero-tenant-id header. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\FilesApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "YOUR_XERO_TENANT_ID"; $folderId = "4ff1e5cc-9835-40d5-bb18-09fdb118db9c"; try { $apiInstance->deleteFolder($xeroTenantId, $folderId); } catch (Exception $e) { echo 'Exception when calling FilesApi->deleteFolder: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### PHP SDK call to getLeaveApplications Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html PHP example using the Xero PHP SDK to retrieve leave applications with optional filters. Requires OAuth2 access token and Xero tenant ID. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $ifModifiedSince = new DateTime("2020-02-06T12:17:43.202-08:00"); $where = "Status==\"ACTIVE\""; $order = "EmailAddress%20DESC"; $page = 56; try { $result = $apiInstance->getLeaveApplications($xeroTenantId, $ifModifiedSince, $where, $order, $page); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->getLeaveApplications: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### getPayrollCalendar - PHP SDK example Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html Retrieves a specific payroll calendar by its ID using the PayrollAuApi. Requires OAuth2 access token, Xero-Tenant-Id, and PayrollCalendarID. The example shows the API call and exception handling. ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $payrollCalendarID = "4ff1e5cc-9835-40d5-bb18-09fdb1189db9"; try { $result = $apiInstance->getPayrollCalendar($xeroTenantId, $payrollCalendarID); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->getPayrollCalendar: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### GET /Projects Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/projects/index.html Retrieves all projects. Use this endpoint to list projects with optional filters. ```APIDOC ## GET /Projects ### Description Retrieves all projects. ### Method GET ### Endpoint /Projects ### Parameters #### Header Parameters - **Xero-Tenant-Id** (String) - Required - Xero identifier for Tenant. #### Query Parameters - **projectIds** (array[UUID]) - Optional - Comma separated list of project IDs to filter by. - **contactID** (UUID) - Optional - Filter for projects for a specific contact. - **states** (String) - Optional - Filter for projects in a particular state (INPROGRESS or CLOSED). - **page** (Integer) - Optional - Page number for pagination (default 1). - **pageSize** (Integer) - Optional - Number of items per page (default 50, max 500). ### Request Example ``` GET /Projects?projectIds=...&contactID=...&states=...&page=1&pageSize=100 ``` ### Response #### Success Response (200) - **projects** (array) - List of projects. #### Response Example ``` { "projects": [ { "projectId": "string", "name": "string" } ] } ``` ``` -------------------------------- ### GET /Settings Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html Retrieves payroll settings. This endpoint requires the Xero-Tenant-Id header and appropriate OAuth2 scopes. ```APIDOC ## GET /Settings ### Description Retrieves payroll settings ### Method GET ### Endpoint /Settings ### Parameters #### Header Parameters - **Xero-Tenant-Id** (String) - Required - Xero identifier for Tenant ### Request Example ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; try { $result = $apiInstance->getSettings($xeroTenantId); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->getSettings: ', $e->getMessage(), PHP_EOL; } ?> ``` ### Response #### Success Response (200) - **Settings** (object) - The payroll settings object #### Response Example ```json { "settings": {} } ``` ``` -------------------------------- ### GET /Files Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/files/index.html Retrieves a list of files. Supports pagination, sorting, and direction parameters. ```APIDOC ## GET /Files ### Description Retrieves a list of files. ### Method GET ### Endpoint /Files ### Parameters #### Header Parameters - **xero-tenant-id** (String) - Required - Xero identifier for Tenant #### Query Parameters - **pagesize** (Integer) - Optional - pass an optional page size value - **page** (Integer) - Optional - number of records to skip for pagination - **sort** (String) - Optional - values to sort by - **direction** (String) - Optional - sort direction ### Request Example ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\FilesApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "YOUR_XERO_TENANT_ID"; $pagesize = 50; $page = 2; $sort = "CreatedDateUTC"; $direction = "ASC"; try { $result = $apiInstance->getFiles($xeroTenantId, $pagesize, $page, $sort, $direction); } catch (Exception $e) { echo 'Exception when calling FilesApi->getFiles: ', $e->getMessage(), PHP_EOL; } ?> ``` ### Response #### Success Response (200) No response schema provided in the source. #### Response Example No response example provided in the source. ### Scopes - files - Grant read-write access to files and folders - files.read - Grant read-only access to files and folders ``` -------------------------------- ### GET /LeaveApplications Source: https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html Retrieves a list of leave applications. Requires the payroll.employees or payroll.employees.read scope. ```APIDOC ## GET /LeaveApplications ### Description Retrieves leave applications. ### Method GET ### Endpoint /LeaveApplications ### Parameters #### Header Parameters - **Xero-Tenant-Id** (string) - Required - Xero identifier for Tenant - **If-Modified-Since** (date-time) - Optional - Only records created or modified since this timestamp will be returned #### Query Parameters - **where** (string) - Optional - Filter by an any element - **order** (string) - Optional - Order by an any element - **page** (integer) - Optional - e.g. page=1 – Up to 100 objects will be returned in a single API call ### Request Example ```php setAccessToken( 'YOUR_ACCESS_TOKEN' ); $apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuApi( new GuzzleHttp\Client(), $config ); $xeroTenantId = "xeroTenantId_example"; $ifModifiedSince = new DateTime("2020-02-06T12:17:43.202-08:00"); $where = "Status==\"ACTIVE\""; $order = "EmailAddress%20DESC"; $page = 56; try { $result = $apiInstance->getLeaveApplications($xeroTenantId, $ifModifiedSince, $where, $order, $page); } catch (Exception $e) { echo 'Exception when calling PayrollAuApi->getLeaveApplications: ', $e->getMessage(), PHP_EOL; } ?> ``` ### Response #### Success Response (200) - **LeaveApplications** (array) - The list of leave applications #### Response Example ```json { "LeaveApplications": [] } ``` ### Scopes - payroll.employees - Grant read-write access to payroll employees - payroll.employees.read - Grant read-only access to payroll employees ```