/// <summary> /// Remove value of specified Node /// </summary> /// <returns></returns> public GeneralCallback Remove() { GeneralCallback callbackHandler = new GeneralCallback(); string route = FirebaseConfig.endpoint + path + ".json" + GetAuthParam(); RESTHelper.Delete(route, res => { callbackHandler.successCallback?.Invoke(); }, err => { callbackHandler.exceptionCallback?.Invoke(err); }); return(callbackHandler); }
/// <summary> /// Write Dictionary to specified reference /// </summary> /// <typeparam name="T1">Value type</typeparam> /// <param name="dictionary">Dictionary that will be written</param> /// <returns></returns> public GeneralCallback WriteValueAsDictionary <T1>(Dictionary <string, T1> dictionary) { GeneralCallback callbackHandler = new GeneralCallback(); string json = SerializerHelper.Serialize(typeof(Dictionary <string, T1>), dictionary); RequestHelper req = new RequestHelper { Uri = FirebaseConfig.endpoint + path + ".json" + GetAuthParam(), BodyString = json }; RESTHelper.PutJson(req, res => { callbackHandler.successCallback?.Invoke(); }, err => { callbackHandler.exceptionCallback?.Invoke(err); }); return(callbackHandler); }
/// <summary> /// Write to specified node /// </summary> /// <param name="value">Value</param> /// <returns></returns> public GeneralCallback WriteValue(object value) { GeneralCallback callbackHandler = new GeneralCallback(); string json = GenerateBody(value).ToString(); RequestHelper req = new RequestHelper { Uri = FirebaseConfig.endpoint + path + ".json" + GetAuthParam(), BodyString = json }; RESTHelper.PutJson(req, res => { callbackHandler.successCallback?.Invoke(); }, err => { callbackHandler.exceptionCallback?.Invoke(err); }); return(callbackHandler); }
/// <summary> /// Write Key-Value Pair to specified node /// </summary> /// <param name="key">Key Name</param> /// <param name="value">Value, any datatypes</param> /// <param name="append">Should append to existing list or just overwrite?</param> /// <returns></returns> public GeneralCallback WriteKeyValuePair(string key, object value, bool append = false) { GeneralCallback callbackHandler = new GeneralCallback(); string json = GenerateJson(value, key); RequestHelper req = new RequestHelper { Uri = FirebaseConfig.endpoint + path + ".json" + GetAuthParam(), BodyString = json }; if (append) //patch { RESTHelper.Patch(req, res => callbackHandler.successCallback?.Invoke(), err => callbackHandler.exceptionCallback?.Invoke(err)); return(callbackHandler); } RESTHelper.PutJson(req, res => callbackHandler.successCallback?.Invoke(), err => callbackHandler.exceptionCallback?.Invoke(err)); return(callbackHandler); }
/// <summary> /// Update value of specified path /// </summary> /// <param name="value">Updated value</param> /// <returns></returns> public GeneralCallback Update(object value) { GeneralCallback callbackHandler = new GeneralCallback(); string json = GenerateJson(value); string upperNodePath = GetImmediateUpperNode(); RequestHelper req = new RequestHelper { Uri = FirebaseConfig.endpoint + upperNodePath + ".json" + GetAuthParam(), BodyString = json }; RESTHelper.Patch(req, res => { callbackHandler.successCallback?.Invoke(); }, err => { callbackHandler.exceptionCallback?.Invoke(err); }); return(callbackHandler); }