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 {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkCreateCourseSectionRequestApplicationJson,
}
impl CreateParams {
#[allow(deprecated)]
pub fn new(body: SdkCreateCourseSectionRequestApplicationJson) -> 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: SdkReplaceCourseSectionRequestApplicationJson,
}
impl ReplaceParams {
#[allow(deprecated)]
pub fn new(body: SdkReplaceCourseSectionRequestApplicationJson) -> 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: SdkUpdateCourseSectionRequestApplicationJson,
}
impl UpdateParams {
#[allow(deprecated)]
pub fn new(body: SdkUpdateCourseSectionRequestApplicationJson) -> 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: SdkReorderCourseSectionsRequestApplicationJson,
}
impl ReorderParams {
#[allow(deprecated)]
pub fn new(body: SdkReorderCourseSectionsRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
impl<'a> CoursesSectionsApi<'a> {
pub async fn create(
&self,
course: &str,
params: CreateParams,
) -> Result<SdkCreateCourseSectionResponseValue201ApplicationJson, Error> {
self.create_with_options(course, params, None).await
}
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)
}
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,
¶ms,
Some(¶ms.body),
options,
"POST /v2/courses/{course}/sections",
)
.await
}
pub async fn replace(
&self,
course: &str,
section: &str,
params: ReplaceParams,
) -> Result<SdkReplaceCourseSectionResponseValue200ApplicationJson, Error> {
self.replace_with_options(course, section, params, None)
.await
}
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)
}
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,
¶ms,
Some(¶ms.body),
options,
"PUT /v2/courses/{course}/sections/{section}",
)
.await
}
pub async fn update(
&self,
course: &str,
section: &str,
params: UpdateParams,
) -> Result<SdkUpdateCourseSectionResponseValue200ApplicationJson, Error> {
self.update_with_options(course, section, params, None)
.await
}
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)
}
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,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/courses/{course}/sections/{section}",
)
.await
}
pub async fn delete(
&self,
course: &str,
section: &str,
params: DeleteParams,
) -> Result<SdkDeleteCourseSectionResponseValue200ApplicationJson, Error> {
self.delete_with_options(course, section, params, None)
.await
}
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)
}
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,
¶ms,
options,
"DELETE /v2/courses/{course}/sections/{section}",
)
.await
}
pub async fn reorder(
&self,
course: &str,
params: ReorderParams,
) -> Result<SdkReorderCourseSectionsResponseValue200ApplicationJson, 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<SdkReorderCourseSectionsResponseValue200ApplicationJson, 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<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,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/courses/{course}/sections/reorder",
)
.await
}
}