use reqwest;
use super::{configuration, Error};
use crate::apis::ResponseContent;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddTaskForSectionError {
Status400(crate::models::ErrorResponse),
Status401(crate::models::ErrorResponse),
Status403(crate::models::ErrorResponse),
Status404(crate::models::ErrorResponse),
Status500(crate::models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateSectionForProjectError {
Status400(crate::models::ErrorResponse),
Status401(crate::models::ErrorResponse),
Status403(crate::models::ErrorResponse),
Status404(crate::models::ErrorResponse),
Status500(crate::models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteSectionError {
Status400(crate::models::ErrorResponse),
Status401(crate::models::ErrorResponse),
Status403(crate::models::ErrorResponse),
Status404(crate::models::ErrorResponse),
Status500(crate::models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSectionError {
Status400(crate::models::ErrorResponse),
Status401(crate::models::ErrorResponse),
Status403(crate::models::ErrorResponse),
Status404(crate::models::ErrorResponse),
Status500(crate::models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSectionsForProjectError {
Status400(crate::models::ErrorResponse),
Status401(crate::models::ErrorResponse),
Status403(crate::models::ErrorResponse),
Status404(crate::models::ErrorResponse),
Status500(crate::models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsertSectionForProjectError {
Status400(crate::models::ErrorResponse),
Status401(crate::models::ErrorResponse),
Status403(crate::models::ErrorResponse),
Status404(crate::models::ErrorResponse),
Status500(crate::models::ErrorResponse),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateSectionError {
Status400(crate::models::ErrorResponse),
Status401(crate::models::ErrorResponse),
Status403(crate::models::ErrorResponse),
Status404(crate::models::ErrorResponse),
Status500(crate::models::ErrorResponse),
UnknownValue(serde_json::Value),
}
pub async fn add_task_for_section(
configuration: &configuration::Configuration,
section_gid: &str,
inline_object29: crate::models::InlineObject29,
opt_pretty: Option<bool>,
opt_fields: Option<Vec<String>>,
) -> Result<crate::models::InlineResponse2001, Error<AddTaskForSectionError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/sections/{section_gid}/addTask",
configuration.base_path,
section_gid = crate::apis::urlencode(section_gid)
);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref local_var_str) = opt_pretty {
local_var_req_builder =
local_var_req_builder.query(&[("opt_pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = opt_fields {
local_var_req_builder = local_var_req_builder.query(&[(
"opt_fields",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&inline_object29);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AddTaskForSectionError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
pub async fn create_section_for_project(
configuration: &configuration::Configuration,
project_gid: &str,
inline_object28: crate::models::InlineObject28,
opt_pretty: Option<bool>,
opt_fields: Option<Vec<String>>,
) -> Result<crate::models::InlineResponse20018, Error<CreateSectionForProjectError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/projects/{project_gid}/sections",
configuration.base_path,
project_gid = crate::apis::urlencode(project_gid)
);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref local_var_str) = opt_pretty {
local_var_req_builder =
local_var_req_builder.query(&[("opt_pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = opt_fields {
local_var_req_builder = local_var_req_builder.query(&[(
"opt_fields",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&inline_object28);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CreateSectionForProjectError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
pub async fn delete_section(
configuration: &configuration::Configuration,
section_gid: &str,
opt_pretty: Option<bool>,
opt_fields: Option<Vec<String>>,
) -> Result<crate::models::InlineResponse2001, Error<DeleteSectionError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/sections/{section_gid}",
configuration.base_path,
section_gid = crate::apis::urlencode(section_gid)
);
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref local_var_str) = opt_pretty {
local_var_req_builder =
local_var_req_builder.query(&[("opt_pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = opt_fields {
local_var_req_builder = local_var_req_builder.query(&[(
"opt_fields",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DeleteSectionError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
pub async fn get_section(
configuration: &configuration::Configuration,
section_gid: &str,
opt_pretty: Option<bool>,
opt_fields: Option<Vec<String>>,
) -> Result<crate::models::InlineResponse20018, Error<GetSectionError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/sections/{section_gid}",
configuration.base_path,
section_gid = crate::apis::urlencode(section_gid)
);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = opt_pretty {
local_var_req_builder =
local_var_req_builder.query(&[("opt_pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = opt_fields {
local_var_req_builder = local_var_req_builder.query(&[(
"opt_fields",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetSectionError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
pub async fn get_sections_for_project(
configuration: &configuration::Configuration,
project_gid: &str,
opt_pretty: Option<bool>,
opt_fields: Option<Vec<String>>,
limit: Option<i32>,
offset: Option<&str>,
) -> Result<crate::models::InlineResponse20019, Error<GetSectionsForProjectError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/projects/{project_gid}/sections",
configuration.base_path,
project_gid = crate::apis::urlencode(project_gid)
);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = opt_pretty {
local_var_req_builder =
local_var_req_builder.query(&[("opt_pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = opt_fields {
local_var_req_builder = local_var_req_builder.query(&[(
"opt_fields",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]);
}
if let Some(ref local_var_str) = limit {
local_var_req_builder =
local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = offset {
local_var_req_builder =
local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetSectionsForProjectError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
pub async fn insert_section_for_project(
configuration: &configuration::Configuration,
project_gid: &str,
inline_object30: crate::models::InlineObject30,
opt_pretty: Option<bool>,
opt_fields: Option<Vec<String>>,
) -> Result<crate::models::InlineResponse2001, Error<InsertSectionForProjectError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/projects/{project_gid}/sections/insert",
configuration.base_path,
project_gid = crate::apis::urlencode(project_gid)
);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref local_var_str) = opt_pretty {
local_var_req_builder =
local_var_req_builder.query(&[("opt_pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = opt_fields {
local_var_req_builder = local_var_req_builder.query(&[(
"opt_fields",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&inline_object30);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsertSectionForProjectError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
pub async fn update_section(
configuration: &configuration::Configuration,
section_gid: &str,
inline_object27: crate::models::InlineObject27,
opt_pretty: Option<bool>,
opt_fields: Option<Vec<String>>,
) -> Result<crate::models::InlineResponse20018, Error<UpdateSectionError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/sections/{section_gid}",
configuration.base_path,
section_gid = crate::apis::urlencode(section_gid)
);
let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
if let Some(ref local_var_str) = opt_pretty {
local_var_req_builder =
local_var_req_builder.query(&[("opt_pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = opt_fields {
local_var_req_builder = local_var_req_builder.query(&[(
"opt_fields",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&inline_object27);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<UpdateSectionError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}