Created
June 7, 2022 22:30
-
-
Save beamable-gists/4ee1ecc72475eca5e6f63aecfdba762a to your computer and use it in GitHub Desktop.
A microservice for forgetting personal player info (email, full name, etc) for GDPR compliance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using System.Threading.Tasks; | |
using Beamable.Common.Api; | |
using Beamable.Server; | |
namespace Beamable.Microservices | |
{ | |
[Microservice("DeletePlayerInfoService")] | |
public class DeletePlayerInfoService : Microservice | |
{ | |
[ClientCallable] | |
public async Task<string> DeleteAccount() | |
{ | |
var accountId = await GetAccountId(); | |
var response = await ForgetUser(accountId); | |
return response; | |
} | |
private async Task<string> GetAccountId() | |
{ | |
var path = $"/basic/accounts/search?query={Context.UserId}&page=1&pagesize=10"; | |
var response = await Requester.Request<AccountSearchResponse>(Method.GET, path); | |
return response.accounts.First().id.ToString(); | |
} | |
private async Task<string> ForgetUser(string accountId) | |
{ | |
var path = $"/object/accounts/{accountId}/admin/forget"; | |
var response = await Requester.Request<string>(Method.DELETE, path, parser:(s => s)); | |
return response; | |
} | |
} | |
public class AccountSearchResponse | |
{ | |
public Account[] accounts; | |
} | |
public class Account | |
{ | |
public long id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment