internal static Message FormatMessage(Message message, Components components, string token, string imId = null,
                                              string channelId      = null,
                                              bool isPrivateMessage = false,
                                              bool isChannelMessage = false)
        {
            string userName = UserMethods.GetUserName(components.Users, message.UserId);

            if (userName == null)
            {
                components.Users = UserHelper.GetUsers(token);

                userName = UserMethods.GetUserName(components.Users, message.UserId);
            }

            string botName = BotMethods.GetBotName(components.Bots, message.BotId);

            if (botName == null)
            {
                components.Bots = BotsHelper.GetBots(token);

                botName = BotMethods.GetBotName(components.Bots, message.BotId);
            }

            string imName = ImMethos.GetImName(components.Ims, components.Users, imId);

            if (imName == null)
            {
                components.Ims = ImHelper.GetIms(token);

                imName = ImMethos.GetImName(components.Ims, components.Users, imId);
            }

            string channelName = ChannelMethods.GetChannelName(components.Channels, channelId);

            if (channelName == null)
            {
                components.Channels = ChannelHelper.GetChannels(token);

                channelName = ChannelMethods.GetChannelName(components.Channels, channelId);
            }

            message.UserName    = botName ?? userName;
            message.ChannelName = isPrivateMessage ? null : (imName ?? channelName);
            message.ChannelId   = channelId;

            message.IsPrivateMessage = isPrivateMessage;
            message.IsGroupMessage   = isChannelMessage;

            return(message);
        }
        public InitializationResults Initialize(string token)
        {
            var result = new InitializationResults();

            try
            {
                if (token == null)
                {
                    throw new SlackApiException(nameof(token));
                }

                if (string.IsNullOrWhiteSpace(token))
                {
                    throw new SlackApiException(nameof(token));
                }

                //TODO: WHEN NO JSON FILES EXISTS, WHAT TO DO?

                string authJson     = JsonUtility.ReadJsonFromFile(fileName: "auth");
                string usersJson    = JsonUtility.ReadJsonFromFile(fileName: "users");
                string channelsJson = JsonUtility.ReadJsonFromFile(fileName: "channels");
                string imsJson      = JsonUtility.ReadJsonFromFile(fileName: "ims");

                var auth  = AuthHelper.GetAuthResponseFromJson(authJson);
                var users = UserHelper.GetUsersFromJson(usersJson);

                var components = new Components
                {
                    Profile  = ProfileHelper.GetProfile(users, auth.UserId),
                    Channels = ChannelHelper.GetChannelsFromJson(channelsJson),
                    Ims      = ImHelper.GetImsFromJson(imsJson),
                    Users    = users,
                    Bots     = BotsHelper.GetBotsFromJson(),
                    Emojis   = new List <EmojiParent>()
                };

                this.Components = components;

                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message   = ex.Message;
            }

            return(result);
        }
        public InitializationResults Initialize(string token)
        {
            var result = new InitializationResults();

            try
            {
                if (token == null)
                {
                    throw new SlackApiException(nameof(token));
                }

                if (string.IsNullOrWhiteSpace(token))
                {
                    throw new SlackApiException(nameof(token));
                }

                var auth = AuthHelper.GetAuthResponse(token);

                var users = UserHelper.GetUsers(token);

                var components = new Components
                {
                    Profile  = ProfileHelper.GetProfile(users, auth.UserId),
                    Channels = ChannelHelper.GetChannels(token),
                    Ims      = ImHelper.GetIms(token),
                    Users    = users,
                    Bots     = BotsHelper.GetBots(token),
                    Emojis   = new List <EmojiParent>()
                };

                this.Token      = token;
                this.ProfileId  = auth.UserId;
                this.Components = components;

                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message   = ex.Message;
            }

            return(result);
        }