xero-php
xero-php copied to clipboard
Get all Assets - Call to undefined method
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>';
Which is the undefined method?
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 :)
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.
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?