/Atlassian.Jira/Remote/IssueResolutionService.cs
C# | 31 lines | 26 code | 5 blank | 0 comment | 1 complexity | 03957e8a7098d1c55426c4260291b4f0 MD5 | raw file
Possible License(s): BSD-3-Clause
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- using RestSharp;
- namespace Atlassian.Jira.Remote
- {
- internal class IssueResolutionService : IIssueResolutionService
- {
- private readonly Jira _jira;
- public IssueResolutionService(Jira jira)
- {
- _jira = jira;
- }
- public async Task<IEnumerable<IssueResolution>> GetResolutionsAsync(CancellationToken token)
- {
- var cache = _jira.Cache;
- if (!cache.Resolutions.Any())
- {
- var resolutions = await _jira.RestClient.ExecuteRequestAsync<RemoteResolution[]>(Method.GET, "rest/api/2/resolution", null, token).ConfigureAwait(false);
- cache.Resolutions.TryAdd(resolutions.Select(r => new IssueResolution(r)));
- }
- return cache.Resolutions.Values;
- }
- }
- }