Actually create the ticket when confirming creation
This commit is contained in:
parent
219f116891
commit
f0aaf0a7e7
1 changed files with 27 additions and 27 deletions
|
@ -211,13 +211,13 @@ fn create_temp_markdown(project_key: Option<String>) -> Result<String, Box<dyn s
|
|||
Ok(content)
|
||||
}
|
||||
async fn create_jira_issue(
|
||||
_config: &JiraConfig,
|
||||
config: &JiraConfig,
|
||||
project_key: &str,
|
||||
title: &str,
|
||||
description: &str,
|
||||
metadata: &TicketMetadata,
|
||||
) -> Result<JiraResponse, Box<dyn std::error::Error>> {
|
||||
let _client = reqwest::Client::new();
|
||||
let client = reqwest::Client::new();
|
||||
|
||||
let mut headers = HeaderMap::new();
|
||||
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
|
||||
|
@ -257,32 +257,32 @@ async fn create_jira_issue(
|
|||
|
||||
let issue = JiraIssueRequest { fields, update };
|
||||
|
||||
println!("{:#?}", issue);
|
||||
Ok(JiraResponse {
|
||||
key: format!("{}-1234", project_key),
|
||||
})
|
||||
// println!("{:#?}", issue);
|
||||
// Ok(JiraResponse {
|
||||
// key: format!("{}-1234", project_key),
|
||||
// })
|
||||
|
||||
// let response = client
|
||||
// .post(format!("{}/rest/api/2/issue", config.url))
|
||||
// .basic_auth(&config.email, Some(&config.api_token))
|
||||
// .headers(headers)
|
||||
// .json(&issue)
|
||||
// .send()
|
||||
// .await?;
|
||||
//
|
||||
// if !response.status().is_success() {
|
||||
// let error_text = response.text().await?;
|
||||
// return Err(format!("Failed to create issue: {}", error_text).into());
|
||||
// }
|
||||
//
|
||||
// let issue_response = response.json::<JiraResponse>().await?;
|
||||
//
|
||||
// // Update status if specified (requires a separate API call)
|
||||
// if let Some(status) = &metadata.status {
|
||||
// update_issue_status(config, &issue_response.key, status).await?;
|
||||
// }
|
||||
//
|
||||
// Ok(issue_response)
|
||||
let response = client
|
||||
.post(format!("{}/rest/api/2/issue", config.url))
|
||||
.basic_auth(&config.email, Some(&config.api_token))
|
||||
.headers(headers)
|
||||
.json(&issue)
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
let error_text = response.text().await?;
|
||||
return Err(format!("Failed to create issue: {}", error_text).into());
|
||||
}
|
||||
|
||||
let issue_response = response.json::<JiraResponse>().await?;
|
||||
|
||||
// Update status if specified (requires a separate API call)
|
||||
if let Some(status) = &metadata.status {
|
||||
update_issue_status(config, &issue_response.key, status).await?;
|
||||
}
|
||||
|
||||
Ok(issue_response)
|
||||
}
|
||||
|
||||
async fn update_issue_status(
|
||||
|
|
Loading…
Reference in a new issue