xero-php-oauth2 Asset SDK Docs

# Xero Assets API

## SDK Documentation

# Asset

# createAsset

adds a fixed asset

Adds an asset to the system

    /Assets

### Usage and SDK Samples

    <?php
    require_once(__DIR__ . '/vendor/autoload.php');

    // Configure OAuth2 access token for authorization: OAuth2
    $config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );

    $apiInstance = new XeroAPI\XeroPHP\Api\AssetApi(
        new GuzzleHttp\Client(),
        $config
    );
    $xeroTenantId = "YOUR_XERO_TENANT_ID";

    $asset = new XeroAPI\XeroPHP\Models\Asset\Asset;
    $asset->setassetName('Other Computer');
    $asset->setassetNumber('FA-00210');
    $asset->setStatus(XeroAPI\XeroPHP\Models\Asset\AssetStatus::Draft);

    try {
      $result = $apiInstance->createAsset($xeroTenantId, $asset);
    } catch (Exception $e) {
      echo 'Exception when calling AssetApi->createAsset: ', $e->getMessage(), PHP_EOL;
    }
    ?>

## Scopes

assets | Grant read-write access to fixed assets

## Parameters

Header parameters

Name | Description
--- | ---
xero-tenant-id* | String Xero identifier for Tenant Required

Body parameters

Name | Description
--- | ---
asset * | Asset Fixed asset you are creating Required

# createAssetType

adds a fixed asset type

Adds an fixed asset type to the system

    /AssetTypes

### Usage and SDK Samples

    <?php
    require_once(__DIR__ . '/vendor/autoload.php');

    // Configure OAuth2 access token for authorization: OAuth2
    $config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );

    $apiInstance = new XeroAPI\XeroPHP\Api\AssetApi(
        new GuzzleHttp\Client(),
        $config
    );
    $xeroTenantId = "YOUR_XERO_TENANT_ID";

    $bookDepreciationSetting = new XeroAPI\XeroPHP\Models\Asset\BookDepreciationSetting;
    $bookDepreciationSetting->setDepreciationMethod('DiminishingValue100');
    $bookDepreciationSetting->setAveragingMethod('ActualDays');
    $bookDepreciationSetting->setDepreciationRate(40);
    $bookDepreciationSetting->setDepreciationCalculationMethod('None');

    $assetType = new XeroAPI\XeroPHP\Models\Asset\AssetType;
    $assetType->setAssetTypeName('Computer Equipment');
    $assetType->setFixedAssetAccountId('00000000-0000-0000-0000-000000000000');
    $assetType->setDepreciationExpenseAccountId('00000000-0000-0000-0000-000000000000');
    $assetType->setAccumulatedDepreciationAccountId('00000000-0000-0000-0000-000000000000');
    $assetType->setBookDepreciationSetting($bookDepreciationSetting);

    try {
      $result = $apiInstance->createAssetType($xeroTenantId, $assetType);
    } catch (Exception $e) {
      echo 'Exception when calling AssetApi->createAssetType: ', $e->getMessage(), PHP_EOL;
    }
    ?>

## Scopes

assets | Grant read-write access to fixed assets

## Parameters

Header parameters

Name | Description
--- | ---
xero-tenant-id* | String Xero identifier for Tenant Required

Body parameters

Name | Description
--- | ---
assetType | AssetType Asset type to add

# getAssetById

Retrieves fixed asset by id

By passing in the appropriate asset id, you can search for a specific fixed asset in the system

    /Assets/{id}

### Usage and SDK Samples

    <?php
    require_once(__DIR__ . '/vendor/autoload.php');

    // Configure OAuth2 access token for authorization: OAuth2
    $config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->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;
    }
    ?>

## Scopes

assets | Grant read-write access to fixed assets
assets.read | Grant read-only access to fixed assets

## Parameters

Path parameters

Name | Description
--- | ---
id* | UUID (uuid) fixed asset id for single object Required

Header parameters

Name | Description
--- | ---
xero-tenant-id* | String Xero identifier for Tenant Required

# getAssetSettings

searches fixed asset settings

By passing in the appropriate options, you can search for available fixed asset types in the system

    /Settings

### Usage and SDK Samples

    <?php
    require_once(__DIR__ . '/vendor/autoload.php');

    // Configure OAuth2 access token for authorization: OAuth2
    $config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->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;
    }
    ?>

## Scopes

assets | Grant read-write access to fixed assets
assets.read | Grant read-only access to fixed assets

## Parameters

Header parameters

Name | Description
--- | ---
xero-tenant-id* | String Xero identifier for Tenant Required

# getAssetTypes

searches fixed asset types

By passing in the appropriate options, you can search for available fixed asset types in the system

    /AssetTypes

### Usage and SDK Samples

    <?php
    require_once(__DIR__ . '/vendor/autoload.php');

    // Configure OAuth2 access token for authorization: OAuth2
    $config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );

    $apiInstance = new XeroAPI\XeroPHP\Api\AssetApi(
        new GuzzleHttp\Client(),
        $config
    );
    $xeroTenantId = "YOUR_XERO_TENANT_ID";

    try {
      $result = $apiInstance->getAssetTypes($xeroTenantId);
    } catch (Exception $e) {
      echo 'Exception when calling AssetApi->getAssetTypes: ', $e->getMessage(), PHP_EOL;
    }
    ?>

## Scopes

assets | Grant read-write access to fixed assets
assets.read | Grant read-only access to fixed assets

## Parameters

Header parameters

Name | Description
--- | ---
xero-tenant-id* | String Xero identifier for Tenant Required

# getAssets

searches fixed asset

By passing in the appropriate options, you can search for available fixed asset in the system

    /Assets

### Usage and SDK Samples

    <?php
    require_once(__DIR__ . '/vendor/autoload.php');

    // Configure OAuth2 access token for authorization: OAuth2
    $config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );

    $apiInstance = new XeroAPI\XeroPHP\Api\AssetApi(
        new GuzzleHttp\Client(),
        $config
    );
    $xeroTenantId = "YOUR_XERO_TENANT_ID";
    $status = ;
    $page = 1;
    $pageSize = 5;
    $orderBy = "AssetName";
    $sortDirection = "ASC";
    $filterBy = "Company Car";

    try {
      $result = $apiInstance->getAssets($xeroTenantId, $status, $page, $pageSize, $orderBy, $sortDirection, $filterBy);
    } catch (Exception $e) {
      echo 'Exception when calling AssetApi->getAssets: ', $e->getMessage(), PHP_EOL;
    }
    ?>

## Scopes

assets | Grant read-write access to fixed assets
assets.read | Grant read-only access to fixed assets

## Parameters

Header parameters

Name | Description
--- | ---
xero-tenant-id* | String Xero identifier for Tenant Required

Query parameters

Name | Description
--- | ---
status* | AssetStatusQueryParam Required when retrieving a collection of assets. See Asset Status Codes Required
page | Integer Results are paged. This specifies which page of the results to return. The default page is 1.
pageSize | Integer The number of records returned per page. By default the number of records returned is 10.
orderBy | String Requests can be ordered by AssetType, AssetName, AssetNumber, PurchaseDate and PurchasePrice. If the asset status is DISPOSED it also allows DisposalDate and DisposalPrice.
sortDirection | String ASC or DESC
filterBy | String A string that can be used to filter the list to only return assets containing the text. Checks it against the AssetName, AssetNumber, Description and AssetTypeName fields.