chore: 序列化云函数的参数

oneRain 2020-05-28 11:15:50 +08:00
parent ba79cd677f
commit 973d58959a
1 changed files with 9 additions and 4 deletions

View File

@ -13,15 +13,20 @@ namespace LeanCloud.Storage {
/// <param name="name"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public static async Task<Dictionary<string, object>> Run(string name, Dictionary<string, object> parameters = null) {
public static async Task<Dictionary<string, object>> Run(string name,
Dictionary<string, object> parameters = null) {
string path = $"functions/{name}";
Dictionary<string, object> response = await LCApplication.HttpClient.Post<Dictionary<string, object>>(path, data: parameters);
object encodeParams = LCEncoder.Encode(parameters);
Dictionary<string, object> response = await LCApplication.HttpClient.Post<Dictionary<string, object>>(path,
data: encodeParams);
return response;
}
public static async Task<object> RPC(string name, Dictionary<string, object> parameters = null) {
public static async Task<object> RPC(string name, object parameters = null) {
string path = $"call/{name}";
Dictionary<string, object> response = await LCApplication.HttpClient.Post<Dictionary<string, object>>(path, data: parameters);
object encodeParams = LCEncoder.Encode(parameters);
Dictionary<string, object> response = await LCApplication.HttpClient.Post<Dictionary<string, object>>(path,
data: encodeParams);
return LCDecoder.Decode(response["result"]);
}
}