Пример #1
0
        protected override void ExecuteCmdlet()
        {
            var groupId = Team.GetGroupId(HttpClient, AccessToken);

            if (groupId != null)
            {
                var channelId = Channel.GetId(HttpClient, AccessToken, groupId);
                if (!string.IsNullOrEmpty(channelId))
                {
                    if (ParameterSpecified(nameof(Identity)))
                    {
                        if (string.IsNullOrEmpty(Identity.Id))
                        {
                            WriteObject(Identity.GetTab(HttpClient, AccessToken, groupId, channelId));
                        }
                        else
                        {
                            WriteObject(Identity.GetTabById(HttpClient, AccessToken, groupId, channelId));
                        }
                    }
                    else
                    {
                        WriteObject(TeamsUtility.GetTabs(AccessToken, HttpClient, groupId, channelId), true);
                    }
                }
                else
                {
                    throw new PSArgumentException("Channel not found");
                }
            }
            else
            {
                throw new PSArgumentException("Team not found");
            }
        }
 public TeamTab GetTab(HttpClient httpClient, string accessToken, string groupId, string channelId)
 {
     if (_tab != null)
     {
         return _tab;
     }
     else
     {
         var tab = TeamsUtility.GetTab(accessToken, httpClient, groupId, channelId, _id);
         if (string.IsNullOrEmpty(tab.Id))
         {
             var tabs = TeamsUtility.GetTabs(accessToken, httpClient, groupId, channelId);
             if (tabs != null)
             {
                 // find the tab by id
                 tab = tabs.FirstOrDefault(t => t.DisplayName.Equals(_displayName, System.StringComparison.OrdinalIgnoreCase));
             }
         }
         if (tab != null)
         {
             return tab;
         }
         else
         {
             throw new PSArgumentException("Cannot find tab");
         }
     }
 }