Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
106 lines (74 sloc) 3.14 KB

Comments

Comment objects represent a user-created comment on a file. They can be added directly to a file or they can be a reply to another comment.

Get a Comment's Information

Calling getInfo() on a comment returns a snapshot of the comment's info.

BoxComment comment = new BoxComment(api, "id");
BoxComment.Info info = comment.getInfo();

Get the Comments on a File

You can get all of the comments on a file by calling the getComments() method.

BoxFile file = new BoxFile(api, "id");
List<BoxComment.Info> comments = file.getComments();

Add a Comment to a File

A comment can be added to a file with the addComment(String message) method.

BoxFile file = new BoxFile(api, "id");
file.addComment("This file is pretty cool.");

The comment's message can also contain @mentions by using the string @[userid:username] anywhere within the message, where userid and username are the ID and username of the person being mentioned. [See the documentation] (https://developers.box.com/docs/#comments-comment-object) on the tagged_message field for more information on @mentions.

BoxFile file = new BoxFile(api, "id");
file.addComment("Message mentioning @[1234:user@box.com].");

Reply to a Comment

You can reply to a comment with the reply(String message) method.

BoxComment comment = new BoxComment(api, "id");
comment.reply("A reply to another comment.");

Change a Comment's Message

The message of a comment can be changed with the changeMessage(String message) method.

BoxComment comment = new BoxComment(api, "id");
comment.changeMessage("An edited message.");

Delete a Comment

A comment can be deleted with the delete() method.

BoxComment comment = new BoxComment(api, "id");
comment.delete();