Skip to content

Commit

Permalink
fix category bug
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorbye committed Apr 19, 2024
1 parent 2c6b245 commit a29e2d6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions grade-sync-api/Services/OneRoster/OneRosterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,19 @@ public async Task<List<Category>> GetActiveCategories()
{
var url = $"{_apiCreds!.OneRosterBaseUrl}/categories";
var token = await GetOrRefreshAccessToken();
var paginated = await OneRosterHttpClient.PaginatedGetRequest<CategoryWrapper>(_httpClient!, url, token, _defaultPageSize);
var combined = paginated.FirstOrDefault();
combined!.CombinePages(paginated);
var req = await OneRosterHttpClient.GetRequest(_httpClient!, url, token);
var res = req.Item2;

return combined.Categories.Where(category => category.Status == "active").ToList();
try
{
res.EnsureSuccessStatusCode();
var wrapper = JsonConvert.DeserializeObject<CategoryWrapper>(req.Item1);
return wrapper!.Categories.Where(category => category.Status == "active").ToList();
}
catch (Exception)
{
throw new ApplicationException($"Error fetching OneRoster categories.");
}
}

public async Task<List<Enrollment>> GetEnrollmentsByClass(string classSourcedId)
Expand Down

0 comments on commit a29e2d6

Please sign in to comment.