use std::sync::Arc;
use crate::error::Result;
use crate::http::Config;
use crate::types::{
list_query, CreateSegmentOptions, DeleteSegmentResponse, List, ListOptions, Segment,
UpdateSegmentOptions,
};
#[derive(Clone)]
pub struct Segments(pub(crate) Arc<Config>);
impl Segments {
pub async fn create(&self, segment: &CreateSegmentOptions) -> Result<Segment> {
self.0.post(&["segments"], segment, None).await
}
pub async fn get(&self, id: &str) -> Result<Segment> {
self.0.get(&["segments", id], &[]).await
}
pub async fn list(&self, options: Option<&ListOptions>) -> Result<List<Segment>> {
self.0.get(&["segments"], &list_query(options)).await
}
pub async fn update(&self, id: &str, changes: &UpdateSegmentOptions) -> Result<Segment> {
self.0.patch(&["segments", id], changes).await
}
pub async fn delete(&self, id: &str) -> Result<DeleteSegmentResponse> {
self.0.delete(&["segments", id]).await
}
}