/// <summary> /// Log work for the specified issue /// </summary> /// <param name="jiraClient">IWorkDomain to bind the extension method to</param> /// <param name="issueKey">key for the issue</param> /// <param name="worklog">Worklog with the work which needs to be logged</param> /// <param name="adjustEstimate"> /// allows you to provide specific instructions to update the remaining time estimate of the /// issue. /// </param> /// <param name="adjustValue"> /// e.g. "2d". /// When "new" is selected for adjustEstimate the new value for the remaining estimate field. /// When "manual" is selected for adjustEstimate the amount to reduce the remaining estimate by. /// </param> /// <param name="cancellationToken">CancellationToken</param> public static async Task <Worklog> CreateAsync(this IWorkDomain jiraClient, string issueKey, Worklog worklog, AdjustEstimate adjustEstimate = AdjustEstimate.Auto, string adjustValue = null, CancellationToken cancellationToken = default) { if (issueKey == null) { throw new ArgumentNullException(nameof(issueKey)); } if (worklog == null) { throw new ArgumentNullException(nameof(worklog)); } var worklogUri = jiraClient.JiraRestUri.AppendSegments("issue", issueKey, "worklog"); if (adjustEstimate != AdjustEstimate.Auto) { worklogUri = worklogUri.ExtendQuery("adjustEstimate", adjustEstimate.EnumValueOf()); switch (adjustEstimate) { case AdjustEstimate.Manual: worklogUri = worklogUri.ExtendQuery("reduceBy", adjustValue); break; case AdjustEstimate.New: worklogUri = worklogUri.ExtendQuery("newEstimate", adjustValue); break; } } jiraClient.Behaviour.MakeCurrent(); var response = await worklogUri.PostAsync <HttpResponse <Worklog, Error> >(worklog, cancellationToken).ConfigureAwait(false); return(response.HandleErrors(HttpStatusCode.Created)); }
/// <summary> /// Get worklogs information /// </summary> /// <param name="jiraClient">IWorkDomain to bind the extension method to</param> /// <param name="issueKey">the issue key</param> /// <param name="cancellationToken">CancellationToken</param> /// <returns>Worklogs</returns> public static async Task <Worklogs> GetAsync(this IWorkDomain jiraClient, string issueKey, CancellationToken cancellationToken = default) { if (issueKey == null) { throw new ArgumentNullException(nameof(issueKey)); } Log.Debug().WriteLine("Retrieving worklogs information for {0}", issueKey); var worklogUri = jiraClient.JiraRestUri.AppendSegments("issue", issueKey, "worklog"); jiraClient.Behaviour.MakeCurrent(); var response = await worklogUri.GetAsAsync <HttpResponse <Worklogs, Error> >(cancellationToken).ConfigureAwait(false); return(response.HandleErrors()); }