Ejemplo n.º 1
0
        // ---------[ AUTHENTICATED USER ]---------
        public static void GetAuthenticatedUserProfile(Action <UserProfile> onSuccess,
                                                       Action <WebRequestError> onError)
        {
            UserProfile cachedProfile = CacheClient.LoadAuthenticatedUserProfile();

            if (cachedProfile != null)
            {
                if (onSuccess != null)
                {
                    onSuccess(cachedProfile);
                }
            }
            else
            {
                // - Fetch from Server -
                Action <UserProfile> onGetUser = (profile) =>
                {
                    CacheClient.SaveAuthenticatedUserProfile(profile);
                    if (onSuccess != null)
                    {
                        onSuccess(profile);
                    }
                };

                APIClient.GetAuthenticatedUser(onGetUser, onError);
            }
        }