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 {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkCreateCourseLessonRequestApplicationJson,
}
impl CreateParams {
#[allow(deprecated)]
pub fn new(body: SdkCreateCourseLessonRequestApplicationJson) -> 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: SdkReplaceCourseLessonRequestApplicationJson,
}
impl ReplaceParams {
#[allow(deprecated)]
pub fn new(body: SdkReplaceCourseLessonRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkUpdateCourseLessonRequestApplicationJson,
}
impl UpdateParams {
#[allow(deprecated)]
pub fn new(body: SdkUpdateCourseLessonRequestApplicationJson) -> 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>,
}
#[derive(Debug, Clone, Serialize)]
pub struct ReorderParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkReorderCourseLessonsRequestApplicationJson,
}
impl ReorderParams {
#[allow(deprecated)]
pub fn new(body: SdkReorderCourseLessonsRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
impl<'a> CoursesLessonsApi<'a> {
pub async fn create(
&self,
course: &str,
section: &str,
params: CreateParams,
) -> Result<SdkCreateCourseLessonResponseValue201ApplicationJson, Error> {
self.create_with_options(course, section, params, None)
.await
}
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)
}
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,
¶ms,
Some(¶ms.body),
options,
"POST /v2/courses/{course}/sections/{section}/lessons",
)
.await
}
pub async fn replace(
&self,
course: &str,
lesson: &str,
params: ReplaceParams,
) -> Result<SdkReplaceCourseLessonResponseValue200ApplicationJson, Error> {
self.replace_with_options(course, lesson, params, None)
.await
}
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)
}
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,
¶ms,
Some(¶ms.body),
options,
"PUT /v2/courses/{course}/lessons/{lesson}",
)
.await
}
pub async fn update(
&self,
course: &str,
lesson: &str,
params: UpdateParams,
) -> Result<SdkUpdateCourseLessonResponseValue200ApplicationJson, Error> {
self.update_with_options(course, lesson, params, None).await
}
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)
}
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,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/courses/{course}/lessons/{lesson}",
)
.await
}
pub async fn delete(
&self,
course: &str,
lesson: &str,
params: DeleteParams,
) -> Result<SdkDeleteCourseLessonResponseValue200ApplicationJson, Error> {
self.delete_with_options(course, lesson, params, None).await
}
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)
}
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,
¶ms,
options,
"DELETE /v2/courses/{course}/lessons/{lesson}",
)
.await
}
pub async fn reorder(
&self,
course: &str,
params: ReorderParams,
) -> Result<SdkReorderCourseLessonsResponseValue200ApplicationJson, Error> {
self.reorder_with_options(course, params, None).await
}
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)
}
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,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/courses/{course}/lessons/reorder",
)
.await
}
}