Skip to main content

hey_sdk/generated/services/
postings.rs

1// Generated by hey-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
2
3#![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/// Optional query parameters for `GetBoxPostingChanges`.
12#[derive(Debug, Clone, Default, PartialEq)]
13pub struct GetBoxPostingChangesParams {
14    pub v: Option<String>,
15    pub page: Option<String>,
16    pub per_page: Option<String>,
17}
18
19/// Optional query parameters for `GetBundleUnseenPostings`.
20#[derive(Debug, Clone, Default, PartialEq)]
21pub struct GetBundleUnseenPostingsParams {
22    pub page: Option<String>,
23}
24
25/// Optional query parameters for `UnfilePostings`.
26#[derive(Debug, Clone, Default, PartialEq)]
27pub struct UnfilePostingsParams {
28    pub folder_id: Option<i64>,
29}
30
31pub struct Postings<'a> {
32    client: &'a Client,
33}
34
35impl<'a> Postings<'a> {
36    pub(crate) fn new(client: &'a Client) -> Self {
37        Self { client }
38    }
39
40    /// The client this service sends through.
41    pub fn client(&self) -> &'a Client {
42        self.client
43    }
44
45    /// Add a selection of postings to a Set Aside group
46    pub async fn add_to_box_group(
47        &self,
48        body: &AddPostingsToBoxGroupRequestContent,
49    ) -> Result<(), Error> {
50        let mut operation = self
51            .client
52            .operation(&routes::ADD_POSTINGS_TO_BOX_GROUP, &[]);
53        operation.json(body)?;
54        self.client.send_unit(operation).await
55    }
56
57    /// Bubble a selection of postings up right now
58    pub async fn bubble_up_now(&self, body: &MarkPostingsRequestContent) -> Result<(), Error> {
59        let mut operation = self.client.operation(&routes::BUBBLE_UP_POSTINGS_NOW, &[]);
60        operation.json(body)?;
61        self.client.send_unit(operation).await
62    }
63
64    /// Cancel a scheduled bubble up for a selection of postings
65    pub async fn cancel_bubble_up(&self, posting_ids: &str) -> Result<(), Error> {
66        let mut operation = self
67            .client
68            .operation(&routes::CANCEL_POSTINGS_BUBBLE_UP, &[]);
69        operation.query("posting_ids", posting_ids);
70        self.client.send_unit(operation).await
71    }
72
73    /// Create a folder (label) and file a selection of postings into it
74    pub async fn create_folder(
75        &self,
76        body: &CreateFolderForPostingsRequestContent,
77    ) -> Result<(), Error> {
78        let mut operation = self
79            .client
80            .operation(&routes::CREATE_FOLDER_FOR_POSTINGS, &[]);
81        operation.json(body)?;
82        self.client.send_unit(operation).await
83    }
84
85    /// File a selection of postings into an existing folder (label)
86    pub async fn file(&self, body: &FilePostingsRequestContent) -> Result<(), Error> {
87        let mut operation = self.client.operation(&routes::FILE_POSTINGS, &[]);
88        operation.json(body)?;
89        self.client.send_unit(operation).await
90    }
91
92    /// Read what changed among a box's postings since a point in time.
93    ///
94    /// This is the incremental sync feed the mail clients follow rather than re-reading a
95    /// box. `since` is an ISO 8601 timestamp with milliseconds and is exclusive, and `v` is
96    /// the client's contract version — the server answers 409 when the caller is too far
97    /// behind for an increment to carry the difference, which means read the box in full
98    /// instead. A box's own `posting_changes_url` carries the `since` and `v` to start from,
99    /// and the `Link` header names the next page while one remains and the next `since`
100    /// cursor on the last page.
101    pub async fn get_box_changes(
102        &self,
103        box_id: i64,
104        since: &str,
105        params: &GetBoxPostingChangesParams,
106    ) -> Result<Page<GetBoxPostingChangesResponseContent>, Error> {
107        let mut operation = self
108            .client
109            .operation(&routes::GET_BOX_POSTING_CHANGES, &[&box_id]);
110        operation.resource_id(box_id);
111        operation.query("since", since);
112        operation.query_optional("v", params.v.as_ref());
113        operation.query_optional("page", params.page.as_ref());
114        operation.query_optional("per_page", params.per_page.as_ref());
115        self.client.send_page(operation).await
116    }
117
118    /// List the unseen postings inside a bundle posting.
119    ///
120    /// A bundle posting groups one contact's unseen mail; this is its contents — the member
121    /// postings, newest first, paged by cursor like a box. The posting must be a bundle.
122    pub async fn get_bundle_unseen(
123        &self,
124        posting_id: i64,
125        params: &GetBundleUnseenPostingsParams,
126    ) -> Result<Page<GetBundleUnseenPostingsResponseContent>, Error> {
127        let mut operation = self
128            .client
129            .operation(&routes::GET_BUNDLE_UNSEEN_POSTINGS, &[&posting_id]);
130        operation.resource_id(posting_id);
131        operation.query_optional("page", params.page.as_ref());
132        self.client.send_page(operation).await
133    }
134
135    /// Mark postings as seen
136    pub async fn mark_seen(&self, body: &MarkPostingsRequestContent) -> Result<(), Error> {
137        let mut operation = self.client.operation(&routes::MARK_POSTINGS_SEEN, &[]);
138        operation.json(body)?;
139        self.client.send_unit(operation).await
140    }
141
142    /// Mark a selection of postings as spam.
143    ///
144    /// Over ten postings the server hands the work to a background job, so the effect is
145    /// eventually consistent.
146    pub async fn mark_spam(&self, body: &MarkPostingsRequestContent) -> Result<(), Error> {
147        let mut operation = self.client.operation(&routes::MARK_POSTINGS_SPAM, &[]);
148        operation.json(body)?;
149        self.client.send_unit(operation).await
150    }
151
152    /// Mark postings as unseen
153    pub async fn mark_unseen(&self, body: &MarkPostingsRequestContent) -> Result<(), Error> {
154        let mut operation = self.client.operation(&routes::MARK_POSTINGS_UNSEEN, &[]);
155        operation.json(body)?;
156        self.client.send_unit(operation).await
157    }
158
159    /// Move postings to a box (bulk).
160    /// Mirrors HEY's Postings::MovesController: `posting_ids` plus the target `box_id`
161    /// (an ID from ListBoxes; the box `kind` field identifies imbox, feedbox, asidebox,
162    /// laterbox, trailbox). Responds 204 No Content.
163    pub async fn move_postings(&self, body: &MovePostingsRequestContent) -> Result<(), Error> {
164        let mut operation = self.client.operation(&routes::MOVE_POSTINGS, &[]);
165        operation.json(body)?;
166        self.client.send_unit(operation).await
167    }
168
169    /// Mute postings (bulk) — stop notifications for their threads.
170    /// Mirrors HEY's Postings::MutingsController#create. Responds 201 Created.
171    pub async fn mute(&self, body: &MarkPostingsRequestContent) -> Result<(), Error> {
172        let mut operation = self.client.operation(&routes::MUTE_POSTINGS, &[]);
173        operation.json(body)?;
174        self.client.send_unit(operation).await
175    }
176
177    /// Remove a selection of postings from their Set Aside group
178    pub async fn remove_from_box_group(&self, posting_ids: &str) -> Result<(), Error> {
179        let mut operation = self
180            .client
181            .operation(&routes::REMOVE_POSTINGS_FROM_BOX_GROUP, &[]);
182        operation.query("posting_ids", posting_ids);
183        self.client.send_unit(operation).await
184    }
185
186    /// Schedule a selection of postings to bubble up.
187    ///
188    /// HEY's scheduler takes a `slot` — today, tomorrow, weekend, next_week, surprise_me
189    /// or custom — and a custom slot also carries the `date` (YYYY-MM-DD) to bubble up on,
190    /// at HEY's morning hour. The today slot lands at HEY's evening hour of the current
191    /// day instead, and both hours are UTC over JSON. An unknown slot, or a custom slot
192    /// without a date, is a server error rather than a validation response, so callers
193    /// check both first. Responds 201 Created.
194    pub async fn schedule_bubble_up(
195        &self,
196        body: &SchedulePostingsBubbleUpRequestContent,
197    ) -> Result<(), Error> {
198        let mut operation = self
199            .client
200            .operation(&routes::SCHEDULE_POSTINGS_BUBBLE_UP, &[]);
201        operation.json(body)?;
202        self.client.send_unit(operation).await
203    }
204
205    /// Move postings to the trash (bulk).
206    /// Mirrors HEY's Postings::TrashController. For JSON requests the server treats
207    /// the removal decision as made (shared topics: your access is removed).
208    /// Responds 204 No Content.
209    pub async fn trash(&self, body: &TrashPostingsRequestContent) -> Result<(), Error> {
210        let mut operation = self.client.operation(&routes::TRASH_POSTINGS, &[]);
211        operation.json(body)?;
212        self.client.send_unit(operation).await
213    }
214
215    /// Remove a selection of postings from a folder, or from every folder when folder_id is omitted
216    pub async fn unfile(
217        &self,
218        posting_ids: &str,
219        params: &UnfilePostingsParams,
220    ) -> Result<(), Error> {
221        let mut operation = self.client.operation(&routes::UNFILE_POSTINGS, &[]);
222        operation.query("posting_ids", posting_ids);
223        operation.query_optional("folder_id", params.folder_id.as_ref());
224        self.client.send_unit(operation).await
225    }
226
227    /// Unmute postings (bulk).
228    /// Mirrors HEY's Postings::MutingsController#destroy. `posting_ids` is sent as a
229    /// comma-separated query string because DELETE carries no body. Responds 201 Created.
230    pub async fn unmute(&self, posting_ids: &str) -> Result<(), Error> {
231        let mut operation = self.client.operation(&routes::UNMUTE_POSTINGS, &[]);
232        operation.query("posting_ids", posting_ids);
233        self.client.send_unit(operation).await
234    }
235}