Yet these properties are transformed into camelCase, leading to confusion when transforming these instances ->toArray() and expecting the same response that the API documentation displays:
Since the InstanceResource classes already use a magic __get(), could we preserve the structure of the API response in $properties and then snake the requested $property?
public function __get($property)
{
$property = strtolower(preg_replace('/(.)(?=[A-Z])/u', '$1_', $property));
return $this->properties[$property] ?? null;
}
This would also remove the need to parse the payload and camelCase all of their properties manually (even though this is automated via your API generation tool).
The Twilio API documentation shows PHP examples with return structures containing properties that are
snake_case
:https://www.twilio.com/docs/usage/api/applications
Yet these properties are transformed into
camelCase
, leading to confusion when transforming these instances->toArray()
and expecting the same response that the API documentation displays:https://github.com/twilio/twilio-php/blob/10c7f8b6f4719c23c6e90c9b2e28ebdb735aea48/src/Twilio/Rest/Api/V2010/Account/ApplicationInstance.php#L54-L60
Since the
InstanceResource
classes already use a magic__get()
, could we preserve the structure of the API response in$properties
and then snake the requested$property
?This would also remove the need to parse the payload and
camelCase
all of their properties manually (even though this is automated via your API generation tool).Thanks for your time!