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.

//! Drafts 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::*;
use crate::pagination::Page;

/// Optional query parameters for `ListMyDrafts`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListMyDraftsParams {
    /// Page number for paginating through results. Defaults to 1. A positive value selects exactly that page, not a starting offset; see SPEC section 8.
    pub page: Option<i32>,
}

/// `Drafts` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct DraftsService<'a> {
    client: &'a AccountClient,
}

impl<'a> DraftsService<'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
    }

    /// List the current user's drafts across their active projects, most recently
    /// updated first (paginated, capped at 250 like /my/assignments). Five draft
    /// kinds are returned: messages, documents, uploads, client approvals, and
    /// client correspondences. Drafts under archived or trashed projects are
    /// excluded.
    ///
    /// `GET /my/drafts.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn list_my_drafts(
        &self,
        params: &ListMyDraftsParams,
    ) -> Result<Page<ListMyDraftsResponseContent>, Error> {
        let mut operation = self.client.operation(&routes::LIST_MY_DRAFTS, &[]);
        operation.query_optional("page", params.page.as_ref());
        self.client.send_page(operation).await
    }
}