Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attributes are not persisted when assigned on an object #35

Open
sjyn opened this issue Feb 16, 2021 · 0 comments
Open

Attributes are not persisted when assigned on an object #35

sjyn opened this issue Feb 16, 2021 · 0 comments

Comments

@sjyn
Copy link

sjyn commented Feb 16, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant