Terms page
This page explains how to show the terms as a web page and how to show the previous content of a terms item.
Terms page URLs
The response of GetTermsAsync() holds two terms page URLs.
| Field name | Purpose |
|---|---|
PageUrl | A page that shows the entire current terms on one screen. Use it when you always show the latest terms, such as "View terms of service" on a settings screen. |
VersionPageUrl | A page fixed to this terms version and language. Use it to keep the terms the user consented to as evidence. null if there is none. |
Open both URLs in a browser or a web view.
Check the terms page as it was when the user consented with VersionPageUrl in the consent history. For details, see Get consent history.
View previous terms of an item
To show the previous content of a terms item, retrieve the list of previous terms and then retrieve the content of the version the user picked.
Get the list of previous terms
ListItemRevisionsAsync
Retrieves the list of previous terms of a terms item, starting from the newest item version. If there is no history, it returns an empty list.
| Field name | Type | Required | Description |
|---|---|---|---|
request | ListItemRevisionsRequest | Required | Request object. ArgumentNullException is thrown if it is null |
request.CompanyCode | string | Required | Company code. The part before the first . of the App ID |
request.ServiceCode | string | Required | Service code |
request.TermId | string | Required | TermId from the get terms response |
request.ItemId | string | Required | ItemId from the get terms response |
context | ApiCallContext? | Optional | Per-call settings object |
TermsListItemRevisionsResult result = await terms.ListItemRevisionsAsync(new ListItemRevisionsRequest
{
CompanyCode = companyCode, // Company code: the part before the first '.' of the App ID
ServiceCode = "SAMPLE",
TermId = doc.TermId,
ItemId = item.ItemId,
});
switch (result)
{
case TermsListItemRevisionsResult.Success success:
foreach (ItemRevisionMeta revision in success.Data.Items)
{
// Show the list with revision.Revision and revision.PublishedAt.
// When the user picks one, retrieve the content with revision.ItemRevisionId.
}
break;
case TermsListItemRevisionsResult.ServiceNotFound:
// Check the company code and the service code.
break;
case TermsListItemRevisionsResult.TermsNotFound:
case TermsListItemRevisionsResult.ItemRevisionNotFound:
// The requested terms or item was not found. Check the TermId and ItemId you passed.
break;
case TermsListItemRevisionsResult.Failure failure:
Debug.LogError($"[Terms] {failure.Problem.ExternalCode} (trace: {failure.Problem.TraceId})");
break;
case TermsListItemRevisionsResult.UnknownOutcome unknown:
Debug.LogWarning($"[Terms] Unknown outcome: {unknown.Code}");
break;
// Safety net: unhandled results
default:
Debug.LogWarning($"Unhandled result: {result.GetType().Name}");
break;
}
Each entry in Data.Items (ItemRevisionMeta) holds the following values.
| Field name | Type | Description |
|---|---|---|
ItemRevisionId | string | Terms item version ID. Used to retrieve the content |
Revision | int | Item version number |
PublishedAt | DateTimeOffset | Time the item version was published |
If ItemId does not belong to the terms of TermId, it returns ItemRevisionNotFound.
Get the previous terms content
Call GetItemRevisionAsync() with the ItemRevisionId of the version the user picked to retrieve the title and content of that version. The way to call it is the same as Get item content.
TermsGetItemRevisionResult result = await terms.GetItemRevisionAsync(new GetItemRevisionRequest
{
CompanyCode = companyCode,
ServiceCode = "SAMPLE",
TermId = doc.TermId,
ItemId = item.ItemId,
ItemRevisionId = revision.ItemRevisionId, // Previous version the user picked
Lang = doc.Language,
});
switch (result)
{
case TermsGetItemRevisionResult.Success success:
// Show the title and content of that version with success.Data.Title and success.Data.Body.
break;
case TermsGetItemRevisionResult.TermsNotFound:
// TermId is not the terms that apply to the request's country.
break;
case TermsGetItemRevisionResult.ItemRevisionNotFound:
// The item version is unpublished or does not exist.
break;
case TermsGetItemRevisionResult.Failure failure:
Debug.LogError($"[Terms] {failure.Problem.ExternalCode} (trace: {failure.Problem.TraceId})");
break;
case TermsGetItemRevisionResult.UnknownOutcome unknown:
Debug.LogWarning($"[Terms] Unknown outcome: {unknown.Code}");
break;
// Safety net: unhandled results
default:
Debug.LogWarning($"Unhandled result: {result.GetType().Name}");
break;
}
You can retrieve only items of the terms that apply to the request's country. If TermId is not the terms of that country, it returns TermsNotFound; if the item version is unpublished or does not exist, it returns ItemRevisionNotFound.