コード例 #1
0
        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);
        }
コード例 #2
0
        public static DumpRequest CreateUpdateRequest(string gameId, string publicKey, string username, string userToken, string key, DataStoreOperation operation, string value)
        {
            var output = new DumpRequest(gameId, publicKey, Constants.DataStoreUrls.UpdateUrl, RequestParameter.CreateKey(key), RequestParameter.CreateOperation(operation), RequestParameter.CreateValue(value));

            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);
        }
コード例 #3
0
        public static JsonRequest <DataStore[], DataStoreKeysResult> CreateGetRequest(string gameId, string publicKey, string username, string userToken, DataStoreType type)
        {
            var output = new JsonRequest <DataStore[], DataStoreKeysResult>(gameId, publicKey, Constants.DataStoreUrls.GetKeysUrl);

            if (type != DataStoreType.User)
            {
                return(output);
            }

            if (string.IsNullOrWhiteSpace(username))
            {
                throw new ArgumentException("You must specify a username when retrieving user keys.");
            }
            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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public static JsonRequest <Score[], ScoreRequestResult> CreateGetRequest(string gameId, string privateKey, string username, string userToken, int limit, string tableId)
        {
            var output = new JsonRequest <Score[], ScoreRequestResult>(gameId, privateKey, Constants.ScoreUrls.GetUrl);

            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.");
                }
            }
            else
            {
                output.Parameters.Add(RequestParameter.CreateUsername(username));
                output.Parameters.Add(RequestParameter.CreateUserToken(userToken));
            }

            if (limit > 0)
            {
                output.Parameters.Add(RequestParameter.CreateLimit(limit));
            }

            if (!string.IsNullOrWhiteSpace(tableId))
            {
                output.Parameters.Add(RequestParameter.CreateTableId(tableId));
            }

            return(output);
        }
コード例 #6
0
 public static StringRequest CreateAuthRequest(string gameId, string publicKey, string username, string userToken)
 {
     return(new StringRequest(gameId, publicKey, Constants.UserUrls.AuthUrl, RequestParameter.CreateUsername(username), RequestParameter.CreateUserToken(userToken)));
 }
コード例 #7
0
 public static JsonRequest <User[], UserResult> CreateGetRequest(string gameId, string publicKey, params string[] userIDs)
 {
     return(new JsonRequest <User[], UserResult>(gameId, publicKey, Constants.UserUrls.GetUrl, RequestParameter.CreateUserId(userIDs)));
 }
コード例 #8
0
 public static StringRequest CreateAddAchieveRequest(string gameId, string publicKey, string username, string userToken, string trophyId)
 {
     return(new StringRequest(gameId, publicKey, Constants.TrophyUrls.AddAchieveUrl, RequestParameter.CreateUsername(username), RequestParameter.CreateUserToken(userToken), RequestParameter.CreateTrophyId(trophyId)));
 }
コード例 #9
0
 public static JsonRequest <Trophy[], TrophyResult> CreateGetRequest(string gameId, string privateKey, string username, string userToken, string trophyId)
 {
     return(new JsonRequest <Trophy[], TrophyResult>(gameId, privateKey, Constants.TrophyUrls.GetUrl, RequestParameter.CreateUsername(username), RequestParameter.CreateUserToken(userToken), RequestParameter.CreateTrophyId(trophyId)));
 }
コード例 #10
0
        public static JsonRequest <Trophy[], TrophyResult> CreateGetRequest(string gameId, string publicKey, string username, string userToken, TrophyFilter filter)
        {
            var request = new JsonRequest <Trophy[], TrophyResult>(gameId, publicKey, Constants.TrophyUrls.GetUrl, RequestParameter.CreateUsername(username), RequestParameter.CreateUserToken(userToken));

            switch (filter)
            {
            case TrophyFilter.Achieved:
            {
                request.Parameters.Add("achieved", true);
                break;
            }

            case TrophyFilter.Unachieved:
            {
                request.Parameters.Add("unachieved", false);
                break;
            }
            }
            return(request);
        }