Skip to content

#38 Worklog #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions TechTalk.JiraRestClient/Compatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ public void DeleteAttachment(Attachment attachment)
client.DeleteAttachment(attachment);
}

public IEnumerable<Worklog> GetWorklogList(int[] ids)
{
return client.GetWorklogList(ids);
}

public IEnumerable<Worklog> GetWorklogsByIssueId(int id)
{
return client.GetWorklogsByIssueId(id);
}

public IEnumerable<IssueLink> GetIssueLinks(IssueRef issue)
{
return client.GetIssueLinks(issue);
Expand Down
6 changes: 6 additions & 0 deletions TechTalk.JiraRestClient/IJiraClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ namespace TechTalk.JiraRestClient
/// <summary>Changes the state of the given issue as described by the transition</summary>
Issue<TIssueFields> TransitionIssue(IssueRef issue, Transition transition);

/// <summary>Returns worklogs for given worklog ids</summary>
IEnumerable<Worklog> GetWorklogList(int[] ids);

/// <summary>Returns worklogs by issue id</summary>
IEnumerable<Worklog> GetWorklogsByIssueId(int id);

/// <summary>Returns all watchers for the given issue</summary>
IEnumerable<JiraUser> GetWatchers(IssueRef issue);

Expand Down
2 changes: 2 additions & 0 deletions TechTalk.JiraRestClient/IssueFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ public IssueFields()
public List<Comment> comments { get; set; }
public List<IssueLink> issuelinks { get; set; }
public List<Attachment> attachment { get; set; }

public List<Worklog> worklogs { get; set; }
}
}
46 changes: 46 additions & 0 deletions TechTalk.JiraRestClient/JiraClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Net;
using System.Text;
using TechTalk.JiraRestClient.Utils;
using RestSharp;
using RestSharp.Deserializers;

Expand Down Expand Up @@ -48,6 +49,51 @@ private void AssertStatus(IRestResponse response, HttpStatusCode status)
throw new JiraClientException("JIRA returned wrong status: " + response.StatusDescription, response.Content);
}

/// <summary>
/// Get Worklog List by worklog's id
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public IEnumerable<Worklog> GetWorklogList(int[] ids)
{
try
{
var request = CreateRequest(Method.GET, "worklog/list");
request.AddHeader("ContentType", "application/json");
request.AddBody(new { ids = ids });

var response = ExecuteRequest(request);
AssertStatus(response, HttpStatusCode.OK);

var data = deserializer.Deserialize<List<Worklog>>(response);
return data;
}
catch (Exception ex)
{
Trace.TraceError("GetWorklogList() error: {0}", ex);
throw new JiraClientException("Could not load worklog list", ex);
}
}

public IEnumerable<Worklog> GetWorklogsByIssueId(int id)
{
try
{
var request = CreateRequest(Method.GET, $"/{id}/worklog");
request.AddHeader("ContentType", "application/json");

var response = ExecuteRequest(request);
AssertStatus(response, HttpStatusCode.OK);

var data = deserializer.Deserialize<List<Worklog>>(response);
return data;
}
catch (Exception ex)
{
Trace.TraceError("GetWorklogsByIssueId() error: {0}", ex);
throw new JiraClientException("Could not load worklog list of issue", ex);
}
}

public IEnumerable<Issue<TIssueFields>> GetIssues(String projectKey)
{
Expand Down
1 change: 1 addition & 0 deletions TechTalk.JiraRestClient/TechTalk.JiraRestClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<Compile Include="Transition.cs" />
<Compile Include="Timetracking.cs" />
<Compile Include="TransitionsContainer.cs" />
<Compile Include="Worklog.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config">
Expand Down
16 changes: 16 additions & 0 deletions TechTalk.JiraRestClient/Worklog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace TechTalk.JiraRestClient
{
public class Worklog
{
public JiraUser author { get; set; }
public JiraUser updateAuthor { get; set; }
public string comment { get; set; }
public DateTime updated { get; set; }
public string timeSpent { get; set; }
public int timeSpentSeconds { get; set; }
public string id { get; set; }
public string issueId { get; set; }
}
}