-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rickschubert
committed
Jun 18, 2020
1 parent
71c9aa7
commit 0c379d6
Showing
5 changed files
with
112 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package jira | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/rickschubert/jira-ticket/constants" | ||
"github.com/rickschubert/jira-ticket/utils" | ||
) | ||
|
||
type assignTicketPostBody struct { | ||
AccountId string `json:"accountId"` | ||
} | ||
|
||
func SelfAssignTicket(ticketInfo NewTicket) { | ||
settings := constants.GetSettings() | ||
postBody := assignTicketPostBody{ | ||
AccountId: settings.UserId, | ||
} | ||
|
||
inputJson, errMarshalling := json.MarshalIndent(postBody, "", " ") | ||
utils.HandleErrorStrictly(errMarshalling) | ||
|
||
resp, err := requestClient.R(). | ||
SetBasicAuth(settings.UserName, settings.ApiKey). | ||
SetHeader("Content-Type", "application/json"). | ||
SetHeader("Accept", "application/json"). | ||
SetBody(string(inputJson)). | ||
Put(fmt.Sprintf("%s/rest/api/3/issue/%s/assignee", settings.JiraBaseUrl, ticketInfo.Key)) | ||
utils.HandleErrorStrictly(err) | ||
|
||
if resp.StatusCode() != 204 { | ||
panic(fmt.Sprintf("We were expecting status code 204 but instead received %v when self-assigning the ticket. The response says:\n\n%v", resp.StatusCode(), resp)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters