public BoxTask . Info addTask ( BoxTask . Action action , String message , Date dueAt ) { JsonObject itemJSON = new JsonObject ( ) ; itemJSON . add ( "type" , "file" ) ; itemJSON . add ( "id" , this . getID ( ) ) ; JsonObject requestJSON = new JsonObject ( ) ; requestJSON . add ( "item" , itemJSON ) ; requestJSON . add ( "action" , action . toJSONString ( ) ) ; if ( message != null && ! message . isEmpty ( ) ) { requestJSON . add ( "message" , message ) ; } if ( dueAt != null ) { requestJSON . add ( "due_at" , BoxDateFormat . format ( dueAt ) ) ; } URL url = ADD_TASK_URL_TEMPLATE . build ( this . getAPI ( ) . getBaseURL ( ) ) ; BoxJSONRequest request = new BoxJSONRequest ( this . getAPI ( ) , url , "POST" ) ; request . setBody ( requestJSON . toString ( ) ) ; BoxJSONResponse response = ( BoxJSONResponse ) request . send ( ) ; JsonObject responseJSON = JsonObject . readFrom ( response . getJSON ( ) ) ; BoxTask addedTask = new BoxTask ( this . getAPI ( ) , responseJSON . get ( "id" ) . asString ( ) ) ; return addedTask . new Info ( responseJSON ) ; }
Adds a new task to this file . The task can have an optional message to include and a due date .