Manage legal documents using SDK
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:
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
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
})
);
AccelByteSDK.GetClientRegistry().GetApi().GetAgreement().QueryLegalEligibilities(eligibilitiesResult =>
{
if (eligibilitiesResult.IsError)
{
// Do something if Query Legal Eligibilities has an error
Debug.Log($"Query Legal Eligibility failed : {eligibilitiesResult.Error.Code} Description : {eligibilitiesResult.Error.Message}");
return;
}
bool isEligible = true;
foreach(var eligibility in eligibilitiesResult.Value)
{
if (!eligibility.isAccepted)
{
isEligible = false;
break;
}
}
if (isEligible)
{
Debug.Log($"Query Legal Eligibility Success");
}
else
{
Debug.Log($"Contains player who don't accept legal eligibility");
}
});
var response = sdk.Legal.Eligibilities.RetrieveEligibilitiesPublicOp
.Execute(sdk.Namespace);
if (response != null)
{
bool isEligible = true;
foreach (var item in response)
{
if (item.IsAccepted.HasValue && !item.IsAccepted.Value)
{
isEligible = false;
break;
}
}
if (isEligible)
{
// Do something if eligible
}
else
{
// Do something if not eligible
}
}
eligibilitiesService := &legal.EligibilitiesService{
Client: factory.NewLegalClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
input := &eligibilities.RetrieveEligibilitiesPublicParams{
Namespace: namespace,
}
result, err := eligibilitiesService.RetrieveEligibilitiesPublicShort(input)
Eligibilities legalWrapper = new Eligibilities(sdk);
List<RetrieveUserEligibilitiesResponse> response;
try {
response = legalWrapper.retrieveEligibilitiesPublic(RetrieveEligibilitiesPublic.builder()
.namespace("<namespace>")
.build());
} catch (Exception e) {
// Do something if failed
return;
}
if (response != null) {
boolean isEligible = true;
for (RetrieveUserEligibilitiesResponse item : response) {
if (item.getIsAccepted() != null && item.getIsAccepted() == false) {
isEligible = false;
break;
}
}
if (isEligible) {
// Do something if eligible
} else {
// Do something if not eligible
}
}
import accelbyte_py_sdk.api.legal as legal_service
result, error = legal_service.retrieve_eligibilities_public(
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
Retrieve legal documents
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
Agreement wLegalAgreement = new Agreement(sdk);
List<RetrieveAcceptedAgreementResponse>? aggrs = wLegalAgreement.RetrieveAgreementsPublic(
RetrieveAgreementsPublic
.Builder.Build());
ok, err := agreementService.RetrieveAgreementsPublic()
if err != nil {
return err
}
return nil
List<RetrieveAcceptedAgreementResponse> aggrs = wLegalAgreement
.retrieveAgreementsPublic(RetrieveAgreementsPublic.builder().build());
import accelbyte_py_sdk.api.legal as legal_service
result, error = legal_service.retrieve_agreements_public()
if error:
exit(error)
Retrieve legal document content
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
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
})
);
Result <string> docResult = null;
String localizedPolicyUrl = policyVersion.localizedPolicyVersions[0].attachmentLocation; // From GetLegalPolicies Result
AccelByteSDK.GetClientRegistry().GetApi().GetAgreement().GetLegalDocument(localizedPolicyUrl, docResult =>
{
if (docResult.IsError)
{
// Do something if failed
Debug.Log($"Get Legal Document failed : {docResult.Error.Code} Description : {docResult.Error.Message}");
return;
}
// Do something when successful
});
string localizedPolicyUrl = getPolicyResponse[0].PolicyVersions[0].LocalizedPolicyVersions[0].AttachmentLocation; //from RetrieveLatestPolicies
HttpRequestMessage request = new HttpRequestMessage();
request.RequestUri = localizedPolicyUrl;
var webResponse = DefaultHttpClient.Http.Send(request);
if (webResponse.IsSuccessStatusCode)
{
// Do something after policy file is retrieved
}
localizedPolicyVersionsService := &legal.LocalizedPolicyVersionsService{
Client: factory.NewLegalClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
policyVersionId := "mypolicyversionid"
input := &localized_policy_versions.RetrieveLocalizedPolicyVersionsParams{
PolicyVersionID: policyVersionId,
}
result, err := localizedPolicyVersionsService.RetrieveLocalizedPolicyVersionsShort(input)
// from RetrieveLatestPolicies
String localizedPolicyUrl = response.get(0).getPolicyVersions().get(0).getLocalizedPolicyVersions().get(0).getAttachmentLocation();
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(localizedPolicyUrl))
.build();
try {
HttpResponse<String> httpResponse =
client.send(request, HttpResponse.BodyHandlers.ofString());
} catch (Exception e) {
// Do something if failed
return;
}
if (httpResponse.statusCode() >= HttpURLConnection.HTTP_OK && httpResponse.statusCode() < HttpURLConnection.HTTP_MULT_CHOICE)
{
// Do something after policy file is retrieved
}
import accelbyte_py_sdk.api.legal as legal_service
from accelbyte_py_sdk.core import get_http_client
# result, error = legal_service.retrieve_latest_policies_public()
localized_policy_version_url = result[0].policy_versions[0].localized_policy_versions[0].attachment_location
localized_policy_version = get_http_client().get(localized_policy_version_url).text
Retrieve legal document policies
This section outlines all the available functions for retrieving document policies based on specific criteria.
Retrieve all latest active policies
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
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
})
);
AccelByteSDK.GetClientRegistry().GetApi().GetAgreement().GetLegalPolicies(AgreementPolicyType.EMPTY, false, publicPoliciesResult =>
{
if (publicPoliciesResult.IsError)
{
// Do something if failed
Debug.Log($"Get Legal Policies failed : {publicPoliciesResult.Error.Code} Description : {publicPoliciesResult.Error.Message}");
return;
}
// Do something when successful
});
string countryCode = "US";
var response = sdk.Legal.Policies.RetrieveLatestPoliciesOp
.Execute(countryCode);
if (response != null)
{
// Do something after policies are retrieved
}
policiesService := &legal.PoliciesService{
Client: factory.NewLegalClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
defaultOnEmpty := false
policyType := ""
input := &policies.RetrieveLatestPoliciesPublicParams{
Namespace: namespace,
DefaultOnEmpty: &defaultOnEmpty,
PolicyType: &policyType,
}
result, err := policiesService.RetrieveLatestPoliciesPublicShort(input)
Policies policiesWrapper = new Policies(sdk);
String countryCode = "US";
List<RetrievePolicyPublicResponse> response;
try {
response = policiesWrapper.retrieveLatestPolicies(RetrieveLatestPolicies.builder()
.countryCode(countryCode)
.build());
} catch (Exception e) {
// Do something if failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something when successful
}
import accelbyte_py_sdk.api.legal as legal_service
result, error = legal_service.retrieve_latest_policies_public(
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
Retrieve list of policies by namespace
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
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
})
);
// Namespace is already stored on Config file
string[] tags = new string[] {
"game",
"NDA"
};
bool defaultOnEmpty = true; // Will get default country when no localized policy is set for your country
AccelByteSDK.GetClientRegistry().GetApi().GetAgreement().GetLegalPolicies(AgreementPolicyType.EMPTY, tags, defaultOnEmpty, publicPoliciesResult =>
{
if (publicPoliciesResult.IsError)
{
// Do something if failed
Debug.Log($"Get Legal Policies failed : {publicPoliciesResult.Error.Code} Description : {publicPoliciesResult.Error.Message}");
return;
}
// Do something when successful
foreach(var publicPolicy in publicPoliciesResult.Value)
{
Debug.Log("PolicyName: " + publicPolicy.policyName + " | Description: " + publicPolicy.description);
foreach(var policyVersion in publicPolicy.policyVersions)
{
Debug.Log("PolicyVersion: " + policyVersion.displayVersion + " | LocalizedPolicyUrl: " + policyVersion.localizedPolicyVersions[0].attachmentLocation);
}
}
});
string countryCode = "US";
bool defaultOnEmpty = true; // Will get default country when no localized policy is set for your country
var response = sdk.Legal.Policies.RetrieveLatestPoliciesOp
.SetDefaultOnEmpty(defaultOnEmpty)
.SetTags("game,NDA")
.Execute(countryCode);
if (response != null)
{
// Do something after policies are retrieved
}
policiesService := &legal.PoliciesService{
Client: factory.NewLegalClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
defaultOnEmpty := true
policyType := ""
tags := "game,NDA"
input := &policies.RetrieveLatestPoliciesPublicParams{
Namespace: namespace,
DefaultOnEmpty: &defaultOnEmpty,
PolicyType: &policyType,
Tags: &tags,
}
result, err := policiesService.RetrieveLatestPoliciesPublicShort(input)
Policies policiesWrapper = new Policies(sdk);
String countryCode = "US";
List<RetrievePolicyPublicResponse> response;
try {
response = policiesWrapper.retrieveLatestPolicies(RetrieveLatestPolicies.builder()
.countryCode(countryCode)
.tags("beta,beta")
.build());
} catch (Exception e) {
// Do something if failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something when successful
}
import accelbyte_py_sdk.api.legal as legal_service
result, error = legal_service.retrieve_latest_policies_public(
default_on_empty=True,
tags="game,NDA",
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
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.
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
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
})
);
string[] tags = new string[2] {
"beta",
"newsletter"
};
AccelByteSDK.GetClientRegistry().GetApi().GetAgreement().GetLegalPolicies(AgreementPolicyType.EMPTY, tags, false, publicPoliciesResult =>
{
if (publicPoliciesResult.IsError)
{
// Do something if failed
Debug.Log($"Get Legal Policies failed : {publicPoliciesResult.Error.Code} Description : {publicPoliciesResult.Error.Message}");
return;
}
// Do something when successful
});
string countryCode = "US";
var response = sdk.Legal.Policies.RetrieveLatestPoliciesOp
.SetTags("beta,beta")
.Execute(countryCode);
if (response != null)
{
// Do something after policies are retrieved
}
policiesService := &legal.PoliciesService{
Client: factory.NewLegalClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
defaultOnEmpty := true
policyType := ""
tags := "beta,newsletter"
input := &policies.RetrieveLatestPoliciesPublicParams{
Namespace: namespace,
DefaultOnEmpty: &defaultOnEmpty,
PolicyType: &policyType,
Tags: &tags,
}
result, err := policiesService.RetrieveLatestPoliciesPublicShort(input)
Policies policiesWrapper = new Policies(sdk);
String countryCode = "US";
List<RetrievePolicyPublicResponse> response;
try {
response = policiesWrapper.retrieveLatestPolicies(RetrieveLatestPolicies.builder()
.countryCode(countryCode)
.tags("beta,beta")
.build());
} catch (Exception e) {
// Do something if failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something when successful
}
import accelbyte_py_sdk.api.legal as legal_service
result, error = legal_service.retrieve_latest_policies_public(
tags="beta,newsletter",
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
Retrieve list of policies by country
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
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
})
);
string countryCode = "US"; // You can get the country code from eligibilities return
string[] tags = new string[] {
"game",
"NDA"
};
bool defaultOnEmpty = true; // Will get default country when no localized policy for your country
AccelByteSDK.GetClientRegistry().GetApi().GetAgreement().GetLegalPoliciesByCountry(countryCode, AgreementPolicyType.EMPTY, tags, defaultOnEmpty, publicPoliciesResult =>
{
if (publicPoliciesResult.IsError)
{
// Do something if failed
Debug.Log($"Get Legal Policies failed : {publicPoliciesResult.Error.Code} Description : {publicPoliciesResult.Error.Message}");
return;
}
// Do something when successful
foreach(var publicPolicy in publicPoliciesResult.Value)
{
Debug.Log("PolicyName: " + publicPolicy.policyName + " | Description: " + publicPolicy.description);
foreach(var policyVersion in publicPolicy.policyVersions)
{
Debug.Log("PolicyVersion: " + policyVersion.displayVersion + " | LocalizedPolicyUrl: " + policyVersion.localizedPolicyVersions[0].attachmentLocation);
}
}
});
string countryCode = "US";
bool defaultOnEmpty = true; // Will get default country when no localized policy is set for your country
var response = sdk.Legal.Policies.RetrieveLatestPoliciesOp
.SetDefaultOnEmpty(defaultOnEmpty)
.SetTags("game,NDA")
.Execute(countryCode);
if (response != null)
{
// Do something after policies are retrieved
}
policiesService := &legal.PoliciesService{
Client: factory.NewLegalClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
countryCode := "US"
defaultOnEmpty := true
policyType := ""
tags := "game,NDA"
input := &policies.RetrieveLatestPoliciesParams{
CountryCode: countryCode,
DefaultOnEmpty: &defaultOnEmpty,
PolicyType: &policyType,
Tags: &tags,
}
result, err := policiesService.RetrieveLatestPoliciesShort(input)
Policies policiesWrapper = new Policies(sdk);
String countryCode = "US";
boolean defaultOnEmpty = true; // Will get default country when no localized policy is set for your country
List<RetrievePolicyPublicResponse> response;
try {
response = policiesWrapper.retrieveLatestPolicies(RetrieveLatestPolicies.builder()
.defaultOnEmpty(defaultOnEmpty)
.countryCode(countryCode)
.tags("game,NDA")
.build());
} catch (Exception e) {
// Do something if failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something when successful
}
import accelbyte_py_sdk.api.legal as legal_service
result, error = legal_service.retrieve_latest_policies(
country_code="US",
default_on_empty=True,
tags="game,NDA",
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
Retrieve list of policies by country and tag
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
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
})
);
string countryCode = "US";
string[] tags = new string[2] {
"beta",
"newsletter"
};
AccelByteSDK.GetClientRegistry().GetApi().GetAgreement().GetLegalPoliciesByCountry(countryCode, AgreementPolicyType.EMPTY, tags, false, publicPoliciesResult =>
{
if (publicPoliciesResult.IsError)
{
// Do something if failed
Debug.Log($"Get Legal Policies failed : {publicPoliciesResult.Error.Code} Description : {publicPoliciesResult.Error.Message}");
return;
}
// Do something when successful
});
string countryCode = "US";
bool defaultOnEmpty = true; // Will get default country when no localized policy is set for your country
var response = sdk.Legal.Policies.RetrieveLatestPoliciesOp
.SetDefaultOnEmpty(defaultOnEmpty)
.SetTags("game,NDA")
.Execute(countryCode);
if (response != null)
{
// Do something after policies are retrieved
}
policiesService := &legal.PoliciesService{
Client: factory.NewLegalClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
countryCode := "US"
defaultOnEmpty := true
policyType := ""
tags := "beta,newsletter"
input := &policies.RetrieveLatestPoliciesParams{
CountryCode: countryCode,
DefaultOnEmpty: &defaultOnEmpty,
PolicyType: &policyType,
Tags: &tags,
}
result, err := policiesService.RetrieveLatestPoliciesShort(input)
Policies policiesWrapper = new Policies(sdk);
String countryCode = "US";
boolean defaultOnEmpty = true; // Will get default country when no localized policy is set for your country
List<RetrievePolicyPublicResponse> response;
try {
response = policiesWrapper.retrieveLatestPolicies(RetrieveLatestPolicies.builder()
.defaultOnEmpty(defaultOnEmpty)
.countryCode(countryCode)
.tags("game,NDA")
.build());
} catch (Exception e) {
// Do something if failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something when successful
}
import accelbyte_py_sdk.api.legal as legal_service
result, error = legal_service.retrieve_latest_policies(
country_code="US",
tags="beta,newsletter",
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
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:
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
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
})
);
string localizedPolicyVersionId = policyVersion.localizedPolicyVersions[0].id; // From GetLegalPolicies Result
AccelByteSDK.GetClientRegistry().GetApi().GetAgreement().AcceptPolicyVersion(localizedPolicyVersionId, acceptPolicyVersionResult =>
{
if (acceptPolicyVersionResult.IsError)
{
// Do something if failed
Debug.Log($"Accept Policy Version failed : {acceptPolicyVersionResult.Error.Code} Description : {acceptPolicyVersionResult.Error.Message}");
return;
}
// Do something when successful
});
string localizedPolicyVersionId = getPolicyResponse[0].PolicyVersions[0].LocalizedPolicyVersions[0].Id; //from RetrieveLatestPolicies
sdk.Legal.Agreement.AcceptVersionedPolicyOp
.Execute(localizedPolicyVersionId);
agreementService := &legal.AgreementService{
Client: factory.NewLegalClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
localizedPolicyVersionId := "mylocalizedpolicyversionid"
input := &agreement.AcceptVersionedPolicyParams{
LocalizedPolicyVersionID: localizedPolicyVersionId,
}
err := agreementService.AcceptVersionedPolicyShort(input)
// from RetrieveLatestPolicies
Agreement legalWrapper = new Agreement(sdk);
String localizedPolicyVersionId = response.get(0).getPolicyVersions().get(0).getLocalizedPolicyVersions().get(0).getId();
try {
legalWrapper.acceptVersionedPolicy(AcceptVersionedPolicy.builder()
.localizedPolicyVersionId(localizedPolicyVersionId)
.build());
} catch (Exception e) {
// Do something if failed
return;
}
// Do something when successful
import accelbyte_py_sdk.api.legal as legal_service
# result, error = legal_service.retrieve_latest_policies_public()
localized_policy_version_id = result[0].policy_versions[0].localized_policy_versions[0].id
result, error = legal_service.accept_versioned_policy(
localized_policy_version_id,
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
Accept policies in bulk
To accept multiple localized policies at once, use this function:
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
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
})
);
//policy
AcceptAgreementRequest[] acceptAgreementRequests = new AcceptAgreementRequest[]
{
new AcceptAgreementRequest
{
isAccepted = true,
policyId = policy.policyId,
policyVersionId = policyVersion.id,
localizedPolicyVersionId = policyVersion.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
});
//from RetrieveLatestPolicies
string policyId = getPolicyResponse[0].Id;
string policyVersionId = getPolicyResponse[0].PolicyVersions[0].Id;
string localizedPolicyVersionId = getPolicyResponse[0].PolicyVersions[0].LocalizedPolicyVersions[0].Id;
var response = sdk.Legal.Agreement.BulkAcceptVersionedPolicyOp
.SetBody(new List<AcceptAgreementRequest>()
{
new AcceptAgreementRequest()
{
IsAccepted = true,
PolicyId = policyId,
PolicyVersionId = policyVersionId,
LocalizedPolicyVersionId = localizedPolicyVersionId
}
})
.Execute();
if (response != null)
{
// Do something when successful
}
agreementService := &legal.AgreementService{
Client: factory.NewLegalClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
isAccepted := true
policyId := "mypolicyid"
policyVersionId := "mypolicyversionid"
localizedPolicyVersionID := "mylocalizedpolicyversionid"
input := &agreement.BulkAcceptVersionedPolicyParams{
Body: []*legalclientmodels.AcceptAgreementRequest {
{
IsAccepted: &isAccepted,
PolicyID: &policyId,
PolicyVersionID: &policyVersionId,
LocalizedPolicyVersionID: &localizedPolicyVersionID,
},
},
}
result, err := agreementService.BulkAcceptVersionedPolicyShort(input)
// from RetrieveLatestPolicies
String policyId = policyResponse.get(0).getId();
String policyVersionId = policyResponse.get(0).getPolicyVersions().get(0).getId();
String localizedPolicyVersionId = policyResponse.get(0).getPolicyVersions().get(0).getLocalizedPolicyVersions().get(0).getId();
List<AcceptAgreementRequest> body = Arrays.asList(
AcceptAgreementRequest.builder()
.isAccepted(true)
.policyId(policyId)
.policyVersionId(policyVersionId)
.localizedPolicyVersionId(localizedPolicyVersionId)
.build());
Agreement legalWrapper = new Agreement(sdk);
AcceptAgreementResponse response;
try {
response = legalWrapper.bulkAcceptVersionedPolicy(BulkAcceptVersionedPolicy.builder()
.body(body)
.build());
} catch (Exception e) {
// Do something if failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something when successful
}
import accelbyte_py_sdk.api.legal as legal_service
import accelbyte_py_sdk.api.legal.models as legal_models
# result, error = legal_service.retrieve_latest_policies_public()
policy = result[0]
policy_id = policy.id_
policy_version = policy.policy_versions[0]
policy_version_id = policy_version.id_
localized_policy_version = policy_version.localized_policy_versions[0]
localized_policy_version_id = localized_policy_version.id_
result, error = legal_service.bulk_accept_versioned_policy(
body=[
legal_models.AcceptAgreementRequest()
.with_is_accepted(True)
.with_policy_id(policy_id)
.with_policy_version_id(policy_version_id)
.with_localized_policy_version_id(localized_policy_version_id),
],
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
Accept policy versions in bulk
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
Agreement wLegalAgreement = new Agreement(sdk);
List<AcceptAgreementRequest> policies = new List<AcceptAgreementRequest>();
policies.Add(new AcceptAgreementRequest()
{
PolicyId = "<policy_id>",
PolicyVersionId = "<version_id>",
LocalizedPolicyVersionId = "<localized_id>",
IsAccepted = true
});
AcceptAgreementResponse? resp = wLegalAgreement.BulkAcceptVersionedPolicy(
BulkAcceptVersionedPolicy.Builder
.SetBody(policies)
.Build());
err := dataRetrievalService.SaveAdminEmailConfiguration(input)
if err != nil {
return err
}
return nil
List<AcceptAgreementRequest> request = Arrays.asList(AcceptAgreementRequest.builder()
.localizedPolicyVersionId(localizedPolicyVersionId)
.policyVersionId(policyVersionId)
.policyId(policyId)
.isAccepted(true)
.build());
wLegalAgreement.bulkAcceptVersionedPolicy(BulkAcceptVersionedPolicy.builder()
.body(request)
.build());
import accelbyte_py_sdk.api.legal as legal_service
import accelbyte_py_sdk.api.legal.models as legal_models
result, error = legal_service.bulk_accept_versioned_policy(
body=[
legal_models.AcceptAgreementRequest()
.with_is_accepted(True)
.with_policy_id("****")
.with_policy_version_id("****")
.with_localized_policy_version_id("****")
]
)
if error:
exit(error)
Update existing policies
The following shows you how to make changes to existing policies.
Update marketing preference consent
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:
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
// 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
});
Agreement wLegalAgreement = new Agreement(sdk);
List<AcceptAgreementRequest> agreementRequests = new List<AcceptAgreementRequest>()
{
new AcceptAgreementRequest()
{
LocalizedPolicyVersionId = targetLocalizedPolicyId,
PolicyVersionId = targetPolicyVersionId,
PolicyId = targetPolicyId,
IsAccepted = true
}
};
wLegalAgreement.ChangePreferenceConsent(
ChangePreferenceConsent.Builder
.SetBody(agreementRequests)
.Build());
err := agreementService.ChangePreferenceConsent()
if err != nil {
return err
}
return nil
List<AcceptAgreementRequest> agreementRequests = Arrays.asList(new AcceptAgreementRequest[] {
AcceptAgreementRequest.builder()
.localizedPolicyVersionId(localizedPolicyVersionId)
.policyVersionId(policyVersionId)
.policyId(policyId)
.isAccepted(true)
.build()
});
wLegalAgreement.changePreferenceConsent(
ChangePreferenceConsent.builder()
.body(agreementRequests)
.build());
import accelbyte_py_sdk.api.legal as legal_service
import accelbyte_py_sdk.api.legal.models as legal_models
result, error = legal_service.change_preference_consent(
body=[
legal_models.AcceptAgreementRequest()
.with_is_accepted(True)
.with_policy_id("****")
.with_policy_version_id("****")
.with_localized_policy_version_id("****"),
],
)
if error:
exit(error)