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 CreditsProductsApi<'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 pagination: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl Default for ListParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
limit: Some(15),
page: Some(1),
pagination: Some(true),
x_store: Default::default(),
}
}
}
#[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: SdkCreateCreditsProductRequestApplicationJson,
}
impl CreateParams {
#[allow(deprecated)]
pub fn new(body: SdkCreateCreditsProductRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct SearchParams {
#[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 pagination: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkSearchCreditsProductsRequestApplicationJson,
}
impl SearchParams {
#[allow(deprecated)]
pub fn new(body: SdkSearchCreditsProductsRequestApplicationJson) -> Self {
Self {
limit: Some(15),
page: Some(1),
pagination: Some(true),
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[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: SdkReplaceCreditsProductRequestApplicationJson,
}
impl ReplaceParams {
#[allow(deprecated)]
pub fn new(body: SdkReplaceCreditsProductRequestApplicationJson) -> 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: SdkUpdateCreditsProductRequestApplicationJson,
}
impl UpdateParams {
#[allow(deprecated)]
pub fn new(body: SdkUpdateCreditsProductRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct DeleteParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkDeleteCreditsProductRequestApplicationJson,
}
impl DeleteParams {
#[allow(deprecated)]
pub fn new(body: SdkDeleteCreditsProductRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
impl<'a> CreditsProductsApi<'a> {
pub async fn list(
&self,
params: ListParams,
) -> Result<SdkListCreditsProductsResponseValue200ApplicationJson, Error> {
self.list_with_options(params, None).await
}
pub async fn list_with_options(
&self,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListCreditsProductsResponseValue200ApplicationJson, 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<SdkListCreditsProductsResponseValue200ApplicationJson>, Error>
{
let path = "/v2/credit-products".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listCreditsProducts".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/credit-products",
)
.await
}
pub async fn create(
&self,
params: CreateParams,
) -> Result<SdkCreateCreditsProductResponseValue201ApplicationJson, Error> {
self.create_with_options(params, None).await
}
pub async fn create_with_options(
&self,
params: CreateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCreateCreditsProductResponseValue201ApplicationJson, 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<SdkCreateCreditsProductResponseValue201ApplicationJson>, Error>
{
let path = "/v2/credit-products".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("createCreditsProduct".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/credit-products",
)
.await
}
pub async fn search(
&self,
params: SearchParams,
) -> Result<SdkSearchCreditsProductsResponseValue200ApplicationJson, Error> {
self.search_with_options(params, None).await
}
pub async fn search_with_options(
&self,
params: SearchParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkSearchCreditsProductsResponseValue200ApplicationJson, 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<SdkSearchCreditsProductsResponseValue200ApplicationJson>, Error>
{
let path = "/v2/credit-products/search".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("searchCreditsProducts".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/credit-products/search",
)
.await
}
pub async fn get(
&self,
credit_product: &str,
params: GetParams,
) -> Result<SdkGetCreditsProductResponseValue200ApplicationJson, Error> {
self.get_with_options(credit_product, params, None).await
}
pub async fn get_with_options(
&self,
credit_product: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetCreditsProductResponseValue200ApplicationJson, Error> {
self.get_raw(credit_product, params, options)
.await
.map(|response| response.data)
}
pub async fn get_raw(
&self,
credit_product: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetCreditsProductResponseValue200ApplicationJson>, Error>
{
let credit_product = crate::client::path_segment(credit_product);
let path = format!("/v2/credit-products/{credit_product}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getCreditsProduct".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/credit-products/{creditProduct}",
)
.await
}
pub async fn replace(
&self,
credit_product: &str,
params: ReplaceParams,
) -> Result<SdkReplaceCreditsProductResponseValue200ApplicationJson, Error> {
self.replace_with_options(credit_product, params, None)
.await
}
pub async fn replace_with_options(
&self,
credit_product: &str,
params: ReplaceParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkReplaceCreditsProductResponseValue200ApplicationJson, Error> {
self.replace_raw(credit_product, params, options)
.await
.map(|response| response.data)
}
pub async fn replace_raw(
&self,
credit_product: &str,
params: ReplaceParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkReplaceCreditsProductResponseValue200ApplicationJson>, Error>
{
let credit_product = crate::client::path_segment(credit_product);
let path = format!("/v2/credit-products/{credit_product}");
let method = http::Method::PUT;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("replaceCreditsProduct".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PUT /v2/credit-products/{creditProduct}",
)
.await
}
pub async fn update(
&self,
credit_product: &str,
params: UpdateParams,
) -> Result<SdkUpdateCreditsProductResponseValue200ApplicationJson, Error> {
self.update_with_options(credit_product, params, None).await
}
pub async fn update_with_options(
&self,
credit_product: &str,
params: UpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkUpdateCreditsProductResponseValue200ApplicationJson, Error> {
self.update_raw(credit_product, params, options)
.await
.map(|response| response.data)
}
pub async fn update_raw(
&self,
credit_product: &str,
params: UpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkUpdateCreditsProductResponseValue200ApplicationJson>, Error>
{
let credit_product = crate::client::path_segment(credit_product);
let path = format!("/v2/credit-products/{credit_product}");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("updateCreditsProduct".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/credit-products/{creditProduct}",
)
.await
}
pub async fn delete(
&self,
credit_product: &str,
params: DeleteParams,
) -> Result<SdkDeleteCreditsProductResponseValue200ApplicationJson, Error> {
self.delete_with_options(credit_product, params, None).await
}
pub async fn delete_with_options(
&self,
credit_product: &str,
params: DeleteParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkDeleteCreditsProductResponseValue200ApplicationJson, Error> {
self.delete_raw(credit_product, params, options)
.await
.map(|response| response.data)
}
pub async fn delete_raw(
&self,
credit_product: &str,
params: DeleteParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkDeleteCreditsProductResponseValue200ApplicationJson>, Error>
{
let credit_product = crate::client::path_segment(credit_product);
let path = format!("/v2/credit-products/{credit_product}");
let method = http::Method::DELETE;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("deleteCreditsProduct".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"DELETE /v2/credit-products/{creditProduct}",
)
.await
}
}