Skip to main content

Manage legal documents using SDK

Last updated on November 13, 2024

Overview

This guide explains how to manage legal documents in AccelByte Gaming Services (AGS) by utilizing the AccelByte Legal Agreement API through the functions in AccelByte::FRegistry::Agreement within your game client.

Prerequisites

For Extend apps, you have integrated the Legal Agreements service into your app. For more information, refer to the Implement Legal Agreements service guide.

Check player eligibilities

To check if players from a specific namespace has agreed to a legal agreement, use this function:

AccelByte::FRegistry::Agreement.QueryLegalEligibilities(
// Specified namespace
,
THandler < TArray < FAccelByteModelsRetrieveUserEligibilitiesResponse >> ::
CreateLambda(
[](TArray < FAccelByteModelsRetrieveUserElegibilitiesResponse > Result) {
// Do something when successful
}),
FError::CreateLambda([](int32 ErrorCode, FString ErrorMessage) {
// Do something if failed
})
);
ok, err := agreementService.RetrieveAgreementsPublic()
if err != nil {
return err
}
return nil
AccelByte::FRegistry::Agreement.GetLegalDocument(
// Specified URL
,
THandler < FString > ::CreateLambda([](FString Result) {
// Do something when successful
}),
FError::CreateLambda([](int32 ErrorCode, FString ErrorMessage) {
// Do something if failed
})
);

This section outlines all the available functions for retrieving document policies based on specific criteria.

Retrieve all latest active policies

AccelByte::FRegistry::Agreement.GetLegalPolicies(
// Specified policy type
,
// Default on empty flag
,
THandler < TArray < FAccelByteModelsPublicPolicy >> ::
CreateLambda([](TArray < FAccelByteModelsPublicPolicy > Result) {
// Do something when successful
}),
FError::CreateLambda([](int32 ErrorCode, FString ErrorMessage) {
// Do something if failed
})
);

Retrieve list of policies by namespace

AccelByte::FRegistry::Agreement.GetLegalPolicies(
// Specified namespace
,
// Specified policy type
,
// Default on empty flag
,
THandler < TArray < FAccelByteModelsPublicPolicy >> ::
CreateLambda([](TArray < FAccelByteModelsPublicPolicy > Result) {
// Do something when successful
}),
FError::CreateLambda([](int32 ErrorCode, FString ErrorMessage) {
// Do something if failed
})
);

Retrieve list of policies by tag

Retrieve all latest active policies that have specified tags based on the namespace from game configuration and country code from the user's profile.

AccelByte::FRegistry::Agreement.GetLegalPolicies(
// Specified policy type
,
// List of tags
,
// Default on empty flag
,
THandler < TArray < FAccelByteModelsPublicPolicy >> ::
CreateLambda([](TArray < FAccelByteModelsPublicPolicy > Result) {
// Do something when successful
}),
FError::CreateLambda([](int32 ErrorCode, FString ErrorMessage) {
// Do something if failed
})
);

Retrieve list of policies by country

AccelByte::FRegistry::Agreement.GetLegalPolicies(
// Specified country code
,
// Specified policy type
,
// Default on empty flag
,
THandler < TArray < FAccelByteModelsPublicPolicy >> ::
CreateLambda([](TArray < FAccelByteModelsPublicPolicy > Result) {
// Do something when successful
}),
FError::CreateLambda([](int32 ErrorCode, FString ErrorMessage) {
// Do something if failed
})
);

Retrieve list of policies by country and tag

AccelByte::FRegistry::Agreement.GetLegalPolicies(
// Specified country code
,
// Specified policy type
,
// List of tags
,
// Default on empty flag
,
THandler < TArray < FAccelByteModelsPublicPolicy >> ::
CreateLambda([](TArray < FAccelByteModelsPublicPolicy > Result) {
// Do something when successful
}),
FError::CreateLambda([](int32 ErrorCode, FString ErrorMessage) {
// Do something if failed
})
);

Accept policies

Policies can be accepted one at a time or in bulk.

Accept a single policy

To accept a localized policy document using it localized version ID, use this function:

AccelByte::FRegistry::Agreement.AcceptPolicyVersion(
// Specified localized policy version ID
,
FVoidHandler::CreateLambda([]() {
// Do something when successful
}),
FError::CreateLambda([](int32 ErrorCode, FString ErrorMessage) {
// Do something if failed
})
);

Accept policies in bulk

To accept multiple localized policies at once, use this function:

AccelByte::FRegistry::Agreement.BulkAcceptPolicyVersions(
// list of localized policy versions
,
THandler < FAccelByteModelsAcceptAgreementResponse > ::
CreateLambda([](FAccelByteModelsAcceptAgreementResponse Result) {
// Do something when successful
}),
FError::CreateLambda([](int32 ErrorCode, FString ErrorMessage) {
// Do something if failed
})
);

Accept policy versions in bulk

err := dataRetrievalService.SaveAdminEmailConfiguration(input)
if err != nil {
return err
}
return nil

Update existing policies

The following shows you how to make changes to existing policies.

note

The code below only accepts the "marketing preference" policy type. Refer to Policy types for information on the different types. Refer to Retrieve policies to get your latest policy details.

To update the player's current marketing preference consent, use the code in the following snippet:

// Retrieve list of policies.
Result<PublicPolicy[]> publicPoliciesResult;

// Assume that the from the retrieved policy list, only the first policy will be accepted
AcceptAgreementRequest[] acceptAgreementRequests = new AcceptAgreementRequest[]
{
new AcceptAgreementRequest
{
isAccepted = true,
policyId = publicPoliciesResult.Value[0].id,
policyVersionId = publicPoliciesResult.Value[0].policyVersions[0].id,
localizedPolicyVersionId = publicPoliciesResult.Value[0].policyVersions[0].localizedPolicyVersions[0].id
}
};

AccelByteSDK.GetClientRegistry().GetApi().GetAgreement().BulkAcceptPolicyVersions(acceptAgreementRequests, acceptAgreementResponseResult =>
{
if (acceptAgreementResponseResult.IsError)
{
// Do something if failed
Debug.Log($"Accept Policy Version failed : {acceptAgreementResponseResult.Error.Code} Description : {acceptAgreementResponseResult.Error.Message}");
return;
}

// Do something when successful
});