use reqwest;
use super::{configuration, Error};
use crate::apis::ResponseContent;
#[derive(Clone, Debug)]
pub struct QuestionsAddConsiderationVoteCreateParams {
pub id: i32,
}
#[derive(Clone, Debug)]
pub struct QuestionsBoostCreateParams {
pub id: i32,
pub boost: crate::models::Boost,
}
#[derive(Clone, Debug)]
pub struct QuestionsBulkPredictCreateParams {
pub bulk_prediction_input: crate::models::BulkPredictionInput,
}
#[derive(Clone, Debug)]
pub struct QuestionsCreateParams {
pub question_update: Option<crate::models::QuestionUpdate>,
}
#[derive(Clone, Debug)]
pub struct QuestionsDestroyParams {
pub id: i32,
}
#[derive(Clone, Debug)]
pub struct QuestionsListParams {
pub access: Option<String>,
pub author: Option<i32>,
pub categories: Option<String>,
pub close_time__gt: Option<String>,
pub close_time__lt: Option<String>,
pub commented_by: Option<f32>,
pub contest: Option<String>,
pub forecast_type: Option<String>,
pub group: Option<i32>,
pub guessed_by: Option<f32>,
pub has_group: Option<bool>,
pub include_description: Option<String>,
pub limit: Option<i32>,
pub not_guessed_by: Option<f32>,
pub offset: Option<i32>,
pub order_by: Option<String>,
pub project: Option<String>,
pub publish_time__gt: Option<String>,
pub publish_time__lt: Option<String>,
pub resolve_time__gt: Option<String>,
pub resolve_time__lt: Option<String>,
pub reversed_related: Option<f32>,
pub search: Option<String>,
pub status: Option<String>,
pub r#type: Option<String>,
pub unconditional: Option<bool>,
pub upvoted_by: Option<f32>,
pub username: Option<String>,
pub visible_from_project: Option<String>,
}
#[derive(Clone, Debug)]
pub struct QuestionsPartialUpdateParams {
pub id: i32,
pub patched_question_update: Option<crate::models::PatchedQuestionUpdate>,
}
#[derive(Clone, Debug)]
pub struct QuestionsPredictCreateParams {
pub id: i32,
pub prediction_input: crate::models::PredictionInput,
}
#[derive(Clone, Debug)]
pub struct QuestionsPredictionForDateRetrieveParams {
pub id: i32,
}
#[derive(Clone, Debug)]
pub struct QuestionsPredictionHistoryRetrieveParams {
pub id: i32,
}
#[derive(Clone, Debug)]
pub struct QuestionsPredictionsRetrieveParams {
pub id: i32,
}
#[derive(Clone, Debug)]
pub struct QuestionsQuestionSharingCreateParams {
pub id: i32,
pub username: String,
pub share_question: crate::models::ShareQuestion,
}
#[derive(Clone, Debug)]
pub struct QuestionsQuestionSharingDestroyParams {
pub id: i32,
pub username: String,
}
#[derive(Clone, Debug)]
pub struct QuestionsRemoveConsiderationVoteCreateParams {
pub id: i32,
}
#[derive(Clone, Debug)]
pub struct QuestionsResolveCreateParams {
pub id: i32,
pub question_resolve: crate::models::QuestionResolve,
}
#[derive(Clone, Debug)]
pub struct QuestionsRetrieveParams {
pub id: i32,
}
#[derive(Clone, Debug)]
pub struct QuestionsShowCommunityCreateParams {
pub id: i32,
pub show_community: crate::models::ShowCommunity,
}
#[derive(Clone, Debug)]
pub struct QuestionsUpdateParams {
pub id: i32,
pub question_update: Option<crate::models::QuestionUpdate>,
}
#[derive(Clone, Debug)]
pub struct QuestionsVoteCreateParams {
pub id: i32,
pub question_vote: crate::models::QuestionVote,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsAddConsiderationVoteCreateError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsBoostCreateError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsBulkPredictCreateError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsCreateError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsDestroyError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsListError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsPartialUpdateError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsPredictCreateError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsPredictionForDateRetrieveError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsPredictionHistoryRetrieveError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsPredictionsRetrieveError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsQuestionSharingCreateError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsQuestionSharingDestroyError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsRemoveConsiderationVoteCreateError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsResolveCreateError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsRetrieveError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsShowCommunityCreateError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsUpdateError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QuestionsVoteCreateError {
UnknownValue(serde_json::Value),
}
pub async fn questions_add_consideration_vote_create(
configuration: &configuration::Configuration,
params: QuestionsAddConsiderationVoteCreateParams,
) -> Result<(), Error<QuestionsAddConsiderationVoteCreateError>> {
let local_var_configuration = configuration;
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/add_consideration_vote/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
Ok(())
} else {
let local_var_entity: Option<QuestionsAddConsiderationVoteCreateError> =
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 questions_boost_create(
configuration: &configuration::Configuration,
params: QuestionsBoostCreateParams,
) -> Result<crate::models::Boost, Error<QuestionsBoostCreateError>> {
let local_var_configuration = configuration;
let id = params.id;
let boost = params.boost;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/boost/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&boost);
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<QuestionsBoostCreateError> =
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 questions_bulk_predict_create(
configuration: &configuration::Configuration,
params: QuestionsBulkPredictCreateParams,
) -> Result<crate::models::BulkPredictionInput, Error<QuestionsBulkPredictCreateError>> {
let local_var_configuration = configuration;
let bulk_prediction_input = params.bulk_prediction_input;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/bulk-predict/",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&bulk_prediction_input);
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<QuestionsBulkPredictCreateError> =
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 questions_create(
configuration: &configuration::Configuration,
params: QuestionsCreateParams,
) -> Result<crate::models::QuestionUpdate, Error<QuestionsCreateError>> {
let local_var_configuration = configuration;
let question_update = params.question_update;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api2/questions/", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&question_update);
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<QuestionsCreateError> =
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 questions_destroy(
configuration: &configuration::Configuration,
params: QuestionsDestroyParams,
) -> Result<(), Error<QuestionsDestroyError>> {
let local_var_configuration = configuration;
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
Ok(())
} else {
let local_var_entity: Option<QuestionsDestroyError> =
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 questions_list(
configuration: &configuration::Configuration,
params: QuestionsListParams,
) -> Result<crate::models::PaginatedQuestionUserList, Error<QuestionsListError>> {
let local_var_configuration = configuration;
let access = params.access;
let author = params.author;
let categories = params.categories;
let close_time__gt = params.close_time__gt;
let close_time__lt = params.close_time__lt;
let commented_by = params.commented_by;
let contest = params.contest;
let forecast_type = params.forecast_type;
let group = params.group;
let guessed_by = params.guessed_by;
let has_group = params.has_group;
let include_description = params.include_description;
let limit = params.limit;
let not_guessed_by = params.not_guessed_by;
let offset = params.offset;
let order_by = params.order_by;
let project = params.project;
let publish_time__gt = params.publish_time__gt;
let publish_time__lt = params.publish_time__lt;
let resolve_time__gt = params.resolve_time__gt;
let resolve_time__lt = params.resolve_time__lt;
let reversed_related = params.reversed_related;
let search = params.search;
let status = params.status;
let r#type = params.r#type;
let unconditional = params.unconditional;
let upvoted_by = params.upvoted_by;
let username = params.username;
let visible_from_project = params.visible_from_project;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api2/questions/", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = access {
local_var_req_builder =
local_var_req_builder.query(&[("access", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = author {
local_var_req_builder =
local_var_req_builder.query(&[("author", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = categories {
local_var_req_builder =
local_var_req_builder.query(&[("categories", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = close_time__gt {
local_var_req_builder =
local_var_req_builder.query(&[("close_time__gt", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = close_time__lt {
local_var_req_builder =
local_var_req_builder.query(&[("close_time__lt", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = commented_by {
local_var_req_builder =
local_var_req_builder.query(&[("commented_by", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = contest {
local_var_req_builder =
local_var_req_builder.query(&[("contest", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = forecast_type {
local_var_req_builder =
local_var_req_builder.query(&[("forecast_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = group {
local_var_req_builder =
local_var_req_builder.query(&[("group", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = guessed_by {
local_var_req_builder =
local_var_req_builder.query(&[("guessed_by", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = has_group {
local_var_req_builder =
local_var_req_builder.query(&[("has_group", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = include_description {
local_var_req_builder =
local_var_req_builder.query(&[("include_description", &local_var_str.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) = not_guessed_by {
local_var_req_builder =
local_var_req_builder.query(&[("not_guessed_by", &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_str) = order_by {
local_var_req_builder =
local_var_req_builder.query(&[("order_by", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = project {
local_var_req_builder =
local_var_req_builder.query(&[("project", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = publish_time__gt {
local_var_req_builder =
local_var_req_builder.query(&[("publish_time__gt", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = publish_time__lt {
local_var_req_builder =
local_var_req_builder.query(&[("publish_time__lt", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = resolve_time__gt {
local_var_req_builder =
local_var_req_builder.query(&[("resolve_time__gt", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = resolve_time__lt {
local_var_req_builder =
local_var_req_builder.query(&[("resolve_time__lt", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = reversed_related {
local_var_req_builder =
local_var_req_builder.query(&[("reversed_related", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search {
local_var_req_builder =
local_var_req_builder.query(&[("search", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = status {
local_var_req_builder =
local_var_req_builder.query(&[("status", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = r#type {
local_var_req_builder =
local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = unconditional {
local_var_req_builder =
local_var_req_builder.query(&[("unconditional", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = upvoted_by {
local_var_req_builder =
local_var_req_builder.query(&[("upvoted_by", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = username {
local_var_req_builder =
local_var_req_builder.query(&[("username", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = visible_from_project {
local_var_req_builder =
local_var_req_builder.query(&[("visible_from_project", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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<QuestionsListError> =
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 questions_partial_update(
configuration: &configuration::Configuration,
params: QuestionsPartialUpdateParams,
) -> Result<crate::models::QuestionUpdate, Error<QuestionsPartialUpdateError>> {
let local_var_configuration = configuration;
let id = params.id;
let patched_question_update = params.patched_question_update;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&patched_question_update);
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<QuestionsPartialUpdateError> =
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 questions_predict_create(
configuration: &configuration::Configuration,
params: QuestionsPredictCreateParams,
) -> Result<crate::models::PredictionInput, Error<QuestionsPredictCreateError>> {
let local_var_configuration = configuration;
let id = params.id;
let prediction_input = params.prediction_input;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/predict/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&prediction_input);
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<QuestionsPredictCreateError> =
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 questions_prediction_for_date_retrieve(
configuration: &configuration::Configuration,
params: QuestionsPredictionForDateRetrieveParams,
) -> Result<crate::models::PredictionForDate, Error<QuestionsPredictionForDateRetrieveError>> {
let local_var_configuration = configuration;
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/prediction-for-date/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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<QuestionsPredictionForDateRetrieveError> =
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 questions_prediction_history_retrieve(
configuration: &configuration::Configuration,
params: QuestionsPredictionHistoryRetrieveParams,
) -> Result<crate::models::PredictionHistory, Error<QuestionsPredictionHistoryRetrieveError>> {
let local_var_configuration = configuration;
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/prediction-history/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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<QuestionsPredictionHistoryRetrieveError> =
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 questions_predictions_retrieve(
configuration: &configuration::Configuration,
params: QuestionsPredictionsRetrieveParams,
) -> Result<Vec<crate::models::ExtendedPredictionUsername>, Error<QuestionsPredictionsRetrieveError>>
{
let local_var_configuration = configuration;
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/predictions/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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<QuestionsPredictionsRetrieveError> =
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 questions_question_sharing_create(
configuration: &configuration::Configuration,
params: QuestionsQuestionSharingCreateParams,
) -> Result<crate::models::ShareQuestion, Error<QuestionsQuestionSharingCreateError>> {
let local_var_configuration = configuration;
let id = params.id;
let username = params.username;
let share_question = params.share_question;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/question-sharing/{username}/",
local_var_configuration.base_path,
id = id,
username = crate::apis::urlencode(username)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&share_question);
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<QuestionsQuestionSharingCreateError> =
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 questions_question_sharing_destroy(
configuration: &configuration::Configuration,
params: QuestionsQuestionSharingDestroyParams,
) -> Result<(), Error<QuestionsQuestionSharingDestroyError>> {
let local_var_configuration = configuration;
let id = params.id;
let username = params.username;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/question-sharing/{username}/",
local_var_configuration.base_path,
id = id,
username = crate::apis::urlencode(username)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
Ok(())
} else {
let local_var_entity: Option<QuestionsQuestionSharingDestroyError> =
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 questions_remove_consideration_vote_create(
configuration: &configuration::Configuration,
params: QuestionsRemoveConsiderationVoteCreateParams,
) -> Result<(), Error<QuestionsRemoveConsiderationVoteCreateError>> {
let local_var_configuration = configuration;
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/remove_consideration_vote/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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() {
Ok(())
} else {
let local_var_entity: Option<QuestionsRemoveConsiderationVoteCreateError> =
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 questions_resolve_create(
configuration: &configuration::Configuration,
params: QuestionsResolveCreateParams,
) -> Result<crate::models::QuestionResolve, Error<QuestionsResolveCreateError>> {
let local_var_configuration = configuration;
let id = params.id;
let question_resolve = params.question_resolve;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/resolve/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&question_resolve);
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<QuestionsResolveCreateError> =
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 questions_retrieve(
configuration: &configuration::Configuration,
params: QuestionsRetrieveParams,
) -> Result<crate::models::QuestionUserDetail, Error<QuestionsRetrieveError>> {
let local_var_configuration = configuration;
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
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<QuestionsRetrieveError> =
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 questions_show_community_create(
configuration: &configuration::Configuration,
params: QuestionsShowCommunityCreateParams,
) -> Result<crate::models::ShowCommunity, Error<QuestionsShowCommunityCreateError>> {
let local_var_configuration = configuration;
let id = params.id;
let show_community = params.show_community;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/show-community/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&show_community);
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<QuestionsShowCommunityCreateError> =
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 questions_update(
configuration: &configuration::Configuration,
params: QuestionsUpdateParams,
) -> Result<crate::models::QuestionUpdate, Error<QuestionsUpdateError>> {
let local_var_configuration = configuration;
let id = params.id;
let question_update = params.question_update;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&question_update);
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<QuestionsUpdateError> =
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 questions_vote_create(
configuration: &configuration::Configuration,
params: QuestionsVoteCreateParams,
) -> Result<crate::models::QuestionVote, Error<QuestionsVoteCreateError>> {
let local_var_configuration = configuration;
let id = params.id;
let question_vote = params.question_vote;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api2/questions/{id}/vote/",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_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_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder
.basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
};
if let Some(ref local_var_cookie) = local_var_configuration.cookie {
local_var_req_builder =
local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
};
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&question_vote);
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<QuestionsVoteCreateError> =
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))
}
}