summaryrefslogtreecommitdiff
path: root/FireBase/Query/AuthQuery.cs
diff options
context:
space:
mode:
authorTrueKuehli <rctcoaster2000@hotmail.de>2018-09-29 17:19:43 +0200
committerTrueKuehli <rctcoaster2000@hotmail.de>2018-09-29 17:19:43 +0200
commitb83fc90abacc73262e0f8404cebadf6d64eb10ae (patch)
treed63b921c9bcdf8d381fc02ecfb0a1dd425ebb561 /FireBase/Query/AuthQuery.cs
parent586d564f3c4c509c1aae931331e96f0382178f80 (diff)
parent680967aee589e4a8d277044b204de07cbe32f41e (diff)
Merge branch 'WebApi' of https://github.com/TrueDoctor/DiscoBot into WebApi
Merged the stuffs
Diffstat (limited to 'FireBase/Query/AuthQuery.cs')
-rw-r--r--FireBase/Query/AuthQuery.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/FireBase/Query/AuthQuery.cs b/FireBase/Query/AuthQuery.cs
new file mode 100644
index 0000000..8a8d3e8
--- /dev/null
+++ b/FireBase/Query/AuthQuery.cs
@@ -0,0 +1,33 @@
+namespace Firebase.Database.Query
+{
+ using System;
+
+ /// <summary>
+ /// Represents an auth parameter in firebase query, e.g. "?auth=xyz".
+ /// </summary>
+ public class AuthQuery : ParameterQuery
+ {
+ private readonly Func<string> tokenFactory;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AuthQuery"/> class.
+ /// </summary>
+ /// <param name="parent"> The parent. </param>
+ /// <param name="tokenFactory"> The authentication token factory. </param>
+ /// <param name="client"> The owner. </param>
+ public AuthQuery(FirebaseQuery parent, Func<string> tokenFactory, FirebaseClient client) : base(parent, () => client.Options.AsAccessToken ? "access_token" : "auth", client)
+ {
+ this.tokenFactory = tokenFactory;
+ }
+
+ /// <summary>
+ /// Build the url parameter value of this child.
+ /// </summary>
+ /// <param name="child"> The child of this child. </param>
+ /// <returns> The <see cref="string"/>. </returns>
+ protected override string BuildUrlParameter(FirebaseQuery child)
+ {
+ return this.tokenFactory();
+ }
+ }
+}