sellapp-sdk 0.1.1

Official Rust SDK for the SellApp API: manage products, orders, subscriptions, and customers.
// 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 BookingsCalendarEventsApi<'a> {
    pub(crate) client: &'a Client,
}

#[derive(Debug, Clone, Serialize)]
pub struct ListParams {
    /// Return the effective override hierarchy for a same-store booking variant, including inherited store-wide and product-wide rows plus exact variant rows.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub product_variant_id: Option<i64>,
    /// Only return overrides ending after this instant.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    /// Only return overrides starting before this instant.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub to: Option<String>,
    /// Filter by override status.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<BookingsStatus>,
    /// Set to false to return at most 100 matching overrides in one data array without pagination links or metadata.
    ///
    /// Defaults to `true`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pagination: Option<bool>,
    /// Number of items to return per page.
    ///
    /// Defaults to `15`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
    /// Page number to return.
    ///
    /// Defaults to `1`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// 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>,
}

impl Default for ListParams {
    #[allow(deprecated)]
    fn default() -> Self {
        Self {
            product_variant_id: Default::default(),
            from: Default::default(),
            to: Default::default(),
            status: Default::default(),
            pagination: Some(true),
            limit: Some(15),
            page: Some(1),
            x_store: Default::default(),
        }
    }
}

#[derive(Debug, Clone, Serialize)]
pub struct SetParams {
    /// 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: SdkSetBookingDateAvailabilityRequestApplicationJson,
}

impl SetParams {
    /// Construct a new `SetParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkSetBookingDateAvailabilityRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

impl<'a> BookingsCalendarEventsApi<'a> {
    /// List booking date overrides
    ///
    /// List store-wide or variant-specific booking date overrides. Date boundaries are stored in UTC and interpreted in the booking timezone. Requires the `listing` Sanctum ability. 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 list(
        &self,
        params: ListParams,
    ) -> Result<SdkListBookingDateOverridesResponseValue200ApplicationJson, Error> {
        self.list_with_options(params, None).await
    }

    /// Variant of [`Self::list`] that accepts per-request [`crate::RequestOptions`].
    pub async fn list_with_options(
        &self,
        params: ListParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkListBookingDateOverridesResponseValue200ApplicationJson, Error> {
        self.list_raw(params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn list_raw(
        &self,
        params: ListParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkListBookingDateOverridesResponseValue200ApplicationJson>, Error>
    {
        let path = "/v2/booking-calendar-events".to_string();
        let method = http::Method::GET;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("listBookingDateOverrides".to_string());
        let options = Some(&merged);
        self.client
            .request_with_query_schema_opts_raw(
                method,
                &path,
                &params,
                options,
                "GET /v2/booking-calendar-events",
            )
            .await
    }

    /// Set booking date availability
    ///
    /// Atomically mark one or more local calendar dates unavailable or available for the store or one same-store booking variant. Requires the `listing` Sanctum ability. 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 set(
        &self,
        params: SetParams,
    ) -> Result<SdkSetBookingDateAvailabilityResponseValue201ApplicationJson, Error> {
        self.set_with_options(params, None).await
    }

    /// Variant of [`Self::set`] that accepts per-request [`crate::RequestOptions`].
    pub async fn set_with_options(
        &self,
        params: SetParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkSetBookingDateAvailabilityResponseValue201ApplicationJson, Error> {
        self.set_raw(params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn set_raw(
        &self,
        params: SetParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<
        crate::RawResponse<SdkSetBookingDateAvailabilityResponseValue201ApplicationJson>,
        Error,
    > {
        let path = "/v2/booking-calendar-events".to_string();
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("setBookingDateAvailability".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/booking-calendar-events",
            )
            .await
    }
}