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 VariantSerialsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct ListParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub search: Option<String>,
#[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")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl Default for ListParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
search: Default::default(),
limit: Some(50),
page: Some(1),
x_store: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct AppendParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkAppendVariantSerialInventoryRequestApplicationJson,
}
impl AppendParams {
#[allow(deprecated)]
pub fn new(body: SdkAppendVariantSerialInventoryRequestApplicationJson) -> 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: SdkReplaceVariantSerialInventoryRequestApplicationJson,
}
impl ReplaceParams {
#[allow(deprecated)]
pub fn new(body: SdkReplaceVariantSerialInventoryRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct QueueParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkQueueVariantSerialImportRequestMultipartFormData,
}
impl QueueParams {
#[allow(deprecated)]
pub fn new(body: SdkQueueVariantSerialImportRequestMultipartFormData) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct DeleteParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl<'a> VariantSerialsApi<'a> {
pub async fn list(
&self,
product: &str,
variant: &str,
params: ListParams,
) -> Result<SdkListVariantSerialInventoryResponseValue200ApplicationJson, Error> {
self.list_with_options(product, variant, params, None).await
}
pub async fn list_with_options(
&self,
product: &str,
variant: &str,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListVariantSerialInventoryResponseValue200ApplicationJson, Error> {
self.list_raw(product, variant, params, options)
.await
.map(|response| response.data)
}
pub async fn list_raw(
&self,
product: &str,
variant: &str,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkListVariantSerialInventoryResponseValue200ApplicationJson>,
Error,
> {
let product = crate::client::path_segment(product);
let variant = crate::client::path_segment(variant);
let path = format!("/v2/products/{product}/variants/{variant}/serials");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listVariantSerialInventory".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/products/{product}/variants/{variant}/serials",
)
.await
}
pub async fn append(
&self,
product: &str,
variant: &str,
params: AppendParams,
) -> Result<SdkAppendVariantSerialInventoryResponseValue201ApplicationJson, Error> {
self.append_with_options(product, variant, params, None)
.await
}
pub async fn append_with_options(
&self,
product: &str,
variant: &str,
params: AppendParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkAppendVariantSerialInventoryResponseValue201ApplicationJson, Error> {
self.append_raw(product, variant, params, options)
.await
.map(|response| response.data)
}
pub async fn append_raw(
&self,
product: &str,
variant: &str,
params: AppendParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkAppendVariantSerialInventoryResponseValue201ApplicationJson>,
Error,
> {
let product = crate::client::path_segment(product);
let variant = crate::client::path_segment(variant);
let path = format!("/v2/products/{product}/variants/{variant}/serials");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("appendVariantSerialInventory".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/products/{product}/variants/{variant}/serials",
)
.await
}
pub async fn replace(
&self,
product: &str,
variant: &str,
params: ReplaceParams,
) -> Result<SdkReplaceVariantSerialInventoryResponseValue200ApplicationJson, Error> {
self.replace_with_options(product, variant, params, None)
.await
}
pub async fn replace_with_options(
&self,
product: &str,
variant: &str,
params: ReplaceParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkReplaceVariantSerialInventoryResponseValue200ApplicationJson, Error> {
self.replace_raw(product, variant, params, options)
.await
.map(|response| response.data)
}
pub async fn replace_raw(
&self,
product: &str,
variant: &str,
params: ReplaceParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkReplaceVariantSerialInventoryResponseValue200ApplicationJson>,
Error,
> {
let product = crate::client::path_segment(product);
let variant = crate::client::path_segment(variant);
let path = format!("/v2/products/{product}/variants/{variant}/serials");
let method = http::Method::PUT;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("replaceVariantSerialInventory".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PUT /v2/products/{product}/variants/{variant}/serials",
)
.await
}
pub async fn queue(
&self,
product: &str,
variant: &str,
params: QueueParams,
) -> Result<SdkQueueVariantSerialImportResponseValue202ApplicationJson, Error> {
self.queue_with_options(product, variant, params, None)
.await
}
pub async fn queue_with_options(
&self,
product: &str,
variant: &str,
params: QueueParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkQueueVariantSerialImportResponseValue202ApplicationJson, Error> {
self.queue_raw(product, variant, params, options)
.await
.map(|response| response.data)
}
pub async fn queue_raw(
&self,
product: &str,
variant: &str,
params: QueueParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkQueueVariantSerialImportResponseValue202ApplicationJson>, Error>
{
let product = crate::client::path_segment(product);
let variant = crate::client::path_segment(variant);
let path = format!("/v2/products/{product}/variants/{variant}/serials/import");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("queueVariantSerialImport".to_string());
merged.body_encoding = crate::BodyEncoding::Multipart;
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/products/{product}/variants/{variant}/serials/import",
)
.await
}
pub async fn delete(
&self,
product: &str,
variant: &str,
serial: &str,
params: DeleteParams,
) -> Result<SdkDeleteVariantSerialResponseValue200ApplicationJson, Error> {
self.delete_with_options(product, variant, serial, params, None)
.await
}
pub async fn delete_with_options(
&self,
product: &str,
variant: &str,
serial: &str,
params: DeleteParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkDeleteVariantSerialResponseValue200ApplicationJson, Error> {
self.delete_raw(product, variant, serial, params, options)
.await
.map(|response| response.data)
}
pub async fn delete_raw(
&self,
product: &str,
variant: &str,
serial: &str,
params: DeleteParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkDeleteVariantSerialResponseValue200ApplicationJson>, Error>
{
let product = crate::client::path_segment(product);
let variant = crate::client::path_segment(variant);
let serial = crate::client::path_segment(serial);
let path = format!("/v2/products/{product}/variants/{variant}/serials/{serial}");
let method = http::Method::DELETE;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("deleteVariantSerial".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"DELETE /v2/products/{product}/variants/{variant}/serials/{serial}",
)
.await
}
}