Example #1
0
 public static void PostUser(UserData user, PostUserCallback callback)
 {
     RestClient.Put <UserData>($"{databaseURL}users/{user.username}.json", user).Then(response => {
         Debug.Log("PostUser");
         callback();
     });
 }
Example #2
0
 public static void PostUser(User user, string level, PostUserCallback callback)
 {
     RestClient.Put <User>($"{databaseUrl}users/{level}/{user.username}.json", user).Then(response => {
         Debug.Log("The use was successfully uploaded to the database");
         callback();
     });
 }
Example #3
0
    // Adds a PlayerSession to the Firebase Database
    public static void PostPlayerSession(PlayerSession session, PostUserCallback callback)
    {
        //auth.SignInWithEmailAndPasswordAsync(YipliHelper.userName, YipliHelper.password).ContinueWith(task => {
        auth.SignInAnonymouslyAsync().ContinueWith(task => {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInAnonymouslyAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception);
                return;
            }

            Firebase.Auth.FirebaseUser newUser = task.Result;
            Debug.LogFormat("User signed in successfully: {0} ({1})",
                            newUser.DisplayName, newUser.UserId);

            //FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://yipli-project.firebaseio.com/");
            DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

            Debug.Log("Pushing data to backend: " + JsonConvert.SerializeObject(session.GetPlayerSessionDataJsonDic()));

            string key = reference.Child("stage-bucket/player-sessions").Push().Key;
            reference.Child("stage-bucket/player-sessions").Child(key).SetRawJsonValueAsync(JsonConvert.SerializeObject(session.GetPlayerSessionDataJsonDic(), Formatting.None, new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            }));
        });
    }
Example #4
0
    public static void AtualizaUser(User newUser, string userName, PostUserCallback callback)
    {
        string attUserKey = "";

        GetUsers(users => {
            foreach (var user in users)
            {
                if (userName != null && userName.Equals(user.Value.name))
                {
                    attUserKey = user.Key;
                    Debug.Log($"this user key is {user.Key}");
                }
            }
            PostUser(newUser, attUserKey, () => { Debug.Log("att done!"); });
            return(200);
        });
    }
Example #5
0
 public static void PutUser(User newUser, string userId, PostUserCallback callback)
 {
     RestClient.Put <User>($"{databaseURL}users" + $"/{userId}.json", newUser).Then(response => { callback(); });
 }
Example #6
0
 /// <summary>
 /// Adds a user to the Firebase Database
 /// </summary>
 /// <param name="user"> User object that will be uploaded </param>
 /// <param name="userId"> Id of the user that will be uploaded </param>
 /// <param name="callback"> What to do after the user is uploaded successfully </param>
 /// <param name="idToken"> Token which authenticates the request </param>
 public static void PostUser(User user, string userId, PostUserCallback callback, string idToken)
 {
     RestClient.Put <User>($"{databaseURL}users/{userId}.json?auth={idToken}", user).Then(response => { callback(); });
 }
 /// <summary>
 /// Adds a user to the Firebase Database
 /// </summary>
 /// <param name="user"> User object that will be uploaded </param>
 /// <param name="userId"> Id of the user that will be uploaded </param>
 /// <param name="callback"> What to do after the user is uploaded successfully </param>
 public static void PostUser(Node node, string nodeId, PostUserCallback callback)
 {
     RestClient.Put <Node>($"{databaseURL}nodes/{nodeId}.json", node).Then(response => { callback(); });
 }
Example #8
0
 public static void PostUser(UserCredentials user, PostUserCallback callback)
 {
     RestClient.Put <UserCredentials>($"{databaseURL}users/{user.username}.json", user)
     .Then(response => { callback(); });
 }
Example #9
0
 /// <summary>
 /// Update the user data
 /// </summary>
 /// <param name="key"></param>
 /// <param name="userData"></param>
 /// <param name="callback"></param>
 public static void PutUser(string key, UserData userData, PostUserCallback callback)
 {
     RestClient.Put($"{databaseURL}students/" + key + ".json", userData).Then(response => { callback(); });
 }
 /// <summary>
 /// Adds a user to the Firebase Database
 /// </summary>
 /// <param name="user"> User object that will be uploaded </param>
 /// <param name="userId"> Id of the user that will be uploaded </param>
 /// <param name="callback"> What to do after the user is uploaded successfully </param>
 public static void PostUser(Patient user, string userId, PostUserCallback callback)
 {
     RestClient.Put <Patient>($"{databaseURL}users/{userId}.json", user).Then(response => { callback(); });
 }
Example #11
0
 /* The function to store ticket data to backend for this user.
  * This is to be called by your games shop manager module.*/
 public static async void UpdateCurrentTicketData(string strUserId, Dictionary <string, object> ticketData, PostUserCallback callback)
 {
     //await auth.SignInWithEmailAndPasswordAsync(YipliHelper.userName, YipliHelper.password).ContinueWith(async task =>
     await auth.SignInAnonymouslyAsync().ContinueWith(async task =>
     {
         if (task.IsCanceled)
         {
             Debug.LogError("SignInAnonymouslyAsync was canceled.");
             return;
         }
         if (task.IsFaulted)
         {
             Debug.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception);
             return;
         }
         Firebase.Auth.FirebaseUser newUser = task.Result;
         Debug.LogFormat("User signed in successfully: {0} ({1})",
                         newUser.DisplayName, newUser.UserId);
         //FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://yipli-project.firebaseio.com/");
         DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
         await reference.Child("customer-tickets/" + strUserId).Child("open/current_tkt/").UpdateChildrenAsync(ticketData);
     });
 }