Example #1
0
        public void GetGroups()
        {
            foreach (SlackHelper user_helper in users_helpers)
            {
                if (!user_helper.IsAuthorized)
                {
                    continue;
                }

                Responses.SlackChannelsListResponse slackChannelsListResponse = user_helper.Channels_List();

                if (!slackChannelsListResponse.Ok)
                {
                    continue;
                }

                List <Models.SlackChannel> channels = slackChannelsListResponse.Channels?.ToList();

                if (channels == null)
                {
                    continue;
                }

                List <GroupsListItem> groups_items = new List <GroupsListItem>();

                foreach (Models.SlackChannel channel in channels)
                {
                    if (!channel.IsMember)
                    {
                        continue;
                    }

                    GroupsListItem group_item = new GroupsListItem();
                    group_item.GroupName         = channel.Name;
                    group_item.SocialNetworkName = getSocialNetworkName();
                    group_item.User = new UserInfo()
                    {
                        SocialNetworkName = getSocialNetworkName(),
                        ID   = user_helper.User.ID,
                        Name = user_helper.User.RealName
                    };

                    groups_items.Add(group_item);
                }

                applicationContract.AddItemsToGroupsList(groups_items);
            }
        }
Example #2
0
        public Responses.SlackChannelsListResponse Channels_List()
        {
            if (!IsAuthorized)
            {
                throw new Exceptions.SlackAuthException("Not Authorized.");
            }

            Dictionary <String, String> parameters = new Dictionary <string, string>();

            parameters["token"] = _access_token;

            Uri channels_list_uri = GetApiUri("channels.list", parameters);

            Responses.SlackChannelsListResponse slackChannelsListResponse = JsonConvert.DeserializeObject <Responses.SlackChannelsListResponse>(NetHelper.GetRequest(channels_list_uri));

            return(slackChannelsListResponse);
        }