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 CouponsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct ListParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub page: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
}
impl Default for ListParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
limit: Some(15),
page: Some(1),
with_trashed: Some(false),
only_trashed: Some(false),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateParams {
#[serde(skip)]
pub body: SdkCreateCouponRequestApplicationJson,
}
impl CreateParams {
#[allow(deprecated)]
pub fn new(body: SdkCreateCouponRequestApplicationJson) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct GetParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
}
impl Default for GetParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ReplaceParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip)]
pub body: SdkReplaceCouponRequestApplicationJson,
}
impl ReplaceParams {
#[allow(deprecated)]
pub fn new(body: SdkReplaceCouponRequestApplicationJson) -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip)]
pub body: SdkUpdateCouponRequestApplicationJson,
}
impl UpdateParams {
#[allow(deprecated)]
pub fn new(body: SdkUpdateCouponRequestApplicationJson) -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct DeleteParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
}
impl Default for DeleteParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct SearchParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip)]
pub body: SdkSearchCouponsRequestApplicationJson,
}
impl SearchParams {
#[allow(deprecated)]
pub fn new(body: SdkSearchCouponsRequestApplicationJson) -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct BatchCreateParams {
#[serde(skip)]
pub body: SdkBatchCreateCouponsRequestApplicationJson,
}
impl BatchCreateParams {
#[allow(deprecated)]
pub fn new(body: SdkBatchCreateCouponsRequestApplicationJson) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct BatchUpdateParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip)]
pub body: SdkBatchUpdateCouponsRequestApplicationJson,
}
impl BatchUpdateParams {
#[allow(deprecated)]
pub fn new(body: SdkBatchUpdateCouponsRequestApplicationJson) -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct BatchDeleteParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip)]
pub body: SdkBatchDeleteCouponsRequestApplicationJson,
}
impl BatchDeleteParams {
#[allow(deprecated)]
pub fn new(body: SdkBatchDeleteCouponsRequestApplicationJson) -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct V2ListCouponsParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub page: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl Default for V2ListCouponsParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
limit: Some(15),
page: Some(1),
with_trashed: Some(false),
only_trashed: Some(false),
x_store: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct V2CreateCouponParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkV2CreateCouponRequestApplicationJson,
}
impl V2CreateCouponParams {
#[allow(deprecated)]
pub fn new(body: SdkV2CreateCouponRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct V2SearchCouponsParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkV2SearchCouponsRequestApplicationJson,
}
impl V2SearchCouponsParams {
#[allow(deprecated)]
pub fn new(body: SdkV2SearchCouponsRequestApplicationJson) -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct V2GetCouponParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl Default for V2GetCouponParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
x_store: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct V2ReplaceCouponParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkV2ReplaceCouponRequestApplicationJson,
}
impl V2ReplaceCouponParams {
#[allow(deprecated)]
pub fn new(body: SdkV2ReplaceCouponRequestApplicationJson) -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct V2UpdateCouponParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkV2UpdateCouponRequestApplicationJson,
}
impl V2UpdateCouponParams {
#[allow(deprecated)]
pub fn new(body: SdkV2UpdateCouponRequestApplicationJson) -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct V2DeleteCouponParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl Default for V2DeleteCouponParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
x_store: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct V2BatchCreateCouponsParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkV2BatchCreateCouponsRequestApplicationJson,
}
impl V2BatchCreateCouponsParams {
#[allow(deprecated)]
pub fn new(body: SdkV2BatchCreateCouponsRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct V2BatchUpdateCouponsParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkV2BatchUpdateCouponsRequestApplicationJson,
}
impl V2BatchUpdateCouponsParams {
#[allow(deprecated)]
pub fn new(body: SdkV2BatchUpdateCouponsRequestApplicationJson) -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct V2BatchDeleteCouponsParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub with_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_trashed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkV2BatchDeleteCouponsRequestApplicationJson,
}
impl V2BatchDeleteCouponsParams {
#[allow(deprecated)]
pub fn new(body: SdkV2BatchDeleteCouponsRequestApplicationJson) -> Self {
Self {
with_trashed: Some(false),
only_trashed: Some(false),
x_store: Default::default(),
body,
}
}
}
impl<'a> CouponsApi<'a> {
pub async fn list(
&self,
params: ListParams,
) -> Result<SdkListCouponsResponseValue200ApplicationJson, Error> {
self.list_with_options(params, None).await
}
pub async fn list_with_options(
&self,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListCouponsResponseValue200ApplicationJson, 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<SdkListCouponsResponseValue200ApplicationJson>, Error> {
let path = "/v1/coupons".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listCoupons".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(method, &path, ¶ms, options, "GET /v1/coupons")
.await
}
pub async fn create(
&self,
params: CreateParams,
) -> Result<SdkCreateCouponResponseValue201ApplicationJson, Error> {
self.create_with_options(params, None).await
}
pub async fn create_with_options(
&self,
params: CreateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCreateCouponResponseValue201ApplicationJson, 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<SdkCreateCouponResponseValue201ApplicationJson>, Error> {
let path = "/v1/coupons".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("createCoupon".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v1/coupons",
)
.await
}
pub async fn get(
&self,
coupon: &str,
params: GetParams,
) -> Result<SdkGetCouponResponseValue200ApplicationJson, Error> {
self.get_with_options(coupon, params, None).await
}
pub async fn get_with_options(
&self,
coupon: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetCouponResponseValue200ApplicationJson, Error> {
self.get_raw(coupon, params, options)
.await
.map(|response| response.data)
}
pub async fn get_raw(
&self,
coupon: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetCouponResponseValue200ApplicationJson>, Error> {
let coupon = crate::client::path_segment(coupon);
let path = format!("/v1/coupons/{coupon}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getCoupon".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v1/coupons/{coupon}",
)
.await
}
pub async fn replace(
&self,
coupon: &str,
params: ReplaceParams,
) -> Result<SdkReplaceCouponResponseValue200ApplicationJson, Error> {
self.replace_with_options(coupon, params, None).await
}
pub async fn replace_with_options(
&self,
coupon: &str,
params: ReplaceParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkReplaceCouponResponseValue200ApplicationJson, Error> {
self.replace_raw(coupon, params, options)
.await
.map(|response| response.data)
}
pub async fn replace_raw(
&self,
coupon: &str,
params: ReplaceParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkReplaceCouponResponseValue200ApplicationJson>, Error> {
let coupon = crate::client::path_segment(coupon);
let path = format!("/v1/coupons/{coupon}");
let method = http::Method::PUT;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("replaceCoupon".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PUT /v1/coupons/{coupon}",
)
.await
}
pub async fn update(
&self,
coupon: &str,
params: UpdateParams,
) -> Result<SdkUpdateCouponResponseValue200ApplicationJson, Error> {
self.update_with_options(coupon, params, None).await
}
pub async fn update_with_options(
&self,
coupon: &str,
params: UpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkUpdateCouponResponseValue200ApplicationJson, Error> {
self.update_raw(coupon, params, options)
.await
.map(|response| response.data)
}
pub async fn update_raw(
&self,
coupon: &str,
params: UpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkUpdateCouponResponseValue200ApplicationJson>, Error> {
let coupon = crate::client::path_segment(coupon);
let path = format!("/v1/coupons/{coupon}");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("updateCoupon".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v1/coupons/{coupon}",
)
.await
}
pub async fn delete(
&self,
coupon: &str,
params: DeleteParams,
) -> Result<SdkDeleteCouponResponseValue200ApplicationJson, Error> {
self.delete_with_options(coupon, params, None).await
}
pub async fn delete_with_options(
&self,
coupon: &str,
params: DeleteParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkDeleteCouponResponseValue200ApplicationJson, Error> {
self.delete_raw(coupon, params, options)
.await
.map(|response| response.data)
}
pub async fn delete_raw(
&self,
coupon: &str,
params: DeleteParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkDeleteCouponResponseValue200ApplicationJson>, Error> {
let coupon = crate::client::path_segment(coupon);
let path = format!("/v1/coupons/{coupon}");
let method = http::Method::DELETE;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("deleteCoupon".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"DELETE /v1/coupons/{coupon}",
)
.await
}
pub async fn search(
&self,
params: SearchParams,
) -> Result<SdkSearchCouponsResponseValue200ApplicationJson, Error> {
self.search_with_options(params, None).await
}
pub async fn search_with_options(
&self,
params: SearchParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkSearchCouponsResponseValue200ApplicationJson, Error> {
self.search_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn search_raw(
&self,
params: SearchParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkSearchCouponsResponseValue200ApplicationJson>, Error> {
let path = "/v1/coupons/search".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("searchCoupons".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v1/coupons/search",
)
.await
}
pub async fn batch_create(
&self,
params: BatchCreateParams,
) -> Result<SdkBatchCreateCouponsResponseValue200ApplicationJson, Error> {
self.batch_create_with_options(params, None).await
}
pub async fn batch_create_with_options(
&self,
params: BatchCreateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkBatchCreateCouponsResponseValue200ApplicationJson, Error> {
self.batch_create_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn batch_create_raw(
&self,
params: BatchCreateParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkBatchCreateCouponsResponseValue200ApplicationJson>, Error>
{
let path = "/v1/coupons/batch".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("batchCreateCoupons".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v1/coupons/batch",
)
.await
}
pub async fn batch_update(
&self,
params: BatchUpdateParams,
) -> Result<SdkBatchUpdateCouponsResponseValue200ApplicationJson, Error> {
self.batch_update_with_options(params, None).await
}
pub async fn batch_update_with_options(
&self,
params: BatchUpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkBatchUpdateCouponsResponseValue200ApplicationJson, Error> {
self.batch_update_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn batch_update_raw(
&self,
params: BatchUpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkBatchUpdateCouponsResponseValue200ApplicationJson>, Error>
{
let path = "/v1/coupons/batch".to_string();
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("batchUpdateCoupons".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v1/coupons/batch",
)
.await
}
pub async fn batch_delete(
&self,
params: BatchDeleteParams,
) -> Result<SdkBatchDeleteCouponsResponseValue200ApplicationJson, Error> {
self.batch_delete_with_options(params, None).await
}
pub async fn batch_delete_with_options(
&self,
params: BatchDeleteParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkBatchDeleteCouponsResponseValue200ApplicationJson, Error> {
self.batch_delete_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn batch_delete_raw(
&self,
params: BatchDeleteParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkBatchDeleteCouponsResponseValue200ApplicationJson>, Error>
{
let path = "/v1/coupons/batch".to_string();
let method = http::Method::DELETE;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("batchDeleteCoupons".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"DELETE /v1/coupons/batch",
)
.await
}
pub async fn v_2_list_coupons(
&self,
params: V2ListCouponsParams,
) -> Result<SdkV2ListCouponsResponseValue200ApplicationJson, Error> {
self.v_2_list_coupons_with_options(params, None).await
}
pub async fn v_2_list_coupons_with_options(
&self,
params: V2ListCouponsParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2ListCouponsResponseValue200ApplicationJson, Error> {
self.v_2_list_coupons_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn v_2_list_coupons_raw(
&self,
params: V2ListCouponsParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2ListCouponsResponseValue200ApplicationJson>, Error> {
let path = "/v2/coupons".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("v2ListCoupons".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(method, &path, ¶ms, options, "GET /v2/coupons")
.await
}
pub async fn v_2_create_coupon(
&self,
params: V2CreateCouponParams,
) -> Result<SdkV2CreateCouponResponseValue201ApplicationJson, Error> {
self.v_2_create_coupon_with_options(params, None).await
}
pub async fn v_2_create_coupon_with_options(
&self,
params: V2CreateCouponParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2CreateCouponResponseValue201ApplicationJson, Error> {
self.v_2_create_coupon_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn v_2_create_coupon_raw(
&self,
params: V2CreateCouponParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2CreateCouponResponseValue201ApplicationJson>, Error> {
let path = "/v2/coupons".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("v2CreateCoupon".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/coupons",
)
.await
}
pub async fn v_2_search_coupons(
&self,
params: V2SearchCouponsParams,
) -> Result<SdkV2SearchCouponsResponseValue200ApplicationJson, Error> {
self.v_2_search_coupons_with_options(params, None).await
}
pub async fn v_2_search_coupons_with_options(
&self,
params: V2SearchCouponsParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2SearchCouponsResponseValue200ApplicationJson, Error> {
self.v_2_search_coupons_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn v_2_search_coupons_raw(
&self,
params: V2SearchCouponsParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2SearchCouponsResponseValue200ApplicationJson>, Error> {
let path = "/v2/coupons/search".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("v2SearchCoupons".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/coupons/search",
)
.await
}
pub async fn v_2_get_coupon(
&self,
coupon: &str,
params: V2GetCouponParams,
) -> Result<SdkV2GetCouponResponseValue200ApplicationJson, Error> {
self.v_2_get_coupon_with_options(coupon, params, None).await
}
pub async fn v_2_get_coupon_with_options(
&self,
coupon: &str,
params: V2GetCouponParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2GetCouponResponseValue200ApplicationJson, Error> {
self.v_2_get_coupon_raw(coupon, params, options)
.await
.map(|response| response.data)
}
pub async fn v_2_get_coupon_raw(
&self,
coupon: &str,
params: V2GetCouponParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2GetCouponResponseValue200ApplicationJson>, Error> {
let coupon = crate::client::path_segment(coupon);
let path = format!("/v2/coupons/{coupon}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("v2GetCoupon".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/coupons/{coupon}",
)
.await
}
pub async fn v_2_replace_coupon(
&self,
coupon: &str,
params: V2ReplaceCouponParams,
) -> Result<SdkV2ReplaceCouponResponseValue200ApplicationJson, Error> {
self.v_2_replace_coupon_with_options(coupon, params, None)
.await
}
pub async fn v_2_replace_coupon_with_options(
&self,
coupon: &str,
params: V2ReplaceCouponParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2ReplaceCouponResponseValue200ApplicationJson, Error> {
self.v_2_replace_coupon_raw(coupon, params, options)
.await
.map(|response| response.data)
}
pub async fn v_2_replace_coupon_raw(
&self,
coupon: &str,
params: V2ReplaceCouponParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2ReplaceCouponResponseValue200ApplicationJson>, Error> {
let coupon = crate::client::path_segment(coupon);
let path = format!("/v2/coupons/{coupon}");
let method = http::Method::PUT;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("v2ReplaceCoupon".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PUT /v2/coupons/{coupon}",
)
.await
}
pub async fn v_2_update_coupon(
&self,
coupon: &str,
params: V2UpdateCouponParams,
) -> Result<SdkV2UpdateCouponResponseValue200ApplicationJson, Error> {
self.v_2_update_coupon_with_options(coupon, params, None)
.await
}
pub async fn v_2_update_coupon_with_options(
&self,
coupon: &str,
params: V2UpdateCouponParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2UpdateCouponResponseValue200ApplicationJson, Error> {
self.v_2_update_coupon_raw(coupon, params, options)
.await
.map(|response| response.data)
}
pub async fn v_2_update_coupon_raw(
&self,
coupon: &str,
params: V2UpdateCouponParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2UpdateCouponResponseValue200ApplicationJson>, Error> {
let coupon = crate::client::path_segment(coupon);
let path = format!("/v2/coupons/{coupon}");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("v2UpdateCoupon".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/coupons/{coupon}",
)
.await
}
pub async fn v_2_delete_coupon(
&self,
coupon: &str,
params: V2DeleteCouponParams,
) -> Result<SdkV2DeleteCouponResponseValue200ApplicationJson, Error> {
self.v_2_delete_coupon_with_options(coupon, params, None)
.await
}
pub async fn v_2_delete_coupon_with_options(
&self,
coupon: &str,
params: V2DeleteCouponParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2DeleteCouponResponseValue200ApplicationJson, Error> {
self.v_2_delete_coupon_raw(coupon, params, options)
.await
.map(|response| response.data)
}
pub async fn v_2_delete_coupon_raw(
&self,
coupon: &str,
params: V2DeleteCouponParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2DeleteCouponResponseValue200ApplicationJson>, Error> {
let coupon = crate::client::path_segment(coupon);
let path = format!("/v2/coupons/{coupon}");
let method = http::Method::DELETE;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("v2DeleteCoupon".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"DELETE /v2/coupons/{coupon}",
)
.await
}
pub async fn v_2_batch_create_coupons(
&self,
params: V2BatchCreateCouponsParams,
) -> Result<SdkV2BatchCreateCouponsResponseValue200ApplicationJson, Error> {
self.v_2_batch_create_coupons_with_options(params, None)
.await
}
pub async fn v_2_batch_create_coupons_with_options(
&self,
params: V2BatchCreateCouponsParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2BatchCreateCouponsResponseValue200ApplicationJson, Error> {
self.v_2_batch_create_coupons_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn v_2_batch_create_coupons_raw(
&self,
params: V2BatchCreateCouponsParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2BatchCreateCouponsResponseValue200ApplicationJson>, Error>
{
let path = "/v2/coupons/batch".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("v2BatchCreateCoupons".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/coupons/batch",
)
.await
}
pub async fn v_2_batch_update_coupons(
&self,
params: V2BatchUpdateCouponsParams,
) -> Result<SdkV2BatchUpdateCouponsResponseValue200ApplicationJson, Error> {
self.v_2_batch_update_coupons_with_options(params, None)
.await
}
pub async fn v_2_batch_update_coupons_with_options(
&self,
params: V2BatchUpdateCouponsParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2BatchUpdateCouponsResponseValue200ApplicationJson, Error> {
self.v_2_batch_update_coupons_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn v_2_batch_update_coupons_raw(
&self,
params: V2BatchUpdateCouponsParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2BatchUpdateCouponsResponseValue200ApplicationJson>, Error>
{
let path = "/v2/coupons/batch".to_string();
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("v2BatchUpdateCoupons".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/coupons/batch",
)
.await
}
pub async fn v_2_batch_delete_coupons(
&self,
params: V2BatchDeleteCouponsParams,
) -> Result<SdkV2BatchDeleteCouponsResponseValue200ApplicationJson, Error> {
self.v_2_batch_delete_coupons_with_options(params, None)
.await
}
pub async fn v_2_batch_delete_coupons_with_options(
&self,
params: V2BatchDeleteCouponsParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2BatchDeleteCouponsResponseValue200ApplicationJson, Error> {
self.v_2_batch_delete_coupons_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn v_2_batch_delete_coupons_raw(
&self,
params: V2BatchDeleteCouponsParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2BatchDeleteCouponsResponseValue200ApplicationJson>, Error>
{
let path = "/v2/coupons/batch".to_string();
let method = http::Method::DELETE;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("v2BatchDeleteCoupons".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"DELETE /v2/coupons/batch",
)
.await
}
}