use crate::client::Client;
#[allow(unused_imports)]
use crate::enums::*;
use crate::error::Error;
#[allow(unused_imports)]
use crate::models::*;
#[allow(unused_imports)]
use serde::Serialize;
pub struct CashbackRulesApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkCreateCashbackRuleRequestApplicationJson,
}
impl CreateParams {
#[allow(deprecated)]
pub fn new(body: SdkCreateCashbackRuleRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ReplaceParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkReplaceCashbackRuleRequestApplicationJson,
}
impl ReplaceParams {
#[allow(deprecated)]
pub fn new(body: SdkReplaceCashbackRuleRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkUpdateCashbackRuleRequestApplicationJson,
}
impl UpdateParams {
#[allow(deprecated)]
pub fn new(body: SdkUpdateCashbackRuleRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ArchiveParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct RestoreParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl<'a> CashbackRulesApi<'a> {
pub async fn list(
&self,
params: ListParams,
) -> Result<SdkListCashbackRulesResponseValue200ApplicationJson, Error> {
self.list_with_options(params, None).await
}
pub async fn list_with_options(
&self,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListCashbackRulesResponseValue200ApplicationJson, Error> {
self.list_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn list_raw(
&self,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkListCashbackRulesResponseValue200ApplicationJson>, Error>
{
let path = "/v2/cashback-rules".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listCashbackRules".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/cashback-rules",
)
.await
}
pub async fn create(
&self,
params: CreateParams,
) -> Result<SdkCreateCashbackRuleResponseValue201ApplicationJson, Error> {
self.create_with_options(params, None).await
}
pub async fn create_with_options(
&self,
params: CreateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCreateCashbackRuleResponseValue201ApplicationJson, Error> {
self.create_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn create_raw(
&self,
params: CreateParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkCreateCashbackRuleResponseValue201ApplicationJson>, Error>
{
let path = "/v2/cashback-rules".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("createCashbackRule".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/cashback-rules",
)
.await
}
pub async fn replace(
&self,
cashback_rule: &str,
params: ReplaceParams,
) -> Result<SdkReplaceCashbackRuleResponseValue200ApplicationJson, Error> {
self.replace_with_options(cashback_rule, params, None).await
}
pub async fn replace_with_options(
&self,
cashback_rule: &str,
params: ReplaceParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkReplaceCashbackRuleResponseValue200ApplicationJson, Error> {
self.replace_raw(cashback_rule, params, options)
.await
.map(|response| response.data)
}
pub async fn replace_raw(
&self,
cashback_rule: &str,
params: ReplaceParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkReplaceCashbackRuleResponseValue200ApplicationJson>, Error>
{
let cashback_rule = crate::client::path_segment(cashback_rule);
let path = format!("/v2/cashback-rules/{cashback_rule}");
let method = http::Method::PUT;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("replaceCashbackRule".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PUT /v2/cashback-rules/{cashbackRule}",
)
.await
}
pub async fn update(
&self,
cashback_rule: &str,
params: UpdateParams,
) -> Result<SdkUpdateCashbackRuleResponseValue200ApplicationJson, Error> {
self.update_with_options(cashback_rule, params, None).await
}
pub async fn update_with_options(
&self,
cashback_rule: &str,
params: UpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkUpdateCashbackRuleResponseValue200ApplicationJson, Error> {
self.update_raw(cashback_rule, params, options)
.await
.map(|response| response.data)
}
pub async fn update_raw(
&self,
cashback_rule: &str,
params: UpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkUpdateCashbackRuleResponseValue200ApplicationJson>, Error>
{
let cashback_rule = crate::client::path_segment(cashback_rule);
let path = format!("/v2/cashback-rules/{cashback_rule}");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("updateCashbackRule".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/cashback-rules/{cashbackRule}",
)
.await
}
pub async fn archive(
&self,
cashback_rule: &str,
params: ArchiveParams,
) -> Result<SdkArchiveCashbackRuleResponseValue200ApplicationJson, Error> {
self.archive_with_options(cashback_rule, params, None).await
}
pub async fn archive_with_options(
&self,
cashback_rule: &str,
params: ArchiveParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkArchiveCashbackRuleResponseValue200ApplicationJson, Error> {
self.archive_raw(cashback_rule, params, options)
.await
.map(|response| response.data)
}
pub async fn archive_raw(
&self,
cashback_rule: &str,
params: ArchiveParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkArchiveCashbackRuleResponseValue200ApplicationJson>, Error>
{
let cashback_rule = crate::client::path_segment(cashback_rule);
let path = format!("/v2/cashback-rules/{cashback_rule}");
let method = http::Method::DELETE;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("archiveCashbackRule".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"DELETE /v2/cashback-rules/{cashbackRule}",
)
.await
}
pub async fn restore(
&self,
cashback_rule: &str,
params: RestoreParams,
) -> Result<SdkRestoreCashbackRuleResponseValue200ApplicationJson, Error> {
self.restore_with_options(cashback_rule, params, None).await
}
pub async fn restore_with_options(
&self,
cashback_rule: &str,
params: RestoreParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkRestoreCashbackRuleResponseValue200ApplicationJson, Error> {
self.restore_raw(cashback_rule, params, options)
.await
.map(|response| response.data)
}
pub async fn restore_raw(
&self,
cashback_rule: &str,
params: RestoreParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkRestoreCashbackRuleResponseValue200ApplicationJson>, Error>
{
let cashback_rule = crate::client::path_segment(cashback_rule);
let path = format!("/v2/cashback-rules/{cashback_rule}/restore");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("restoreCashbackRule".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"POST /v2/cashback-rules/{cashbackRule}/restore",
)
.await
}
}