using System;
using System.Net.Http;
using System.Runtime.CompilerServices;
using Firebase.Database.Query;
[assembly: InternalsVisibleTo("Firebase.Database.Tests")]
namespace Firebase.Database
{
///
/// Firebase client which acts as an entry point to the online database.
///
public class FirebaseClient : IDisposable
{
private readonly string baseUrl;
internal readonly HttpClient HttpClient;
internal readonly FirebaseOptions Options;
///
/// Initializes a new instance of the class.
///
/// The base url.
/// Offline database.
public FirebaseClient(string baseUrl, FirebaseOptions options = null)
{
HttpClient = new HttpClient();
Options = options ?? new FirebaseOptions();
this.baseUrl = baseUrl;
if (!this.baseUrl.EndsWith("/")) this.baseUrl += "/";
}
public void Dispose()
{
HttpClient?.Dispose();
}
///
/// Queries for a child of the data root.
///
/// Name of the child.
/// .
public ChildQuery Child(string resourceName)
{
return new ChildQuery(this, () => baseUrl + resourceName);
}
}
}