From 5a61e90c4ed0936c3f05c2d87c4d21079ea40322 Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Sun, 5 Jun 2022 23:38:01 +0300 Subject: [PATCH] Improve Graph methods --- .../Utilities/ServiceHealthUtility.cs | 42 +++---------------- src/Commands/Utilities/TeamsUtility.cs | 2 +- 2 files changed, 7 insertions(+), 37 deletions(-) diff --git a/src/Commands/Utilities/ServiceHealthUtility.cs b/src/Commands/Utilities/ServiceHealthUtility.cs index 84d0e6550..3f7f9612f 100644 --- a/src/Commands/Utilities/ServiceHealthUtility.cs +++ b/src/Commands/Utilities/ServiceHealthUtility.cs @@ -19,18 +19,8 @@ internal static class ServiceHealthUtility /// List with objects public static async Task> GetServiceUpdateMessagesAsync(HttpClient httpClient, string accessToken) { - var returnCollection = new List(); - var collection = await GraphHelper.GetAsync>(httpClient, $"v1.0/admin/serviceAnnouncement/messages", accessToken); - if (collection != null && collection.Items.Any()) - { - returnCollection = collection.Items.ToList(); - while (!string.IsNullOrEmpty(collection.NextLink)) - { - collection = await GraphHelper.GetAsync>(httpClient, collection.NextLink, accessToken); - returnCollection.AddRange(collection.Items); - } - } - return returnCollection; + var collection = await GraphHelper.GetResultCollectionAsync(httpClient, $"v1.0/admin/serviceAnnouncement/messages", accessToken); + return collection; } /// @@ -214,18 +204,8 @@ public static async Task SetServiceUpdateMessageAsNotfavoriteByIdAsync(str /// List with objects public static async Task> GetServiceHealthIssuesAsync(HttpClient httpClient, string accessToken) { - var returnCollection = new List(); - var collection = await GraphHelper.GetAsync>(httpClient, $"v1.0/admin/serviceAnnouncement/issues", accessToken); - if (collection != null && collection.Items.Any()) - { - returnCollection = collection.Items.ToList(); - while (!string.IsNullOrEmpty(collection.NextLink)) - { - collection = await GraphHelper.GetAsync>(httpClient, collection.NextLink, accessToken); - returnCollection.AddRange(collection.Items); - } - } - return returnCollection; + var collection = await GraphHelper.GetResultCollectionAsync(httpClient, $"v1.0/admin/serviceAnnouncement/issues", accessToken); + return collection; } /// @@ -253,18 +233,8 @@ public static async Task GetServiceHealthIssueByIdAsync(stri /// List with objects public static async Task> GetServiceCurrentHealthAsync(HttpClient httpClient, string accessToken) { - var returnCollection = new List(); - var collection = await GraphHelper.GetAsync>(httpClient, $"v1.0/admin/serviceAnnouncement/healthOverviews", accessToken); - if (collection != null && collection.Items.Any()) - { - returnCollection = collection.Items.ToList(); - while (!string.IsNullOrEmpty(collection.NextLink)) - { - collection = await GraphHelper.GetAsync>(httpClient, collection.NextLink, accessToken); - returnCollection.AddRange(collection.Items); - } - } - return returnCollection; + var collection = await GraphHelper.GetResultCollectionAsync(httpClient, $"v1.0/admin/serviceAnnouncement/healthOverviews", accessToken); + return collection; } /// diff --git a/src/Commands/Utilities/TeamsUtility.cs b/src/Commands/Utilities/TeamsUtility.cs index ced2b994d..47a6d3f4d 100644 --- a/src/Commands/Utilities/TeamsUtility.cs +++ b/src/Commands/Utilities/TeamsUtility.cs @@ -674,7 +674,7 @@ public static async Task GetMessageReplyAsync(HttpClien public static async Task UpdateChannelAsync(HttpClient httpClient, string accessToken, string groupId, string channelId, TeamChannel channel) { - return await GraphHelper.PatchAsync(httpClient, accessToken, $"beta/teams/{groupId}/channels/{channelId}", channel); + return await GraphHelper.PatchAsync(httpClient, accessToken, $"v1.0/teams/{groupId}/channels/{channelId}", channel); } #endregion