#![allow(
clippy::too_many_arguments,
clippy::wildcard_imports,
clippy::doc_markdown
)]
use crate::client::AccountClient;
use crate::error::Error;
use crate::generated::routes;
#[allow(unused_imports)]
use crate::generated::types::*;
use crate::pagination::Page;
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListEventBoostsParams {
pub page: Option<i32>,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListRecordingBoostsParams {
pub page: Option<i32>,
}
#[derive(Debug, Clone, Copy)]
pub struct BoostsService<'a> {
client: &'a AccountClient,
}
impl<'a> BoostsService<'a> {
pub(crate) fn new(client: &'a AccountClient) -> Self {
Self { client }
}
pub fn client(&self) -> &'a AccountClient {
self.client
}
pub async fn create_for_event(
&self,
recording_id: i64,
event_id: i64,
body: &CreateEventBoostRequestContent,
) -> Result<CreateEventBoostResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::CREATE_EVENT_BOOST, &[&recording_id, &event_id]);
operation.json(body)?;
self.client.send(operation).await
}
pub async fn create_for_recording(
&self,
recording_id: i64,
body: &CreateRecordingBoostRequestContent,
) -> Result<CreateRecordingBoostResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::CREATE_RECORDING_BOOST, &[&recording_id]);
operation.json(body)?;
self.client.send(operation).await
}
pub async fn delete(&self, boost_id: i64) -> Result<(), Error> {
let operation = self.client.operation(&routes::DELETE_BOOST, &[&boost_id]);
self.client.send_unit(operation).await
}
pub async fn get(&self, boost_id: i64) -> Result<GetBoostResponseContent, Error> {
let operation = self.client.operation(&routes::GET_BOOST, &[&boost_id]);
self.client.send(operation).await
}
pub async fn list_for_event(
&self,
recording_id: i64,
event_id: i64,
params: &ListEventBoostsParams,
) -> Result<Page<ListEventBoostsResponseContent>, Error> {
let mut operation = self
.client
.operation(&routes::LIST_EVENT_BOOSTS, &[&recording_id, &event_id]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
pub async fn list_for_recording(
&self,
recording_id: i64,
params: &ListRecordingBoostsParams,
) -> Result<Page<ListRecordingBoostsResponseContent>, Error> {
let mut operation = self
.client
.operation(&routes::LIST_RECORDING_BOOSTS, &[&recording_id]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
}