PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Atlassian.Jira/Remote/IssueResolutionService.cs

https://bitbucket.org/farmas/atlassian.net-sdk
C# | 31 lines | 26 code | 5 blank | 0 comment | 1 complexity | 03957e8a7098d1c55426c4260291b4f0 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using RestSharp;
  6. namespace Atlassian.Jira.Remote
  7. {
  8. internal class IssueResolutionService : IIssueResolutionService
  9. {
  10. private readonly Jira _jira;
  11. public IssueResolutionService(Jira jira)
  12. {
  13. _jira = jira;
  14. }
  15. public async Task<IEnumerable<IssueResolution>> GetResolutionsAsync(CancellationToken token)
  16. {
  17. var cache = _jira.Cache;
  18. if (!cache.Resolutions.Any())
  19. {
  20. var resolutions = await _jira.RestClient.ExecuteRequestAsync<RemoteResolution[]>(Method.GET, "rest/api/2/resolution", null, token).ConfigureAwait(false);
  21. cache.Resolutions.TryAdd(resolutions.Select(r => new IssueResolution(r)));
  22. }
  23. return cache.Resolutions.Values;
  24. }
  25. }
  26. }