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))) { WriteObject(Identity.GetTab(HttpClient, AccessToken, groupId, channelId)); } else { WriteObject(TeamsUtility.GetTabsAsync(AccessToken, HttpClient, groupId, channelId).GetAwaiter().GetResult(), 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.GetTabAsync(accessToken, httpClient, groupId, channelId, _id).GetAwaiter().GetResult(); if (string.IsNullOrEmpty(tab.Id)) { var tabs = TeamsUtility.GetTabsAsync(accessToken, httpClient, groupId, channelId).GetAwaiter().GetResult(); 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"); } } }