#![allow(missing_docs, unreachable_pub, clippy::all, clippy::pedantic)]
use crate::client::Client;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
use crate::pagination::Page;
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetBoxPostingChangesParams {
pub v: Option<String>,
pub page: Option<String>,
pub per_page: Option<String>,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetBundleUnseenPostingsParams {
pub page: Option<String>,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct UnfilePostingsParams {
pub folder_id: Option<i64>,
}
pub struct Postings<'a> {
client: &'a Client,
}
impl<'a> Postings<'a> {
pub(crate) fn new(client: &'a Client) -> Self {
Self { client }
}
pub fn client(&self) -> &'a Client {
self.client
}
pub async fn add_to_box_group(
&self,
body: &AddPostingsToBoxGroupRequestContent,
) -> Result<(), Error> {
let mut operation = self
.client
.operation(&routes::ADD_POSTINGS_TO_BOX_GROUP, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn bubble_up_now(&self, body: &MarkPostingsRequestContent) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::BUBBLE_UP_POSTINGS_NOW, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn cancel_bubble_up(&self, posting_ids: &str) -> Result<(), Error> {
let mut operation = self
.client
.operation(&routes::CANCEL_POSTINGS_BUBBLE_UP, &[]);
operation.query("posting_ids", posting_ids);
self.client.send_unit(operation).await
}
pub async fn create_folder(
&self,
body: &CreateFolderForPostingsRequestContent,
) -> Result<(), Error> {
let mut operation = self
.client
.operation(&routes::CREATE_FOLDER_FOR_POSTINGS, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn file(&self, body: &FilePostingsRequestContent) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::FILE_POSTINGS, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn get_box_changes(
&self,
box_id: i64,
since: &str,
params: &GetBoxPostingChangesParams,
) -> Result<Page<GetBoxPostingChangesResponseContent>, Error> {
let mut operation = self
.client
.operation(&routes::GET_BOX_POSTING_CHANGES, &[&box_id]);
operation.resource_id(box_id);
operation.query("since", since);
operation.query_optional("v", params.v.as_ref());
operation.query_optional("page", params.page.as_ref());
operation.query_optional("per_page", params.per_page.as_ref());
self.client.send_page(operation).await
}
pub async fn get_bundle_unseen(
&self,
posting_id: i64,
params: &GetBundleUnseenPostingsParams,
) -> Result<Page<GetBundleUnseenPostingsResponseContent>, Error> {
let mut operation = self
.client
.operation(&routes::GET_BUNDLE_UNSEEN_POSTINGS, &[&posting_id]);
operation.resource_id(posting_id);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
pub async fn mark_seen(&self, body: &MarkPostingsRequestContent) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::MARK_POSTINGS_SEEN, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn mark_spam(&self, body: &MarkPostingsRequestContent) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::MARK_POSTINGS_SPAM, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn mark_unseen(&self, body: &MarkPostingsRequestContent) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::MARK_POSTINGS_UNSEEN, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn move_postings(&self, body: &MovePostingsRequestContent) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::MOVE_POSTINGS, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn mute(&self, body: &MarkPostingsRequestContent) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::MUTE_POSTINGS, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn remove_from_box_group(&self, posting_ids: &str) -> Result<(), Error> {
let mut operation = self
.client
.operation(&routes::REMOVE_POSTINGS_FROM_BOX_GROUP, &[]);
operation.query("posting_ids", posting_ids);
self.client.send_unit(operation).await
}
pub async fn schedule_bubble_up(
&self,
body: &SchedulePostingsBubbleUpRequestContent,
) -> Result<(), Error> {
let mut operation = self
.client
.operation(&routes::SCHEDULE_POSTINGS_BUBBLE_UP, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn trash(&self, body: &TrashPostingsRequestContent) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::TRASH_POSTINGS, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn unfile(
&self,
posting_ids: &str,
params: &UnfilePostingsParams,
) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::UNFILE_POSTINGS, &[]);
operation.query("posting_ids", posting_ids);
operation.query_optional("folder_id", params.folder_id.as_ref());
self.client.send_unit(operation).await
}
pub async fn unmute(&self, posting_ids: &str) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::UNMUTE_POSTINGS, &[]);
operation.query("posting_ids", posting_ids);
self.client.send_unit(operation).await
}
}