Exemple #1
0
        /// <summary>
        /// Fetches the information of the currently authenticated user.
        /// </summary>
        /// <param name="context">The current http context</param>
        /// <returns>A task of an either monad</returns>
        public async Task <Either <User, Error> > GetAsync(HttpContext context)
        {
            try
            {
                var method = HttpMethod.Get;
                var url    = $"api/user";

                return(await _apiInteropService.SendAsync <User>(context, method, url));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(new Failure <User, Error>(SystemErrors.Exception()));
            }
        }
Exemple #2
0
        /// <summary>
        /// This method will fetch information about a private group based on the provided id.
        /// </summary>
        /// <param name="context">The http context of the current request</param>
        /// <param name="groupId">The id of the private group</param>
        /// <returns>A task that encapsulates an either monad</returns>
        public async Task <Either <PrivateGroup, Error> > GetPrivateGroupAsync(HttpContext context, long groupId)
        {
            try
            {
                var url    = $"/api/groups/{groupId}";
                var method = HttpMethod.Get;

                return(await _apiInteropService.SendAsync <PrivateGroup>(context, method, url));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(new Failure <PrivateGroup, Error>(SystemErrors.Exception()));
            }
        }
        /// <summary>
        /// Fetches all available information about a direct messaging entry based on the provided id.
        /// </summary>
        /// <param name="context">The http context of the current request</param>
        /// <param name="directMessagingId">The id of the target entry</param>
        /// <returns>An either monad</returns>
        public async Task <Either <DirectMessaging, Error> > GetAsync(HttpContext context, long directMessagingId)
        {
            try
            {
                var method = HttpMethod.Get;
                var url    = $"/api/direct/{directMessagingId}";

                return(await _apiInteropService.SendAsync <DirectMessaging>(context, method, url));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(new Failure <DirectMessaging, Error>(SystemErrors.Exception()));
            }
        }