/// <summary>
        /// Serialize SendScoreRequestData to make it compatible with MiniJSON.
        /// </summary>
        /// <param name="data">Data</param>
        /// <returns></returns>
        public static IDictionary <string, object> Serialize(SendScoreRequestData data)
        {
            var serialized = RankingRequestDataSerializer.Serialize(data);

            serialized[Const.PlayerScore] = data.Score;
            return(serialized);
        }
Example #2
0
        /// <summary>
        /// Get ranking data list from Google sheets.
        /// You can use yield to wait until the process completes.
        /// </summary>
        /// <param name="requestDataList">List of request data.</param>
        /// <param name="responseHandler">Method that will be called to handle response.</param>
        /// <returns></returns>
        public CustomYieldInstruction GetRankingListsAsync(IList <RankingRequestData> requestDataList, Action <IList <RankingResponseData> > responseHandler)
        {
            var data = new Dictionary <string, object>();

            data[Const.PlayerId]       = LocalSaveDataHelper.GetUserID();
            data[Const.RankingRequest] = requestDataList.Select(r => RankingRequestDataSerializer.Serialize(r)).ToArray();
            return(SendRequestAsync(Const.GetRankingMethod, data, response => responseHandler?.Invoke(ParseResponse(response))));
        }