public static StringRequest CreateSetRequest(string gameId, string publicKey, string username, string userToken, string key, string data) { var output = new StringRequest(gameId, publicKey, Constants.DataStoreUrls.SetUrl, RequestParameter.CreateKey(key), RequestParameter.CreateData(data)); if (string.IsNullOrWhiteSpace(username)) { return(output); } if (string.IsNullOrWhiteSpace(userToken)) { throw new ArgumentException("You must specify a user token when retrieving user keys."); } output.Parameters.Add(RequestParameter.CreateUsername(username)); output.Parameters.Add(RequestParameter.CreateUserToken(userToken)); return(output); }
public static StringRequest CreateAddRequest(string gameId, string privateKey, string score, int sort, string username, string userToken, string guest, string extraData, string tableId) { var output = new StringRequest(gameId, privateKey, Constants.ScoreUrls.AddUrl, RequestParameter.CreateScore(score), RequestParameter.CreateSort(sort)); if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(userToken)) { if (!string.IsNullOrWhiteSpace(username)) { Logging.LogError("If you do not want user specific scores you cannot supply a username or a user token."); throw new Exception("User token is null, but username is not."); } if (!string.IsNullOrWhiteSpace(userToken)) { Logging.LogError("If you do not want user specific scores you cannot supply a username or a user token."); throw new Exception("Username is null, but user token is not."); } output.Parameters.Add(RequestParameter.CreateGuest(guest)); } else { output.Parameters.Add(RequestParameter.CreateUsername(username)); output.Parameters.Add(RequestParameter.CreateUserToken(userToken)); } if (!string.IsNullOrWhiteSpace(extraData)) { output.Parameters.Add(RequestParameter.CreateExtraData(extraData)); } if (!string.IsNullOrWhiteSpace(tableId)) { output.Parameters.Add(RequestParameter.CreateTableId(tableId)); } return(output); }