use reqwest;
use super::ResponseContent;
use super::{Error, configuration};
#[derive(Clone, Debug, Default)]
pub struct ConfirmCustomerPaymentParams {
pub stripe_setup_intent_id: Option<String>,
}
#[derive(Clone, Debug, Default)]
pub struct GetInvoiceForSubscriptionAsPdfParams {
pub invoice_id: String,
}
#[derive(Clone, Debug, Default)]
pub struct UpdateCloudCustomerParams {
pub update_cloud_customer_request: crate::openapi::models::UpdateCloudCustomerRequest,
}
#[derive(Clone, Debug, Default)]
pub struct UpdateCloudCustomerAddressParams {
pub address: crate::openapi::models::Address,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum ConfirmCustomerPaymentError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum CreateCustomerPaymentError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetCloudCustomerError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetCloudLimitsError {
Status401(crate::openapi::models::AppError),
Status500(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetCloudProductsError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetInvoiceForSubscriptionAsPdfError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetInvoicesForSubscriptionError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetSubscriptionError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum PostEndpointForCwsWebhooksError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum UpdateCloudCustomerError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum UpdateCloudCustomerAddressError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
pub async fn confirm_customer_payment(
configuration: &configuration::Configuration,
params: ConfirmCustomerPaymentParams,
) -> Result<(), Error<ConfirmCustomerPaymentError>> {
let local_var_configuration = configuration;
let stripe_setup_intent_id = params.stripe_setup_intent_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/cloud/payment/confirm",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let mut local_var_form = reqwest::multipart::Form::new();
if let Some(local_var_param_value) = stripe_setup_intent_id {
local_var_form =
local_var_form.text("stripe_setup_intent_id", local_var_param_value.to_string());
}
local_var_req_builder = local_var_req_builder.multipart(local_var_form);
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<ConfirmCustomerPaymentError> =
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_customer_payment(
configuration: &configuration::Configuration,
) -> Result<crate::openapi::models::PaymentSetupIntent, Error<CreateCustomerPaymentError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/cloud/payment", 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_token) = local_var_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<CreateCustomerPaymentError> =
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_cloud_customer(
configuration: &configuration::Configuration,
) -> Result<crate::openapi::models::CloudCustomer, Error<GetCloudCustomerError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/cloud/customer",
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_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_token) = local_var_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<GetCloudCustomerError> =
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_cloud_limits(
configuration: &configuration::Configuration,
) -> Result<crate::openapi::models::ProductLimits, Error<GetCloudLimitsError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/cloud/limits", 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_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_token) = local_var_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<GetCloudLimitsError> =
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_cloud_products(
configuration: &configuration::Configuration,
) -> Result<Vec<crate::openapi::models::Product>, Error<GetCloudProductsError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/cloud/products",
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_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_token) = local_var_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<GetCloudProductsError> =
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_invoice_for_subscription_as_pdf(
configuration: &configuration::Configuration,
params: GetInvoiceForSubscriptionAsPdfParams,
) -> Result<(), Error<GetInvoiceForSubscriptionAsPdfError>> {
let local_var_configuration = configuration;
let invoice_id = params.invoice_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/cloud/subscription/invoices/{invoice_id}/pdf",
local_var_configuration.base_path,
invoice_id = super::urlencode(invoice_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_token) = local_var_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() {
Ok(())
} else {
let local_var_entity: Option<GetInvoiceForSubscriptionAsPdfError> =
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_invoices_for_subscription(
configuration: &configuration::Configuration,
) -> Result<Vec<crate::openapi::models::Invoice>, Error<GetInvoicesForSubscriptionError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/cloud/subscription/invoices",
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_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_token) = local_var_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<GetInvoicesForSubscriptionError> =
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_subscription(
configuration: &configuration::Configuration,
) -> Result<crate::openapi::models::Subscription, Error<GetSubscriptionError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/cloud/subscription",
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_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_token) = local_var_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<GetSubscriptionError> =
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 post_endpoint_for_cws_webhooks(
configuration: &configuration::Configuration,
) -> Result<(), Error<PostEndpointForCwsWebhooksError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/cloud/webhook", 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_token) = local_var_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() {
Ok(())
} else {
let local_var_entity: Option<PostEndpointForCwsWebhooksError> =
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_cloud_customer(
configuration: &configuration::Configuration,
params: UpdateCloudCustomerParams,
) -> Result<crate::openapi::models::CloudCustomer, Error<UpdateCloudCustomerError>> {
let local_var_configuration = configuration;
let update_cloud_customer_request = params.update_cloud_customer_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/cloud/customer",
local_var_configuration.base_path
);
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_token) = local_var_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(&update_cloud_customer_request);
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<UpdateCloudCustomerError> =
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_cloud_customer_address(
configuration: &configuration::Configuration,
params: UpdateCloudCustomerAddressParams,
) -> Result<crate::openapi::models::CloudCustomer, Error<UpdateCloudCustomerAddressError>> {
let local_var_configuration = configuration;
let address = params.address;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/cloud/customer/address",
local_var_configuration.base_path
);
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_token) = local_var_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(&address);
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<UpdateCloudCustomerAddressError> =
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))
}
}