// This file is auto-generated by oagen. Do not edit.
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 VariantDeliverablesApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct ReplaceParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkReplaceVariantDeliverableConfigurationRequestApplicationJson,
}
impl ReplaceParams {
/// Construct a new `ReplaceParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkReplaceVariantDeliverableConfigurationRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
impl<'a> VariantDeliverablesApi<'a> {
/// Retrieve variant deliverable configuration
///
/// Retrieve variant deliverable configuration. Requires the listing Sanctum ability. Returns delivery types and safe configuration for a variant in the authenticated store. Dynamic endpoint URLs and inventory data are not returned. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn get(
&self,
product: &str,
variant: &str,
params: GetParams,
) -> Result<SdkGetVariantDeliverableConfigurationResponseValue200ApplicationJson, Error> {
self.get_with_options(product, variant, params, None).await
}
/// Variant of [`Self::get`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_with_options(
&self,
product: &str,
variant: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetVariantDeliverableConfigurationResponseValue200ApplicationJson, Error> {
self.get_raw(product, variant, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn get_raw(
&self,
product: &str,
variant: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkGetVariantDeliverableConfigurationResponseValue200ApplicationJson>,
Error,
> {
let product = crate::client::path_segment(product);
let variant = crate::client::path_segment(variant);
let path = format!("/v2/products/{product}/variants/{variant}/deliverable");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getVariantDeliverableConfiguration".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/products/{product}/variants/{variant}/deliverable",
)
.await
}
/// Replace variant deliverable configuration
///
/// Replace variant deliverable configuration. Requires the listing Sanctum ability. Replaces this resource's delivery types atomically. Pass expected_updated_at from the product variant resource to reject stale updates with 422. TEXT, BOOKING, CREDITS, and BUNDLE must remain unchanged. Removing DOWNLOADABLE deletes managed files and folders after commit; removing a type clears its private configuration. Dynamic endpoints are write-only. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn replace(
&self,
product: &str,
variant: &str,
params: ReplaceParams,
) -> Result<SdkReplaceVariantDeliverableConfigurationResponseValue200ApplicationJson, Error>
{
self.replace_with_options(product, variant, params, None)
.await
}
/// Variant of [`Self::replace`] that accepts per-request [`crate::RequestOptions`].
pub async fn replace_with_options(
&self,
product: &str,
variant: &str,
params: ReplaceParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkReplaceVariantDeliverableConfigurationResponseValue200ApplicationJson, Error>
{
self.replace_raw(product, variant, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn replace_raw(
&self,
product: &str,
variant: &str,
params: ReplaceParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<
SdkReplaceVariantDeliverableConfigurationResponseValue200ApplicationJson,
>,
Error,
> {
let product = crate::client::path_segment(product);
let variant = crate::client::path_segment(variant);
let path = format!("/v2/products/{product}/variants/{variant}/deliverable");
let method = http::Method::PUT;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("replaceVariantDeliverableConfiguration".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}/deliverable",
)
.await
}
}