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 CoursesLessonsApi<'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: SdkCreateCourseLessonRequestApplicationJson,
}

impl CreateParams {
    /// Construct a new `CreateParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkCreateCourseLessonRequestApplicationJson) -> 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: SdkReplaceCourseLessonRequestApplicationJson,
}

impl ReplaceParams {
    /// Construct a new `ReplaceParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkReplaceCourseLessonRequestApplicationJson) -> 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: SdkUpdateCourseLessonRequestApplicationJson,
}

impl UpdateParams {
    /// Construct a new `UpdateParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkUpdateCourseLessonRequestApplicationJson) -> 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: SdkReorderCourseLessonsRequestApplicationJson,
}

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

impl<'a> CoursesLessonsApi<'a> {
    /// Create a course lesson
    ///
    /// Append a lesson, quiz, or assignment to a section. Rich text is sanitized before storage. 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,
        section: &str,
        params: CreateParams,
    ) -> Result<SdkCreateCourseLessonResponseValue201ApplicationJson, Error> {
        self.create_with_options(course, section, params, None)
            .await
    }

    /// Variant of [`Self::create`] that accepts per-request [`crate::RequestOptions`].
    pub async fn create_with_options(
        &self,
        course: &str,
        section: &str,
        params: CreateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkCreateCourseLessonResponseValue201ApplicationJson, Error> {
        self.create_raw(course, section, 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,
        section: &str,
        params: CreateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkCreateCourseLessonResponseValue201ApplicationJson>, Error>
    {
        let course = crate::client::path_segment(course);
        let section = crate::client::path_segment(section);
        let path = format!("/v2/courses/{course}/sections/{section}/lessons");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("createCourseLesson".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/{section}/lessons",
            )
            .await
    }

    /// Update a course lesson
    ///
    /// Update lesson content, draft state, preview state, or replace the structured quiz or assignment body. Item type is immutable except while choosing video or text for a new lecture placeholder. 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,
        lesson: &str,
        params: ReplaceParams,
    ) -> Result<SdkReplaceCourseLessonResponseValue200ApplicationJson, Error> {
        self.replace_with_options(course, lesson, params, None)
            .await
    }

    /// Variant of [`Self::replace`] that accepts per-request [`crate::RequestOptions`].
    pub async fn replace_with_options(
        &self,
        course: &str,
        lesson: &str,
        params: ReplaceParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkReplaceCourseLessonResponseValue200ApplicationJson, Error> {
        self.replace_raw(course, lesson, 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,
        lesson: &str,
        params: ReplaceParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkReplaceCourseLessonResponseValue200ApplicationJson>, Error>
    {
        let course = crate::client::path_segment(course);
        let lesson = crate::client::path_segment(lesson);
        let path = format!("/v2/courses/{course}/lessons/{lesson}");
        let method = http::Method::PUT;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("replaceCourseLesson".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}/lessons/{lesson}",
            )
            .await
    }

    /// Update a course lesson
    ///
    /// Update lesson content, draft state, preview state, or replace the structured quiz or assignment body. Item type is immutable except while choosing video or text for a new lecture placeholder. 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,
        lesson: &str,
        params: UpdateParams,
    ) -> Result<SdkUpdateCourseLessonResponseValue200ApplicationJson, Error> {
        self.update_with_options(course, lesson, params, None).await
    }

    /// Variant of [`Self::update`] that accepts per-request [`crate::RequestOptions`].
    pub async fn update_with_options(
        &self,
        course: &str,
        lesson: &str,
        params: UpdateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkUpdateCourseLessonResponseValue200ApplicationJson, Error> {
        self.update_raw(course, lesson, 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,
        lesson: &str,
        params: UpdateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkUpdateCourseLessonResponseValue200ApplicationJson>, Error>
    {
        let course = crate::client::path_segment(course);
        let lesson = crate::client::path_segment(lesson);
        let path = format!("/v2/courses/{course}/lessons/{lesson}");
        let method = http::Method::PATCH;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("updateCourseLesson".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}/lessons/{lesson}",
            )
            .await
    }

    /// Delete a course lesson
    ///
    /// Delete a lesson and its structured questions, assignment, attachments, and video reference, then normalize lesson 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,
        lesson: &str,
        params: DeleteParams,
    ) -> Result<SdkDeleteCourseLessonResponseValue200ApplicationJson, Error> {
        self.delete_with_options(course, lesson, params, None).await
    }

    /// Variant of [`Self::delete`] that accepts per-request [`crate::RequestOptions`].
    pub async fn delete_with_options(
        &self,
        course: &str,
        lesson: &str,
        params: DeleteParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkDeleteCourseLessonResponseValue200ApplicationJson, Error> {
        self.delete_raw(course, lesson, 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,
        lesson: &str,
        params: DeleteParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkDeleteCourseLessonResponseValue200ApplicationJson>, Error>
    {
        let course = crate::client::path_segment(course);
        let lesson = crate::client::path_segment(lesson);
        let path = format!("/v2/courses/{course}/lessons/{lesson}");
        let method = http::Method::DELETE;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("deleteCourseLesson".to_string());
        let options = Some(&merged);
        self.client
            .request_with_query_schema_opts_raw(
                method,
                &path,
                &params,
                options,
                "DELETE /v2/courses/{course}/lessons/{lesson}",
            )
            .await
    }

    /// Reorder course lessons
    ///
    /// Replace the complete lesson order and section placement. Send every lesson ID exactly once with a destination section from the same course. 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<SdkReorderCourseLessonsResponseValue200ApplicationJson, 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<SdkReorderCourseLessonsResponseValue200ApplicationJson, 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<SdkReorderCourseLessonsResponseValue200ApplicationJson>, Error>
    {
        let course = crate::client::path_segment(course);
        let path = format!("/v2/courses/{course}/lessons/reorder");
        let method = http::Method::PATCH;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("reorderCourseLessons".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}/lessons/reorder",
            )
            .await
    }
}