| // Copyright 2015 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| [DartPackage="sky_services"] |
| module firebase; |
| |
| enum EventType { |
| EventTypeChildAdded, // 0, fired when a new child node is added to a location |
| EventTypeChildRemoved, // 1, fired when a child node is removed from a location |
| EventTypeChildChanged, // 2, fired when a child node at a location changes |
| EventTypeChildMoved, // 3, fired when a child node moves relative to the other child nodes at a location |
| EventTypeValue // 4, fired when any data changes at a location and, recursively, any children |
| }; |
| |
| struct DataSnapshot { |
| string key; |
| string jsonValue; |
| }; |
| |
| struct Error { |
| int32 code; |
| string message; |
| }; |
| |
| struct AuthData { |
| string uid; |
| string provider; |
| string token; |
| }; |
| |
| interface ValueEventListener { |
| OnCancelled(Error error); |
| OnDataChange(DataSnapshot snapshot); |
| }; |
| |
| interface ChildEventListener { |
| OnCancelled(Error error); |
| OnChildAdded(DataSnapshot snapshot, string? previousChildName); |
| OnChildChanged(DataSnapshot snapshot, string? previousChildName); |
| OnChildMoved(DataSnapshot snapshot, string? previousChildName); |
| OnChildRemoved(DataSnapshot snapshot); |
| }; |
| |
| [ServiceName="firebase::Firebase"] |
| interface Firebase { |
| InitWithUrl(string url); |
| AddValueEventListener(ValueEventListener listener); |
| AddChildEventListener(ChildEventListener listener); |
| ObserveSingleEventOfType(EventType eventType) => (DataSnapshot snapshot); |
| AuthWithCustomToken(string token) => (Error? error, AuthData? authData); |
| AuthAnonymously() => (Error? error, AuthData? authData); |
| AuthWithOAuthToken(string provider, string credentials) => (Error? error, AuthData? authData); |
| AuthWithPassword(string email, string password) => (Error? error, AuthData? authData); |
| Unauth() => (Error? error); |
| GetChild(string path, Firebase& child); |
| GetParent(Firebase& parent); |
| GetRoot(Firebase& root); |
| SetValue(string jsonValue, int32 priority, bool hasPriority) => (Error? error); |
| RemoveValue() => (Error? error); |
| Push(Firebase& child) => (string key); |
| SetPriority(int32 priority) => (Error? error); |
| CreateUser(string email, string password) => (Error? error, string? jsonValue); |
| ChangeEmail(string oldEmail, string password, string newEmail) => (Error? error); |
| ChangePassword(string newPassword, string email, string oldPassword) => (Error? error); |
| RemoveUser(string email, string password) => (Error? error); |
| ResetPassword(string email) => (Error? error); |
| }; |