Skip to content

Commit

Permalink
Improve Graph methods (#1938)
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamdsheth authored Jun 8, 2022
1 parent f026018 commit 82a05a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 37 deletions.
42 changes: 6 additions & 36 deletions src/Commands/Utilities/ServiceHealthUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,8 @@ internal static class ServiceHealthUtility
/// <returns>List with <see cref="ServiceUpdateMessage"> objects</returns>
public static async Task<IEnumerable<ServiceUpdateMessage>> GetServiceUpdateMessagesAsync(HttpClient httpClient, string accessToken)
{
var returnCollection = new List<ServiceUpdateMessage>();
var collection = await GraphHelper.GetAsync<RestResultCollection<ServiceUpdateMessage>>(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<RestResultCollection<ServiceUpdateMessage>>(httpClient, collection.NextLink, accessToken);
returnCollection.AddRange(collection.Items);
}
}
return returnCollection;
var collection = await GraphHelper.GetResultCollectionAsync<ServiceUpdateMessage>(httpClient, $"v1.0/admin/serviceAnnouncement/messages", accessToken);
return collection;
}

/// <summary>
Expand Down Expand Up @@ -214,18 +204,8 @@ public static async Task<bool> SetServiceUpdateMessageAsNotfavoriteByIdAsync(str
/// <returns>List with <see cref="ServiceHealthIssue"> objects</returns>
public static async Task<IEnumerable<ServiceHealthIssue>> GetServiceHealthIssuesAsync(HttpClient httpClient, string accessToken)
{
var returnCollection = new List<ServiceHealthIssue>();
var collection = await GraphHelper.GetAsync<RestResultCollection<ServiceHealthIssue>>(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<RestResultCollection<ServiceHealthIssue>>(httpClient, collection.NextLink, accessToken);
returnCollection.AddRange(collection.Items);
}
}
return returnCollection;
var collection = await GraphHelper.GetResultCollectionAsync<ServiceHealthIssue>(httpClient, $"v1.0/admin/serviceAnnouncement/issues", accessToken);
return collection;
}

/// <summary>
Expand Down Expand Up @@ -253,18 +233,8 @@ public static async Task<ServiceHealthIssue> GetServiceHealthIssueByIdAsync(stri
/// <returns>List with <see cref="ServiceHealthCurrent"> objects</returns>
public static async Task<IEnumerable<ServiceHealthCurrent>> GetServiceCurrentHealthAsync(HttpClient httpClient, string accessToken)
{
var returnCollection = new List<ServiceHealthCurrent>();
var collection = await GraphHelper.GetAsync<RestResultCollection<ServiceHealthCurrent>>(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<RestResultCollection<ServiceHealthCurrent>>(httpClient, collection.NextLink, accessToken);
returnCollection.AddRange(collection.Items);
}
}
return returnCollection;
var collection = await GraphHelper.GetResultCollectionAsync<ServiceHealthCurrent>(httpClient, $"v1.0/admin/serviceAnnouncement/healthOverviews", accessToken);
return collection;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Utilities/TeamsUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ public static async Task<TeamChannelMessageReply> GetMessageReplyAsync(HttpClien

public static async Task<TeamChannel> 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

Expand Down

0 comments on commit 82a05a0

Please sign in to comment.