123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- using UnityEngine;
- namespace SimpleFirebaseUnity
- {
- public struct FirebaseParam
- {
- string param;
- /// <summary>
- /// Created parameter for REST API call
- /// </summary>
- public string Parameter
- {
- get
- {
- return param;
- }
- }
- /// <summary>
- /// Created parameter for REST API call with the symbols encoded to url-safe escape characters.
- /// </summary>
- public string SafeParameter
- {
- get
- {
- return WWW.EscapeURL(param);
- }
- }
- /// <summary>
- /// Create new FirebaseQuery
- /// </summary>
- /// <param name="param">REST call parameters on a string. Example: "orderBy=\"$key\""print=pretty"auth=secret123"></param>
- public FirebaseParam(string _param = "")
- {
- param = _param;
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam Add(string parameter)
- {
- if (param != null && param.Length > 0)
- param += "&";
- param += parameter;
- return this;
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data . Set quoted parameter if necessary
- /// </summary>
- public FirebaseParam Add(string header, string value, bool quoted = true)
- {
- return (quoted) ? Add(header + "=\"" + value + "\"") : Add(header + "=" + value);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam Add(string header, int value)
- {
- return Add(header + "=" + value);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam Add(string header, float value)
- {
- return Add(header + "=" + value);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam Add(string header, bool value)
- {
- return Add(header + "=" + value);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam OrderByChild(string key)
- {
- return Add("orderBy", key);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam OrderByKey()
- {
- return Add("orderBy", "$key");
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam OrderByValue()
- {
- return Add("orderBy", "$value");
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam OrderByPriority()
- {
- return Add("orderBy", "$priority");
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam LimitToFirst(int lim)
- {
- return Add("limitToFirst", lim);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam LimitToLast(int lim)
- {
- return Add("limitToLast", lim);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam StartAt(string start)
- {
- return Add("startAt", start);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam StartAt(int start)
- {
- return Add("startAt", start);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam StartAt(bool start)
- {
- return Add("startAt", start);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam StartAt(float start)
- {
- return Add("startAt", start);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam EndAt(string end)
- {
- return Add("endAt", end);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam EndAt(int end)
- {
- return Add("endAt", end);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam EndAt(bool end)
- {
- return Add("endAt", end);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam EndAt(float end)
- {
- return Add("endAt", end);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam EqualTo(string at)
- {
- return Add("equalTo", at);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam EqualTo(int at)
- {
- return Add("equalTo", at);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam EqualTo(bool at)
- {
- return Add("equalTo", at);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam EqualTo(float at)
- {
- return Add("equalTo", at);
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam PrintPretty()
- {
- return Add("print=pretty");
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam PrintSilent()
- {
- return Add("print=silent");
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam Shallow()
- {
- return Add("shallow=true");
- }
- /// <summary>
- /// For details see https://firebase.google.com/docs/database/rest/retrieve-data
- /// </summary>
- public FirebaseParam Auth(string cred)
- {
- return Add("auth=" + cred);
- }
- public override string ToString()
- {
- return param;
- }
- /// <summary>
- /// Empty paramete or \"\"
- /// </summary>
- public static FirebaseParam Empty
- {
- get
- {
- return new FirebaseParam();
- }
- }
- }
- }
|