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

client.companies.users(...) returns a list of intercom.company.Company #180

Open
jarcoal opened this issue Feb 7, 2018 · 5 comments
Open

Comments

@jarcoal
Copy link

jarcoal commented Feb 7, 2018

Is this the intended behavior? Seems to cause issues when trying to save the user data back to Intercom.

@tanasegabriel
Copy link
Contributor

tanasegabriel commented Mar 1, 2018

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?

@jarcoal
Copy link
Author

jarcoal commented Mar 1, 2018

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.

@tanasegabriel
Copy link
Contributor

tanasegabriel commented Mar 1, 2018

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!

@jarcoal
Copy link
Author

jarcoal commented Mar 1, 2018

Exactly, it tries to send the save request to the wrong URL. Thanks for looking into that!

@mehmetgencolatug
Copy link

I am facing with the same behavior in v3.1.0. Will there be a new version for this fix soon?

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

3 participants