Terms of Service allows Box Admins to configure a custom Terms of Service for end users to accept/re-accept/decline for custom applications
- Create a Terms of Service
- Edit a Terms of Service
- Get a Terms of Service
- Get All Terms of Services
- Accept or Decline a Terms of Service for New User
- Accept or Decline a Terms of Service for Existing User
- Get User Status on a Terms of Service
A terms of service can be created in an enterprise. Please note that only two can be created. One external and one managed. If a terms of service already exists please use the update call to change the current terms of service.
You can create a custom terms of service by calling
create(BoxAPIConnection api, BoxTermsOfService.TermsOfServiceStatus status, BoxTermsOfService.TermsOfServiceType type, String text)
.
BoxTermsOfService.Info newTOS = BoxTermsOfService.create(
api,
BoxTermsOfService.TermsOfServiceStatus.ENABLED,
BoxTermsOfService.TermsOfServiceType.EXTERNAL,
"Terms of Service..."
);
You can update a terms of service status and text after you have created them by calling
updateInfo(BoxTermsOfService.Info fieldsToUpdate)
BoxTermsOfService termsOfService = new BoxTermsOfService(api, "tos-id");
BoxTermsOfService.Info termsOfServiceInfo = termsOfService.new Info();
termsOfServiceInfo.setStatus(BoxTermsOfService.TermsOfServiceStatus.DISABLED);
termsOfServiceInfo.setText("New Terms of Service Text");
termsOfService.updateInfo(termsOfService);
You can retrieve a terms of service by providing the ID and calling
getInfo()
.
BoxTermsOfService termsOfService = new BoxTermsOfService(api, "tos-id");
BoxTermsOfService.Info tosInfo = termsOfService.getInfo();
You can also retrieve all terms of service in your enterprise by calling
getAllTermsOfServices(BoxAPIConnection api)
.
This will return an iterable that will page through all of the enterprises terms of services.
List<BoxTermsOfService.Info> termsOfServices = BoxTermsOfService.getAllTermsOfServices(api);
for(BoxTermsOfService.Info termsOfServiceInfo : termsOfServices){
// Do something with the terms of service.
}
You can also filter by managed or external terms of service by calling
getAllTermsOfServices(BoxAPIConnection api, BoxTermsOfService.TermsOfServiceType type)
.
For new users you can accept or decline a terms of service by calling
create(BoxAPIConnection api, String tosID, Boolean accepted, String userID)
BoxTermsOfService.Info newUserStatus = BoxTermsOfServiceUserStatus.create(api, "tos-id", true, "user-id");
You can only create a new user status on a terms of service if the user has never accepted/declined a terms of service. If they have then you will need to make the update call.
For an existing user you can accept or decline a terms of service by calling
updateInfo(BoxTermsOfService.Info fieldsToUpdate)
.
BoxTermsOfServiceUserStatus tosUserStatus = new BoxTermsOfServiceUserStatus(api, "tos-user-status-id");
BoxTermOfServiceUserStatus.Info tosUserStatusInfo = tosUserStatus.new Info();
tosUserStatusInfo.setStatus(newStatus);
tosUserStatus.updateInfo(tosUSerStatusInfo);
You can retrieve the terms of service status for a user by calling
getInfo(BoxAPIConnection api, String tosID, String userID)
List<BoxTermsOfServiceUserStatus.Info> tosUserStatusInfo = BoxTermsOfServiceUserStatus.getInfo(api, "tos-id", "user-id");
for(BoxTermsOfServiceUserStatus.Info info : toUserStatusInfo){
// Do something with the user status on terms of service.
}
Alternatively you can get the user status by the ID of the terms of service by
calling getInfo(BoxAPIConnection api, String tosID)
.
List<BoxTermsOfServiceUserStatus.Info> tosUserStatusInfo = BoxTermsOfServiceUserStatus.getInfo(api, "tos-id");
for(BoxTermsOfServiceUserStatus.Info info : toUserStatusInfo){
// Do something with the user status on terms of service.
}