1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2024-11-24 08:22:42 +02:00

[ISSUE] Add: Rank API

This commit is contained in:
Chhekur 2021-11-22 18:24:06 +05:30 committed by Harendra Chhekur
parent 59bda3c9b6
commit 131e4b5f2c

View File

@ -606,6 +606,20 @@ type RemoteLinkStatus struct {
Icon *RemoteLinkIcon `json:"icon,omitempty" structs:"icon,omitempty"`
}
// type for rank api
type RankBeforeReqBody struct {
Issues []string `json:"issues"`
RankBeforeIssue string `json:"rankBeforeIssue"`
RankCustomFieldId int64 `json:"rankCustomFieldId"`
}
type RankAfterReqBody struct {
Issues []string `json:"issues"`
RankAfterIssue string `json:"rankAfterIssue"`
RankCustomFieldId int64 `json:"rankCustomFieldId"`
}
// GetWithContext returns a full representation of the issue for the given issue key.
// Jira will attempt to identify the issue by the issueIdOrKey path parameter.
// This can be an issue id, or an issue key.
@ -782,6 +796,39 @@ func (s *IssueService) GetWorklogsWithContext(ctx context.Context, issueID strin
return v, resp, err
}
// Rank rank's given issue
func (s * IssueService) Rank(issueIDs []string, beforeIssue, afterIssue string, customFieldId int64) error {
apiEndpoint := "/rest/agile/1.0/issue/rank"
var reqBody interface{}
if len(beforeIssue) > 0 {
reqBody = &RankBeforeReqBody {
Issues: issueIDs,
RankBeforeIssue: beforeIssue,
RankCustomFieldId: customFieldId,
}
} else {
reqBody = &RankAfterReqBody {
Issues: issueIDs,
RankAfterIssue: beforeIssue,
RankCustomFieldId: customFieldId,
}
}
req, err := s.client.NewRequestWithContext(context.Background(), "PUT", apiEndpoint, reqBody)
if err != nil {
return err
}
_, err = s.client.Do(req, nil)
if err != nil {
return err
}
return nil
}
// GetWorklogs wraps GetWorklogsWithContext using the background context.
func (s *IssueService) GetWorklogs(issueID string, options ...func(*http.Request) error) (*Worklog, *Response, error) {
return s.GetWorklogsWithContext(context.Background(), issueID, options...)