python-intercom and self fields
Intercom’s docs state the following:
All objects in the API have an id field indicating their logical identifier. Some objects may optionally also have a self field that indicates a URL or canonical address for the object.
self
A URL that addresses the object within the API. The self field will not be larger than 255 characters (in SQL it corresponds to a varchar(255)).
Both fields id and self hold special significance in Python.
The current version of python-intercom allows fields called id e.g. user.id
. I could add similar support for self e.g. user.self
but it feels wrong.
Alternatives
I can only think of two semi-sensible alternatives:
- rename to
_id
and_self
– this doesn’t sit well either as they are not intended to be private - remove
__getattribute__
and__setattr__
support and just use__getitem__
i.e. instead ofuser.id
we useuser['id']
anduser['self']
. This is clean but will break whatever code is out there using.id
.
Right here, right now
I am going to add support for .self
for initial release. Keeping to a familiar programming model is the most important thing right now.
Feedback
I’ve opened an issue on GitHub to track any feedback.