Tagging API seems odd, or maybe needs more documentation
- intercom-java version: 2.8.2
The README documentation shows how to create a Tag and use it to tag users. However, the vast majority of time, an existing tag will be used. It's not obvious from the documentation how we're supposed to use a tag without creating one.
We can obtain a Tag object by iterating all of the tags. This seems slow and expensive.
There's new Tag().setName() but there's no way to set the id. Is the id necessary for tagging users and companies? It doesn't seem to be in the underlying rest api, but the Java code seems to use it.
Would love some clarification. Thanks.
To add some experimental results:
It appears that new Tag().setName() is enough to create a tag for tagging, though there's a really weird problem. If you want to untag, you set untag() on the company/user that you pass into the Tag.tag(tag, company). But this creates a one-way mutation of the Company/User. If I want to perform a series of tags/untags, I have to construct a new Company for each one.
I guess it works, but it's a bit clunky.
To illustrate, this appears to be the code necessary:
public static void tag(final String companyId, final String tagName, final boolean present) {
final Company company = new Company().setCompanyID(companyId);
if (!present) {
company.untag();
}
final Tag tag = new Tag().setName(tagName);
Tag.tag(tag, company);
}