internal static void CheckVarsUpdate(Action callback) { IDictionary <string, string> updateVarsParams = new Dictionary <string, string>(); updateVarsParams[Constants.Params.INCLUDE_DEFAULTS] = false.ToString(); LeanplumRequest updateVarsReq = LeanplumRequest.Post(Constants.Methods.GET_VARS, updateVarsParams); updateVarsReq.Response += delegate(object varsUpdate) { var getVariablesResponse = Util.GetLastResponse(varsUpdate) as IDictionary <string, object>; var newVarValues = Util.GetValueOrDefault(getVariablesResponse, Constants.Keys.VARS) as IDictionary <string, object>; var newVarFileAttributes = Util.GetValueOrDefault(getVariablesResponse, Constants.Keys.FILE_ATTRIBUTES) as IDictionary <string, object>; var newVariants = Util.GetValueOrDefault(getVariablesResponse, Constants.Keys.VARIANTS) as List <object> ?? new List <object>(); ApplyVariableDiffs(newVarValues, newVarFileAttributes, newVariants); if (callback != null) { callback(); } }; updateVarsReq.Error += delegate { if (callback != null) { callback(); } }; updateVarsReq.SendNow(); VarsNeedUpdate = false; }
internal static void ForceSendVariables(Leanplum.SyncVariablesCompleted completedHandler) { var parameters = new Dictionary <string, string>(); parameters[Constants.Params.VARIABLES] = Json.Serialize(valuesFromClient); parameters[Constants.Params.KINDS] = Json.Serialize(defaultKinds); LeanplumUnityHelper.QueueOnMainThread(() => { LeanplumRequest setVarsReq = LeanplumRequest.Post(Constants.Methods.SET_VARS, parameters); setVarsReq.Response += delegate(object response) { completedHandler?.Invoke(true); }; setVarsReq.Error += delegate(Exception ex) { LeanplumNative.CompatibilityLayer.LogError("Leanplum Error: ForceSyncVariables", ex); completedHandler?.Invoke(false); }; setVarsReq.SendNow(); }); }