We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Dec 3, 2021 11:11 AM
Using the PHP hubspot/api-client composer package.
composer require hubspot/api-client
Most API calls have been working great, but I'm running into some issues with Line Items. I'm basing my code off of the samples from here: https://developers.hubspot.com/docs/api/crm/line-items
But I'm finding that SimplePublicObjectInput is not a defined object. I'm not seeing anybody else with this issue, so I'm guessing I am overlooking something obvious! Here's my code snippet:
use HubSpot\Factory;
use HubSpot\Client\Crm\LineItems\ApiException;
class lineitem
{
private function hs_createNewTaxLineItem()
{
$client = Factory::createWithApiKey(HUBSPOT_API_KEY);
$properties = [
"hs_product_id" => HS_SALES_TAX_PRODUCT_ID,
"quantity" => "1",
"price" => 99.98
];
$SimplePublicObjectInput = new SimplePublicObjectInput(['properties' => $properties]);
try {
$apiResponse = $client->crm()->lineItems()->basicApi()->create($SimplePublicObjectInput);
var_dump($apiResponse);
} catch (ApiException $e) {
echo "Exception when calling basic_api->create: ", $e->getMessage();
}
}
It returns the error:
Fatal error: Uncaught Error: Class 'SimplePublicObjectInput' not found in...
Any ideas?
Dec 3, 2021 11:29 AM
Playing around with this a little more....
This does NOT work for creating the object:
$SimplePublicObjectInput = new SimplePublicObjectInput(['properties' => $properties]);
But I CAN create the object like this:
$SimplePublicObjectInput = new \HubSpot\Client\Crm\LineItems\Model\SimplePublicObjectInput(['properties' => $properties]);
Is this normal way to code this?
The only other way I can access this object is if I literally specify it in the use statement
use HubSpot\Client\Crm\LineItems\Model\SimplePublicObjectInput;