@@ -26,6 +26,10 @@ public static Tag tag(Tag tag, User... users) throws InvalidException, Authoriza
2626 return tag (tag , new UserCollection (Lists .newArrayList (users )));
2727 }
2828
29+ public static Tag tag (Tag tag , Contact ... contacts ) throws InvalidException , AuthorizationException {
30+ return tag (tag , new ContactCollection (Lists .newArrayList (contacts )));
31+ }
32+
2933 public static Tag tag (Tag tag , Company ... companies ) throws InvalidException , AuthorizationException {
3034 return tag (tag , new CompanyCollection (Lists .newArrayList (companies )));
3135 }
@@ -35,6 +39,11 @@ static Tag tag(Tag tag, UserCollection users) throws InvalidException, Authoriza
3539 return DataResource .create (taggableCollection , "tags" , Tag .class );
3640 }
3741
42+ static Tag tag (Tag tag , ContactCollection contacts ) throws InvalidException , AuthorizationException {
43+ TaggableCollection taggableCollection = createTagTypedCollection (tag , contacts );
44+ return DataResource .create (taggableCollection , "tags" , Tag .class );
45+ }
46+
3847 static Tag tag (Tag tag , CompanyCollection companies ) throws InvalidException , AuthorizationException {
3948 TaggableCollection taggableCollection = createTagTypedCollection (tag , companies );
4049 return DataResource .create (taggableCollection , "tags" , Tag .class );
@@ -97,6 +106,32 @@ static TaggableCollection createTagTypedCollection(Tag tag, UserCollection users
97106 return taggableCollection ;
98107 }
99108
109+ @ VisibleForTesting
110+ static TaggableCollection createTagTypedCollection (Tag tag , ContactCollection contacts ) {
111+ TaggableCollection taggableCollection = new TaggableCollection ();
112+ taggableCollection .setName (tag .getName ());
113+ taggableCollection .setId (tag .getId ());
114+ final List <Map <String , Object >> contactsLite = Lists .newArrayList ();
115+ final List <Contact > pageItems = contacts .getPage ();
116+ for (Contact contact : pageItems ) {
117+ Map <String , Object > contactMap = Maps .newHashMap ();
118+ final String id = contact .getID ();
119+
120+ if (contact .isUntag ()) {
121+ contactMap .put ("untag" , true );
122+ }
123+
124+ if (!Strings .isNullOrEmpty (id )) {
125+ contactMap .put ("id" , id );
126+ contactsLite .add (contactMap );
127+ } else {
128+ logger .warn ("no identifiers found for user tag target, skipping [" + tag + "] [" + contact .toString () + "]" );
129+ }
130+ }
131+ taggableCollection .setUsers (contactsLite );
132+ return taggableCollection ;
133+ }
134+
100135 @ VisibleForTesting
101136 static TaggableCollection createTagTypedCollection (Tag tag , CompanyCollection companies ) {
102137 TaggableCollection taggableCollection = new TaggableCollection ();
0 commit comments