User tagging refactored #22

Merged
merged 6 commits into from Apr 3, 2013

Conversation

Projects
None yet
4 participants
Member

erskingardner commented Mar 26, 2013

No description provided.

@darragh darragh commented on an outdated diff Mar 28, 2013

lib/intercom/tag.rb
+ ##
+ # Represents a tag
+ #
+ # A tag consists of a name, and (optionally) a color and users that you would like to tag.
+ #
+ # == Examples
+ #
+ # tag = Intercom::Tag.create(:name => "Super Tag", :color => "red", :user_ids => ['abc123', 'def456'])
+ # tag = Intercom::Tag.create(:name => "Super Tag", :color => "red", :emails => ['bob@example.com', 'joe@example.com'])
+ #
+ # You can also create a tag and save it like this:
+ # tag = Intercom::Tag.new
+ # tag.name = "Super Tag"
+ # tag.color = "red"
+ # tag.user_ids = ['abc123', 'def456']
+ # tag.save
@darragh

darragh Mar 28, 2013

Owner

An example of adding a user to an existing tag would be useful: would that be something like:

tag = Intercom::Tag.find_by_name("Super Tag")
tag.user_ids << 'user123abc'
tag.save

or would it be something else?

Owner

darragh commented Mar 28, 2013

Looks good, just one suggestion/question about how to tag users with existing tags.

Contributor

benmcredmond commented Apr 3, 2013

🚢

@theirishpenguin theirishpenguin commented on the diff Apr 3, 2013

lib/intercom/tag.rb
+ ##
+ # An array of user_ids of the users you'd like to tag or untag
+ def user_ids=(user_ids)
+ @attributes["user_ids"] = user_ids
+ end
+
+ ##
+ # An array of emails of the users you'd like to tag or untag
+ def emails=(emails)
+ @attributes["emails"] = emails
+ end
+
+ ##
+ # A string to specify whether to tag or untag the specified users, can be left out if only creating a new tag.
+ def tag_or_untag=(tag_or_untag)
+ return unless ["tag", "untag"].include?(tag_or_untag)
@theirishpenguin

theirishpenguin Apr 3, 2013

Contributor

Small thought. Should we raise an error here if someone passes in something like 'tagg' typo? Maybe not.

Contributor

theirishpenguin commented Apr 3, 2013

👍

erskingardner merged commit 7e2d8f3 into master Apr 3, 2013

1 check failed

default The Travis build failed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment