use http::Method;
use crate::generated::endpoints;
use super::{
BytesRequestBuilder, DeleteResponse, JsonRequestBuilder, ListRequestBuilder, Video,
VideoCharacter, VideosResource, encode_path_segment,
};
impl VideosResource {
pub fn create(&self) -> JsonRequestBuilder<Video> {
let endpoint = endpoints::videos::VIDEOS_CREATE;
JsonRequestBuilder::new(
self.client.clone(),
endpoint.id,
Method::POST,
endpoint.template,
)
}
pub fn retrieve(&self, video_id: impl Into<String>) -> JsonRequestBuilder<Video> {
let video_id = encode_path_segment(video_id.into());
let endpoint = endpoints::videos::VIDEOS_RETRIEVE;
JsonRequestBuilder::new(
self.client.clone(),
endpoint.id,
Method::GET,
endpoint.render(&[("video_id", &video_id)]),
)
}
pub fn list(&self) -> ListRequestBuilder<Video> {
let endpoint = endpoints::videos::VIDEOS_LIST;
ListRequestBuilder::new(self.client.clone(), endpoint.id, endpoint.template)
}
pub fn delete(&self, video_id: impl Into<String>) -> JsonRequestBuilder<DeleteResponse> {
let video_id = encode_path_segment(video_id.into());
let endpoint = endpoints::videos::VIDEOS_DELETE;
JsonRequestBuilder::new(
self.client.clone(),
endpoint.id,
Method::DELETE,
endpoint.render(&[("video_id", &video_id)]),
)
}
pub fn edit(&self) -> JsonRequestBuilder<Video> {
let endpoint = endpoints::videos::VIDEOS_EDIT;
JsonRequestBuilder::new(
self.client.clone(),
endpoint.id,
Method::POST,
endpoint.template,
)
}
pub fn extend(&self) -> JsonRequestBuilder<Video> {
let endpoint = endpoints::videos::VIDEOS_EXTEND;
JsonRequestBuilder::new(
self.client.clone(),
endpoint.id,
Method::POST,
endpoint.template,
)
}
pub fn create_character(&self) -> JsonRequestBuilder<VideoCharacter> {
let endpoint = endpoints::videos::VIDEOS_CREATE_CHARACTER;
JsonRequestBuilder::new(
self.client.clone(),
endpoint.id,
Method::POST,
endpoint.template,
)
}
pub fn get_character(
&self,
character_id: impl Into<String>,
) -> JsonRequestBuilder<VideoCharacter> {
let character_id = encode_path_segment(character_id.into());
let endpoint = endpoints::videos::VIDEOS_GET_CHARACTER;
JsonRequestBuilder::new(
self.client.clone(),
endpoint.id,
Method::GET,
endpoint.render(&[("character_id", &character_id)]),
)
}
pub fn download_content(&self, video_id: impl Into<String>) -> BytesRequestBuilder {
let video_id = encode_path_segment(video_id.into());
let endpoint = endpoints::videos::VIDEOS_DOWNLOAD_CONTENT;
BytesRequestBuilder::new(
self.client.clone(),
endpoint.id,
Method::GET,
endpoint.render(&[("video_id", &video_id)]),
)
}
pub fn remix(&self, video_id: impl Into<String>) -> JsonRequestBuilder<Video> {
let video_id = encode_path_segment(video_id.into());
let endpoint = endpoints::videos::VIDEOS_REMIX;
JsonRequestBuilder::new(
self.client.clone(),
endpoint.id,
Method::POST,
endpoint.render(&[("video_id", &video_id)]),
)
}
}