Created
March 26, 2022 15:01
-
-
Save codorizzi/c6d8e256f4c073163b695119a7cd4cb1 to your computer and use it in GitHub Desktop.
FireBase - RealTime DB Rest API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Newtonsoft.Json; | |
using Proyecto26; | |
using RSG; | |
// Dependencies | |
// REST Client - https://assetstore.unity.com/packages/tools/network/rest-client-for-unity-102501 | |
// JSON .Net - https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347 | |
namespace Utility.FireBase { | |
public class RealTime { | |
#region Private Fields | |
private string _url; | |
#endregion | |
public RealTime(string url) { | |
_url = url; | |
} | |
public IPromise<ResponseHelper> Post(string route, object obj) { | |
return RestClient.Put(GetRouteUrl(route), JsonConvert.SerializeObject(obj)); | |
} | |
public IPromise<ResponseHelper> Put(string route, object obj) { | |
return RestClient.Put(GetRouteUrl(route), JsonConvert.SerializeObject(obj)); | |
} | |
public IPromise<ResponseHelper> Delete(string route) { | |
return RestClient.Delete(GetRouteUrl(route)); | |
} | |
public IPromise<ResponseHelper> Get(string route) { | |
return RestClient.Get(GetRouteUrl(route)); | |
} | |
private string GetRouteUrl(string route) { | |
return $"{_url}/{route}.json"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment