hey_sdk/generated/services/
entries.rs1#![allow(missing_docs, unreachable_pub, clippy::all, clippy::pedantic)]
4
5use crate::client::Client;
6use crate::error::Error;
7use crate::generated::routes;
8use crate::generated::types::*;
9use crate::pagination::Page;
10
11#[derive(Debug, Clone, Default, PartialEq)]
13pub struct ListDraftsParams {
14 pub page: Option<String>,
15}
16
17pub struct Entries<'a> {
18 client: &'a Client,
19}
20
21impl<'a> Entries<'a> {
22 pub(crate) fn new(client: &'a Client) -> Self {
23 Self { client }
24 }
25
26 pub fn client(&self) -> &'a Client {
28 self.client
29 }
30
31 pub async fn create_reply(
33 &self,
34 entry_id: i64,
35 body: &CreateReplyRequestContent,
36 ) -> Result<(), Error> {
37 let mut operation = self.client.operation(&routes::CREATE_REPLY, &[&entry_id]);
38 operation.resource_id(entry_id);
39 operation.json(body)?;
40 self.client.send_unit(operation).await
41 }
42
43 pub async fn delete_draft(&self, entry_id: i64) -> Result<(), Error> {
46 let mut operation = self.client.operation(&routes::DELETE_DRAFT, &[&entry_id]);
47 operation.resource_id(entry_id);
48 self.client.send_unit(operation).await
49 }
50
51 pub async fn list_drafts(
53 &self,
54 params: &ListDraftsParams,
55 ) -> Result<Page<ListDraftsResponseContent>, Error> {
56 let mut operation = self.client.operation(&routes::LIST_DRAFTS, &[]);
57 operation.query_optional("page", params.page.as_ref());
58 self.client.send_page(operation).await
59 }
60
61 pub async fn mark_spam(&self, entry_id: i64) -> Result<(), Error> {
63 let mut operation = self
64 .client
65 .operation(&routes::MARK_ENTRY_SPAM, &[&entry_id]);
66 operation.resource_id(entry_id);
67 self.client.send_unit(operation).await
68 }
69
70 pub async fn new_forward(
73 &self,
74 entry_id: i64,
75 ) -> Result<NewEntryForwardResponseContent, Error> {
76 let mut operation = self
77 .client
78 .operation(&routes::NEW_ENTRY_FORWARD, &[&entry_id]);
79 operation.resource_id(entry_id);
80 self.client.send(operation).await
81 }
82
83 pub async fn new_reply(&self, entry_id: i64) -> Result<NewEntryReplyResponseContent, Error> {
87 let mut operation = self
88 .client
89 .operation(&routes::NEW_ENTRY_REPLY, &[&entry_id]);
90 operation.resource_id(entry_id);
91 self.client.send(operation).await
92 }
93}