client.companies.users(...) returns a list of intercom.company.Company
Is this the intended behavior? Seems to cause issues when trying to save the user data back to Intercom.
Hey @jarcoal 👋 companies.users(<company_id>) should be returning a collection that will contain all of the users belonging to a specific company:
>>> intercom.companies.users(company_id)
<intercom.collection_proxy.CollectionProxy object at 0x7f582fc78128>
>>> for user in intercom.companies.users(company_id):
... print(user.name)
...
Steven Hyde
Michael Kelso
>>>
What arguments are you passing when experiencing this and what's the object that you're being presented with?
Try checking user.__class__. For me it's returning companies, not users, even though the data within is the user's data. In my code I've had to extract the user ID and re-wrap it in a User model.
Ah, got it - you're referring to each of the users returned. Yep, that's how this is defined in here.
I do understand now how this can cause issues while trying to update all of the users belonging to a company like this:
>>> for user in intercom.companies.users(company_id):
... user.custom_attributes["newCDA"] = "yup"
... intercom.users.save(user)
...
<intercom.company.Company object at 0x7f109be4d710>
☝️ That will actually update the company rather than the user - nice catch here!
Exactly, it tries to send the save request to the wrong URL. Thanks for looking into that!
I am facing with the same behavior in v3.1.0. Will there be a new version for this fix soon?