If you are enumerating the line items in an invoice and an item is an adhoc type, trying to access the entityId attribute crashes rather than returning null.
As per the docs:
entityId - The identifier of the modelled entity this lineitem is based on. Will be null for 'adhoc' entity type.
When I try to access this item, I get:
Unknown property entityId in ChargeBee_InvoiceLineItem
Based on the documentation, I'd expect to get it returned as "null", rather than throwing that exception. With that said, I dug into your API code and modified ChargeBee_Model::__get to dump $this->_data and $this->allowed. I then see this:
The issue here is that the check for the value (and ChargeBee_Model::$_data) uses camel case while ChargeBee_Model::$allowed uses underscores. I honestly don't understand why you implemented the conversion, but since you did, you have to do the conversion when checking $allowed. I'd also surmise that the server should be returning a null entity_id, but that is a separate issue.
This pull request fixes the allowed check to check based on underscores instead of camel case so if you access an attribute that is allowed, but null, it does not crash.
If you are enumerating the line items in an invoice and an item is an
adhoc
type, trying to access theentityId
attribute crashes rather than returningnull
.As per the docs:
When I try to access this item, I get:
Based on the documentation, I'd expect to get it returned as "
null
", rather than throwing that exception. With that said, I dug into your API code and modifiedChargeBee_Model::__get
to dump$this->_data
and$this->allowed
. I then see this:The issue here is that the check for the value (and
ChargeBee_Model::$_data
) uses camel case whileChargeBee_Model::$allowed
uses underscores. I honestly don't understand why you implemented the conversion, but since you did, you have to do the conversion when checking$allowed
. I'd also surmise that the server should be returning a nullentity_id
, but that is a separate issue.This pull request fixes the allowed check to check based on underscores instead of camel case so if you access an attribute that is allowed, but
null
, it does not crash.