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 CoursesSectionsApi<'a> {
    pub(crate) client: &'a Client,
}

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

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

#[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: SdkReplaceCourseSectionRequestApplicationJson,
}

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

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

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

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

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

impl<'a> CoursesSectionsApi<'a> {
    /// Create a course section
    ///
    /// Append a section to a course curriculum. 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 create(
        &self,
        course: &str,
        params: CreateParams,
    ) -> Result<SdkCreateCourseSectionResponseValue201ApplicationJson, Error> {
        self.create_with_options(course, params, None).await
    }

    /// Variant of [`Self::create`] that accepts per-request [`crate::RequestOptions`].
    pub async fn create_with_options(
        &self,
        course: &str,
        params: CreateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkCreateCourseSectionResponseValue201ApplicationJson, Error> {
        self.create_raw(course, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn create_raw(
        &self,
        course: &str,
        params: CreateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkCreateCourseSectionResponseValue201ApplicationJson>, Error>
    {
        let course = crate::client::path_segment(course);
        let path = format!("/v2/courses/{course}/sections");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("createCourseSection".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/courses/{course}/sections",
            )
            .await
    }

    /// Update a course section
    ///
    /// Update a section title or sanitized rich-text description. 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,
        course: &str,
        section: &str,
        params: ReplaceParams,
    ) -> Result<SdkReplaceCourseSectionResponseValue200ApplicationJson, Error> {
        self.replace_with_options(course, section, params, None)
            .await
    }

    /// Variant of [`Self::replace`] that accepts per-request [`crate::RequestOptions`].
    pub async fn replace_with_options(
        &self,
        course: &str,
        section: &str,
        params: ReplaceParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkReplaceCourseSectionResponseValue200ApplicationJson, Error> {
        self.replace_raw(course, section, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn replace_raw(
        &self,
        course: &str,
        section: &str,
        params: ReplaceParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkReplaceCourseSectionResponseValue200ApplicationJson>, Error>
    {
        let course = crate::client::path_segment(course);
        let section = crate::client::path_segment(section);
        let path = format!("/v2/courses/{course}/sections/{section}");
        let method = http::Method::PUT;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("replaceCourseSection".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "PUT /v2/courses/{course}/sections/{section}",
            )
            .await
    }

    /// Update a course section
    ///
    /// Update a section title or sanitized rich-text description. 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 update(
        &self,
        course: &str,
        section: &str,
        params: UpdateParams,
    ) -> Result<SdkUpdateCourseSectionResponseValue200ApplicationJson, Error> {
        self.update_with_options(course, section, params, None)
            .await
    }

    /// Variant of [`Self::update`] that accepts per-request [`crate::RequestOptions`].
    pub async fn update_with_options(
        &self,
        course: &str,
        section: &str,
        params: UpdateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkUpdateCourseSectionResponseValue200ApplicationJson, Error> {
        self.update_raw(course, section, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn update_raw(
        &self,
        course: &str,
        section: &str,
        params: UpdateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkUpdateCourseSectionResponseValue200ApplicationJson>, Error>
    {
        let course = crate::client::path_segment(course);
        let section = crate::client::path_segment(section);
        let path = format!("/v2/courses/{course}/sections/{section}");
        let method = http::Method::PATCH;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("updateCourseSection".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "PATCH /v2/courses/{course}/sections/{section}",
            )
            .await
    }

    /// Delete a course section
    ///
    /// Delete a section, its lessons, structured questions, attachments, and video references, then normalize remaining section order. 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 delete(
        &self,
        course: &str,
        section: &str,
        params: DeleteParams,
    ) -> Result<SdkDeleteCourseSectionResponseValue200ApplicationJson, Error> {
        self.delete_with_options(course, section, params, None)
            .await
    }

    /// Variant of [`Self::delete`] that accepts per-request [`crate::RequestOptions`].
    pub async fn delete_with_options(
        &self,
        course: &str,
        section: &str,
        params: DeleteParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkDeleteCourseSectionResponseValue200ApplicationJson, Error> {
        self.delete_raw(course, section, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn delete_raw(
        &self,
        course: &str,
        section: &str,
        params: DeleteParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkDeleteCourseSectionResponseValue200ApplicationJson>, Error>
    {
        let course = crate::client::path_segment(course);
        let section = crate::client::path_segment(section);
        let path = format!("/v2/courses/{course}/sections/{section}");
        let method = http::Method::DELETE;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("deleteCourseSection".to_string());
        let options = Some(&merged);
        self.client
            .request_with_query_schema_opts_raw(
                method,
                &path,
                &params,
                options,
                "DELETE /v2/courses/{course}/sections/{section}",
            )
            .await
    }

    /// Reorder course sections
    ///
    /// Replace the complete section order. Send every section ID exactly once in the desired order. 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 reorder(
        &self,
        course: &str,
        params: ReorderParams,
    ) -> Result<SdkReorderCourseSectionsResponseValue200ApplicationJson, Error> {
        self.reorder_with_options(course, params, None).await
    }

    /// Variant of [`Self::reorder`] that accepts per-request [`crate::RequestOptions`].
    pub async fn reorder_with_options(
        &self,
        course: &str,
        params: ReorderParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkReorderCourseSectionsResponseValue200ApplicationJson, Error> {
        self.reorder_raw(course, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn reorder_raw(
        &self,
        course: &str,
        params: ReorderParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkReorderCourseSectionsResponseValue200ApplicationJson>, Error>
    {
        let course = crate::client::path_segment(course);
        let path = format!("/v2/courses/{course}/sections/reorder");
        let method = http::Method::PATCH;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("reorderCourseSections".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "PATCH /v2/courses/{course}/sections/reorder",
            )
            .await
    }
}