chargebee-python
chargebee-python copied to clipboard
Attributes are not persisted when assigned on an object
When a field on an object is assigned, the value is not persisted down to the values
dict on the object. I suspect this is probably due to the fact that setattr
is being used to populate the fields on initialization, so it's not able to be overloaded.
Unfortunately, this makes using the object basically useless, since they can't really be updated given the currently available methods.
Example:
subscription = chargebee.Subscription.retrieve('subscriptionId')
assert subscription.plan_id == 'oldPlanId' # this passes
subscription.plan_id = 'newPlanId'
serializedSub = json.loads(str(subscription))
assert serializedSub['plan_id'] == 'newPlanId # this fails
It would be nice to provide a way for the attributes of the object to be "serialized" into a dict that can be passed to the update
call of a chargebee model, or implement some sort of update
that can be called on the object itself, rather than passing in the id and update params.