public BoxGroupMembership . Info addMembership ( BoxUser user , Role role ) { BoxAPIConnection api = this . getAPI ( ) ; JsonObject requestJSON = new JsonObject ( ) ; requestJSON . add ( "user" , new JsonObject ( ) . add ( "id" , user . getID ( ) ) ) ; requestJSON . add ( "group" , new JsonObject ( ) . add ( "id" , this . getID ( ) ) ) ; if ( role != null ) { requestJSON . add ( "role" , role . toJSONString ( ) ) ; } URL url = ADD_MEMBERSHIP_URL_TEMPLATE . build ( api . getBaseURL ( ) ) ; BoxJSONRequest request = new BoxJSONRequest ( api , url , "POST" ) ; request . setBody ( requestJSON . toString ( ) ) ; BoxJSONResponse response = ( BoxJSONResponse ) request . send ( ) ; JsonObject responseJSON = JsonObject . readFrom ( response . getJSON ( ) ) ; BoxGroupMembership membership = new BoxGroupMembership ( api , responseJSON . get ( "id" ) . asString ( ) ) ; return membership . new Info ( responseJSON ) ; }
Adds a member to this group with the specified role .