Terms of Service are custom objects that the admin of an enterprise can configure. This will prompt the end user to accept/re-accept or decline the custom Terms of Service for platform applications built on Box Platform.
To create a terms of service call the
TermsOfServiceManager.CreateTermsOfServicesAsync(BoxTermsOfServicesRequest termsOfServicesRequest)
method with the parameters for the new terms of service.
var tosParams = new CreateTermsOfServicesAsync()
{
Status = "enabled"
TosType = "external",
Text = "By using this service, you agree to ..."
};
BoxTermsOfService tos = await client.TermsOfServiceManager.CreateTermsOfServicesAsync(tosParams);
To update a terms of service call
TermsOfServiceManager.UpdateTermsOfServicesAsync(string tosId, BoxTermsOfServicesRequest termsOfServicesRequest)
method with the fields to update and their new values.
var updates = new BoxTermsOfServicesRequest()
{
Status = "disabled",
Text = "Updated Text"
};
BoxTermsOfService updatedToS = client.TermsOfServiceManager
.UpdateTermsOfServicesAsync("11111", updates);
To get the terms of service with an ID call
TermsOfServiceManager.GetTermsOfServicesByIdAsync(string tosId)
with the ID of the terms of service object.
BoxTermsOfService tos = await client.TermsOfServiceManager.GetTermsOfServicesByIdAsync("11111");
To get the terms of service for an enterprise, call
TermsOfServiceManager.GetTermsOfServicesAsync(string tosType = null)
.
BoxTermsOfServiceCollection<BoxTermsOfService> termsOfService = await client.TermsOfServiceManager
.GetTermsOfServicesAsync();
For create user status on a terms of service call the
TermsOfServiceManager.CreateBoxTermsOfServiceUserStatusesAsync(BoxTermsOfServiceUserStatusCreateRequest termsOfServiceUserStatusCreateRequest)
You can only create a 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..
var createStatusRequest = new BoxTermsOfServiceUserStatusCreateRequest()
{
TermsOfService = new BoxRequestEntity()
{
Id = "11111",
Type = BoxType.terms_of_service
},
User = new BoxRequestEntity()
{
Id = "22222",
Type = BoxType.user
},
IsAccepted = true
};
BoxTermsOfServiceUserStatuses termsOfServiceUserStatuses =
await client.TermsOfServiceManager.CreateBoxTermsOfServiceUserStatusesAsync(createStatusRequest);
To update user status on a terms of service call the
TermsOfServiceManager.UpdateTermsofServiceUserStatusesAsync(string tosId, bool isAccepted)
method with the ID of the status object, and the new acceptance value for the user.
It is important to note that this will accept or decline a custom terms of service for a user. For a user that has taken action in this terms of service, this will update their status. If the user has never taken action on this terms of service then this will return a 404 Not Found error.
BoxTermsOfServiceUserStatuses updatedStatus = await client.TermsOfServiceManager
.UpdateTermsofServiceUserStatusesAsync("12345", false);
To get user status on a terms of service call the
TermsOfServiceManager.GetTermsOfServiceUserStatusesAsync(string tosId, String userId = null)
method with the ID of the terms of service. If no user ID is provided, the method defaults to the
current user.
BoxTermsOfServiceUserStatusesCollection<BoxTermsOfServiceUserStatuses> tosStatuses = await client.TermsOfServiceManager
.GetTermsOfServiceUserStatusesAsync(tosId: "11111", userId: "22222");