Move issue creation calls into the jira client
This commit is contained in:
parent
8a7c989f48
commit
194e25dc14
14 changed files with 280 additions and 180 deletions
31
crates/libjirac/src/client/commands/issue_create_command.rs
Normal file
31
crates/libjirac/src/client/commands/issue_create_command.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use crate::client::{JiraCommand, JiraRequestType};
|
||||
use crate::entities::issue_request::{IssueCreateRequest, IssueCreateResponse};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct IssueCreateCommand {
|
||||
issue: IssueCreateRequest,
|
||||
}
|
||||
|
||||
impl IssueCreateCommand {
|
||||
pub fn new(issue: IssueCreateRequest) -> Self {
|
||||
Self { issue }
|
||||
}
|
||||
}
|
||||
|
||||
impl JiraCommand for IssueCreateCommand {
|
||||
type TResponse = IssueCreateResponse;
|
||||
type TPayload = IssueCreateRequest;
|
||||
const REQUEST_TYPE: JiraRequestType = JiraRequestType::Create;
|
||||
|
||||
fn endpoint(&self) -> String {
|
||||
"/rest/api/2/issue".to_string()
|
||||
}
|
||||
|
||||
fn request_body(&self) -> Option<&Self::TPayload> {
|
||||
Some(&self.issue)
|
||||
}
|
||||
|
||||
fn query_params(&self) -> Option<Vec<(String, String)>> {
|
||||
None
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
use crate::client::{JiraCommand, JiraRequestType};
|
||||
use crate::entities::transitions::Transitions;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct IssueTransitionsCommand {
|
||||
issue_key: String,
|
||||
}
|
||||
|
||||
impl IssueTransitionsCommand {
|
||||
pub fn new(issue_key: &str) -> Self {
|
||||
Self {
|
||||
issue_key: issue_key.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl JiraCommand for IssueTransitionsCommand {
|
||||
type TResponse = Transitions;
|
||||
type TPayload = ();
|
||||
const REQUEST_TYPE: JiraRequestType = JiraRequestType::Read;
|
||||
|
||||
fn endpoint(&self) -> String {
|
||||
format!("/rest/api/3/issue/{}/transitions", self.issue_key)
|
||||
}
|
||||
|
||||
fn request_body(&self) -> Option<&Self::TPayload> {
|
||||
None
|
||||
}
|
||||
|
||||
fn query_params(&self) -> Option<Vec<(String, String)>> {
|
||||
None
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
use crate::client::{JiraCommand, JiraRequestType};
|
||||
use crate::entities::transitions::{IssueTransitionUpdatePayload, IssueTransitionUpdatePayloadId};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct IssueTransitionsUpdateCommand {
|
||||
pub issue_key: String,
|
||||
pub transition: IssueTransitionUpdatePayload,
|
||||
}
|
||||
|
||||
impl IssueTransitionsUpdateCommand {
|
||||
pub fn new(issue_key: &str, transition_id: &str) -> Self {
|
||||
Self {
|
||||
issue_key: issue_key.to_string(),
|
||||
transition: IssueTransitionUpdatePayload {
|
||||
transition: IssueTransitionUpdatePayloadId {
|
||||
id: transition_id.to_string(),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl JiraCommand for IssueTransitionsUpdateCommand {
|
||||
type TResponse = ();
|
||||
type TPayload = IssueTransitionUpdatePayload;
|
||||
const REQUEST_TYPE: JiraRequestType = JiraRequestType::Create;
|
||||
|
||||
fn endpoint(&self) -> String {
|
||||
format!("/rest/api/3/issue/{}/transitions", self.issue_key)
|
||||
}
|
||||
|
||||
fn request_body(&self) -> Option<&Self::TPayload> {
|
||||
Some(&self.transition)
|
||||
}
|
||||
|
||||
fn query_params(&self) -> Option<Vec<(String, String)>> {
|
||||
None
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue