Exemplo n.º 1
0
        /// <summary>
        /// Gets a Slack user in the current team based on the user's ID.
        /// </summary>
        /// <param name="id">User ID to be found.</param>
        /// <returns>User data if the ID was found, null otherwise.</returns>
        /// <remarks>This will always pull from local cache if available.</remarks>
        public async Task <User> GetUserAsync(IUserId id)
        {
            // try to find the user in local cache first
            var user = _database.FindWithChildren <User>(id.GetUserId());

            // if the user wasn't found, pull it from the server and cache it.
            if (user == null)
            {
                var request  = new GetUserRequest(id);
                var response = await _restClient.RequestAsync <GetUserResponse>(request);

                // TODO: Should be checking response.OK to make sure it succeeded, and handle the error if it didn't

                user = response.User;
            }

            return(user);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets a Slack user in the current team based on the user's ID.
        /// </summary>
        /// <param name="id">User ID to be found.</param>
        /// <returns>User data if the ID was found, null otherwise.</returns>
        /// <remarks>This will always pull from local cache if available.</remarks>
        public async Task<User> GetUserAsync(IUserId id)
        {
            // try to find the user in local cache first
            var user = _database.FindWithChildren<User>(id.GetUserId());

            // if the user wasn't found, pull it from the server and cache it.
            if (user == null)
            {
                var request = new GetUserRequest(id);
                var response = await _restClient.RequestAsync<GetUserResponse>(request);

                // TODO: Should be checking response.OK to make sure it succeeded, and handle the error if it didn't

                user = response.User;
            }

            return user;
        }