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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
//! Cards 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 `ListCards`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListCardsParams {
/// 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>,
}
/// `Cards` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct CardsService<'a> {
client: &'a AccountClient,
}
impl<'a> CardsService<'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
}
/// Create a card in a column
///
/// `POST /card_tables/lists/{columnId}/cards.json` — not idempotent, sent exactly once.
pub async fn create(
&self,
column_id: i64,
body: &CreateCardRequestContent,
) -> Result<CreateCardResponseContent, Error> {
let mut operation = self.client.operation(&routes::CREATE_CARD, &[&column_id]);
operation.json(body)?;
self.client.send(operation).await
}
/// Get a card by ID
///
/// `GET /card_tables/cards/{cardId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn get(&self, card_id: i64) -> Result<GetCardResponseContent, Error> {
let operation = self.client.operation(&routes::GET_CARD, &[&card_id]);
self.client.send(operation).await
}
/// List cards in a column
///
/// **Pagination**: Uses Link header (RFC5988). Follow the `next` rel URL
/// to fetch additional pages. X-Total-Count header provides total count.
///
/// `GET /card_tables/lists/{columnId}/cards.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn list(
&self,
column_id: i64,
params: &ListCardsParams,
) -> Result<Page<ListCardsResponseContent>, Error> {
let mut operation = self.client.operation(&routes::LIST_CARDS, &[&column_id]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
/// Move a card to any column in its project, including on another card table there, or through a linked wormhole to another project (queued: the card gets a new id, and position, if sent, must still be positive but doesn't set placement).
///
/// `column_id` may be any column in the card's project, including a column on
/// another card table in the same project; the card moves there directly, with
/// no wormhole needed. To send the card to another project, pass the id of a
/// linked wormhole (`linked: true`) the card table already has, listed in
/// GetCardTable's `wormholes`; an unlinked or unreachable one returns not found.
/// A move through a wormhole is queued: the card arrives under a new id and its
/// old id then returns not found. `position` does not control where it lands,
/// but if supplied it must still be a positive integer.
///
/// No wormhole is needed to move a card to another project's card table either:
/// MoveRecording with that card table as `filing_destination_id` moves it, and
/// the card lands in Triage, or in Done if it is completed. Create a wormhole
/// only when the card table should keep that shortcut.
///
/// `POST /card_tables/cards/{cardId}/moves.json` — not idempotent, sent exactly once.
pub async fn move_card(
&self,
card_id: i64,
body: &MoveCardRequestContent,
) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::MOVE_CARD, &[&card_id]);
operation.json(body)?;
self.client.send_unit(operation).await
}
/// Update an existing card
///
/// `PUT /card_tables/cards/{cardId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn update_verbatim(
&self,
card_id: i64,
body: &UpdateCardRequestContent,
) -> Result<UpdateCardResponseContent, Error> {
let mut operation = self.client.operation(&routes::UPDATE_CARD, &[&card_id]);
operation.json(body)?;
self.client.send(operation).await
}
}