mirror of
				https://github.com/interviewstreet/go-jira.git
				synced 2025-10-30 23:47:46 +02:00 
			
		
		
		
	⚡ [ISSUE] Add: Rank API
This commit is contained in:
		
							
								
								
									
										47
									
								
								issue.go
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								issue.go
									
									
									
									
									
								
							| @@ -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...) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user