While I can set a Sales Setting/Category for a Contact through the UI, I can't seem to do this via the Calcinai PHP library.
I'm using v1.x at the moment and have done for other Contact creates/updates for a couple of years now.
Firstly, should it even be possible to set a Tracking Category selection on a Contact via the API (the Category and Options have already been defined). Most of the tracking category questions here are in relation to Invoicing, not Contact.
There are various hints in Contact.php that this should be possible and I've tried a number of combinations, but just can't get it working.
I'm a little concerned that the name of the elements in returned Contact payload via the API Previewer don't have the same element names in the Models e.g.
<SalesTrackingCategories>
<SalesTrackingCategory>
<TrackingCategoryName>Gift Aid</TrackingCategoryName>
<TrackingOptionName>Declined</TrackingOptionName>
</SalesTrackingCategory>
</SalesTrackingCategories>
!=
'Name' => [false, self::PROPERTY_TYPE_STRING, null, false, false],
'Status' => [false, self::PROPERTY_TYPE_STRING, null, false, false],
'Options' => [false, self::PROPERTY_TYPE_OBJECT, 'Accounting\\TrackingCategory\\TrackingOption', true, true],
'Option' => [false, self::PROPERTY_TYPE_STRING, null, false, true]
I see there's a mention of a 'dirty hack' in Helpers.php, but that alone doesn't seem to solve my problem.
Again, I've tried a number of things, including:
$TrackingOption = new XeroPHP\Models\Accounting\TrackingCategory\TrackingOption();
$TrackingOption->setTrackingOptionID("37ae930d-f576-44fc-b1d8-86b7f96c0205");
$TrackingCategory = new TrackingCategory();
$TrackingCategory->setTrackingCategoryID("4031ea9e-37a0-40cb-8539-d3127a501828");
$TrackingCategory->addOption($TrackingOption);
$contact->setName($contactname)
->setFirstName($primarypersonfirst)
->setLastName($primarypersonlast)
->setEmailAddress($primarypersonemail)
->setContactStatus(\XeroPHP\Models\Accounting\Contact::CONTACT_STATUS_ACTIVE)
->setContactNumber($contactnumber)
->addSalesTrackingCategory($TrackingCategory)
Has anyone managed to get this going? I would be very appreciative of any pointers.