Created
February 20, 2017 16:35
-
-
Save looneym/18b975e8de3ada0c188bba87f4f60dc9 to your computer and use it in GitHub Desktop.
Add and remove companies from an Intercom user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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