1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
//! MyNotes operations.
#![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::*;
/// `MyNotes` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct MyNotesService<'a> {
client: &'a AccountClient,
}
impl<'a> MyNotesService<'a> {
pub(crate) fn new(client: &'a AccountClient) -> Self {
Self { client }
}
/// The client this service sends through.
pub fn client(&self) -> &'a AccountClient {
self.client
}
/// Get the authenticated user's note — a per-person notebook singleton at
/// /my/notes.json. If the user has not yet written anything, the shape is the
/// same with empty content and null id/created_at/updated_at; the record is
/// created on first update.
///
/// `GET /my/notes.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn get_my_note(&self) -> Result<GetMyNoteResponseContent, Error> {
let operation = self.client.operation(&routes::GET_MY_NOTE, &[]);
self.client.send(operation).await
}
/// Replace the note's content, recording a new revision server-side.
/// The first update also creates the underlying notebook if the user did not
/// have one yet. Returns the updated note. Rejections arrive as a field-keyed
/// 422 ({"errors": {"content": \["can't be blank"\]}}), not the flat {error}
/// body.
///
/// `PUT /my/notes.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn update_my_note(
&self,
body: &UpdateMyNoteRequestContent,
) -> Result<UpdateMyNoteResponseContent, Error> {
let mut operation = self.client.operation(&routes::UPDATE_MY_NOTE, &[]);
operation.json(body)?;
self.client.send(operation).await
}
}