Skip to content

Instantly share code, notes, and snippets.

@looneym
Created February 20, 2017 16:35
Show Gist options
  • Save looneym/18b975e8de3ada0c188bba87f4f60dc9 to your computer and use it in GitHub Desktop.
Save looneym/18b975e8de3ada0c188bba87f4f60dc9 to your computer and use it in GitHub Desktop.
Add and remove companies from an Intercom user
# get a user
user = intercom.users.find(email: "bob@example.com")
# add a company to that user
user.companies = [{company_id: 6, name: "Intercom"},]
intercom.users.save(user)
puts user.companies[0].name # "Intercom"
#remove the same company
user.companies = [{company_id: 6, name: "Intercom", remove: true},]
intercom.users.save(user)
puts user.companies[0].name # This will crash as the user has no companies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment