basecamp-sdk 0.38.0

Official client for Basecamp - https://basecamp.com
Documentation
// 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
    }
}