xero-php icon indicating copy to clipboard operation
xero-php copied to clipboard

Get all Assets - Call to undefined method

Open andrewvink opened this issue 5 years ago • 4 comments

Trying to GET all Assets via a Private App

Not sure if I'm doing it correctly... as I get a call to undefined method.

Here's what I have so far. Please could you send me an example.

require 'vendor/autoload.php';

use XeroPHP\Application\PrivateApplication;
use XeroPHP\Models\Assets\AssetType;

$config = [
    'oauth' => [
        'callback' => 'http://localhost/',
        'consumer_key' => 'XXXXXXXXXXXXXXXXXXXXX',
        'consumer_secret' => 'XXXXXXXXXXXXXXXXXXXXX',
        'rsa_private_key' => 'file://certs/privatekey.pem',
    ],
];

$xero = new PrivateApplication($config);

$assets = $xero->load('Assets\\AssetType')->execute();


echo '<pre>';
print_r($assets);
echo '</pre>';


andrewvink avatar Aug 29 '19 16:08 andrewvink

Which is the undefined method?

calcinai avatar Aug 30 '19 00:08 calcinai

Running the above gives me:


Fatal error: Uncaught Error: Call to undefined method XeroPHP\Remote\Query::getfixedAssetAccountId() in /home/vagrant/xero/assets.php on line 21

Error: Call to undefined method XeroPHP\Remote\Query::getfixedAssetAccountId() in /home/vagrant/xero/assets.php on line 21


I'm trying to get a full list of assets, and then update the 'assetStatus' - are there any examples I can look at to do that?

Thanks for your help :)

andrewvink avatar Aug 30 '19 15:08 andrewvink

You'll have to provide the code snippet that calls this function, i.e. assets.php around line 21. Looks like you are calling it on the wrong object.

timacdonald avatar Sep 01 '19 05:09 timacdonald

Hey Guys,

Thanks for the help so far!

Sorry still learning, so trying to figure out how to write the script to call all the assets...?

I've been guessing on how to do this to be honest with the snippet above by looking at other examples, but don't have enough knowledge yet of OOP to get it right.

Looking at the other models it looks like there should be a Models\Assets\Asset.php file in order to query all assets, that's at least if I follow the pattern of the other files or models - but I'm more than likely am getting this wrong.

What I'm trying to do - but don't know how to do it:

  • Query a full list of assets
  • Update & save the 'assetStatus' to draft

Could you possibly send me an example snippet on how to do this?

andrewvink avatar Sep 02 '19 07:09 andrewvink