hey_sdk/generated/services/
journal.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 ListJournalEntriesParams {
14 pub page: Option<String>,
15 pub q: Option<String>,
16}
17
18pub struct Journal<'a> {
19 client: &'a Client,
20}
21
22impl<'a> Journal<'a> {
23 pub(crate) fn new(client: &'a Client) -> Self {
24 Self { client }
25 }
26
27 pub fn client(&self) -> &'a Client {
29 self.client
30 }
31
32 pub async fn get_entry(&self, day: &str) -> Result<GetJournalEntryResponseContent, Error> {
34 let operation = self.client.operation(&routes::GET_JOURNAL_ENTRY, &[&day]);
35 self.client.send(operation).await
36 }
37
38 pub async fn list_entries(
41 &self,
42 params: &ListJournalEntriesParams,
43 ) -> Result<Page<ListJournalEntriesResponseContent>, Error> {
44 let mut operation = self.client.operation(&routes::LIST_JOURNAL_ENTRIES, &[]);
45 operation.query_optional("page", params.page.as_ref());
46 operation.query_optional("q", params.q.as_ref());
47 self.client.send_page(operation).await
48 }
49
50 pub async fn update_entry(
55 &self,
56 day: &str,
57 body: &UpdateJournalEntryRequestContent,
58 ) -> Result<UpdateJournalEntryResponseContent, Error> {
59 let mut operation = self
60 .client
61 .operation(&routes::UPDATE_JOURNAL_ENTRY, &[&day]);
62 operation.json(body)?;
63 self.client.send(operation).await
64 }
65}