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"); } } }