Skip to main content

fizzy_sdk/generated/services/
cards.rs

1// Generated by fizzy-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
2
3use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7use crate::pagination::Page;
8
9/// Optional query parameters for `ListCards`.
10#[derive(Debug, Clone, Default, PartialEq)]
11pub struct ListCardsParams {
12    /// `board_ids[]`.
13    pub board_ids: Option<Vec<String>>,
14    /// `tag_ids[]`.
15    pub tag_ids: Option<Vec<String>>,
16    /// `assignee_ids[]`.
17    pub assignee_ids: Option<Vec<String>>,
18    /// `creator_ids[]`.
19    pub creator_ids: Option<Vec<String>>,
20    /// `closer_ids[]`.
21    pub closer_ids: Option<Vec<String>>,
22    /// `card_ids[]`.
23    pub card_ids: Option<Vec<String>>,
24    /// `column_ids[]`.
25    pub column_ids: Option<Vec<String>>,
26    /// `indexed_by`.
27    pub indexed_by: Option<String>,
28    /// `sorted_by`.
29    pub sorted_by: Option<String>,
30    /// `assignment_status`.
31    pub assignment_status: Option<String>,
32    /// `creation`.
33    pub creation: Option<String>,
34    /// `closure`.
35    pub closure: Option<String>,
36    /// `terms[]`.
37    pub terms: Option<Vec<String>>,
38}
39
40/// Optional query parameters for `ListActivities`.
41#[derive(Debug, Clone, Default, PartialEq)]
42pub struct ListActivitiesParams {
43    /// `creator_ids[]`.
44    pub creator_ids: Option<Vec<String>>,
45    /// `board_ids[]`.
46    pub board_ids: Option<Vec<String>>,
47}
48
49/// The `Cards` operations.
50pub struct CardsService<'a> {
51    scope: Scope<'a>,
52}
53
54impl<'a> CardsService<'a> {
55    pub(crate) fn new(scope: Scope<'a>) -> Self {
56        Self { scope }
57    }
58
59    /// The client and account these operations send through.
60    pub fn scope(&self) -> &Scope<'a> {
61        &self.scope
62    }
63
64    /// `AssignCard` — `POST /{accountId}/cards/{cardNumber}/assignments.json`.
65    ///
66    /// Sent once and never resent.
67    pub async fn assign(
68        &self,
69        card_number: i32,
70        body: &AssignCardRequestContent,
71    ) -> Result<(), Error> {
72        let mut operation = self
73            .scope
74            .operation(&routes::ASSIGN_CARD, &[&card_number])?;
75        operation.resource_id(card_number);
76        operation.json(body)?;
77        self.scope.client().send_unit(operation).await
78    }
79
80    /// `CloseCard` — `POST /{accountId}/cards/{cardNumber}/closure.json`.
81    ///
82    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
83    pub async fn close(&self, card_number: i32) -> Result<(), Error> {
84        let mut operation = self.scope.operation(&routes::CLOSE_CARD, &[&card_number])?;
85        operation.resource_id(card_number);
86        self.scope.client().send_unit(operation).await
87    }
88
89    /// `CreateCard` — `POST /{accountId}/cards.json`.
90    ///
91    /// Sent once and never resent.
92    pub async fn create(&self, body: &CreateCardRequestContent) -> Result<Card, Error> {
93        let mut operation = self.scope.operation(&routes::CREATE_CARD, &[])?;
94        operation.json(body)?;
95        self.scope.client().send(operation).await
96    }
97
98    /// `DeleteCard` — `DELETE /{accountId}/cards/{cardNumber}`.
99    ///
100    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
101    pub async fn delete(&self, card_number: i32) -> Result<(), Error> {
102        let mut operation = self
103            .scope
104            .operation(&routes::DELETE_CARD, &[&card_number])?;
105        operation.resource_id(card_number);
106        self.scope.client().send_unit(operation).await
107    }
108
109    /// `DeleteCardImage` — `DELETE /{accountId}/cards/{cardNumber}/image.json`.
110    ///
111    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
112    pub async fn delete_image(&self, card_number: i32) -> Result<(), Error> {
113        let mut operation = self
114            .scope
115            .operation(&routes::DELETE_CARD_IMAGE, &[&card_number])?;
116        operation.resource_id(card_number);
117        self.scope.client().send_unit(operation).await
118    }
119
120    /// `GetCard` — `GET /{accountId}/cards/{cardNumber}`.
121    ///
122    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
123    pub async fn get(&self, card_number: i32) -> Result<Card, Error> {
124        let mut operation = self.scope.operation(&routes::GET_CARD, &[&card_number])?;
125        operation.resource_id(card_number);
126        self.scope.client().send(operation).await
127    }
128
129    /// `GoldCard` — `POST /{accountId}/cards/{cardNumber}/goldness.json`.
130    ///
131    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
132    pub async fn gold(&self, card_number: i32) -> Result<(), Error> {
133        let mut operation = self.scope.operation(&routes::GOLD_CARD, &[&card_number])?;
134        operation.resource_id(card_number);
135        self.scope.client().send_unit(operation).await
136    }
137
138    /// `ListCards` — `GET /{accountId}/cards.json`.
139    ///
140    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
141    ///
142    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
143    pub async fn list(&self, params: &ListCardsParams) -> Result<Page<Vec<Card>>, Error> {
144        let mut operation = self.scope.operation(&routes::LIST_CARDS, &[])?;
145        operation.query_all_optional("board_ids[]", params.board_ids.as_deref());
146        operation.query_all_optional("tag_ids[]", params.tag_ids.as_deref());
147        operation.query_all_optional("assignee_ids[]", params.assignee_ids.as_deref());
148        operation.query_all_optional("creator_ids[]", params.creator_ids.as_deref());
149        operation.query_all_optional("closer_ids[]", params.closer_ids.as_deref());
150        operation.query_all_optional("card_ids[]", params.card_ids.as_deref());
151        operation.query_all_optional("column_ids[]", params.column_ids.as_deref());
152        operation.query_optional("indexed_by", params.indexed_by.as_ref());
153        operation.query_optional("sorted_by", params.sorted_by.as_ref());
154        operation.query_optional("assignment_status", params.assignment_status.as_ref());
155        operation.query_optional("creation", params.creation.as_ref());
156        operation.query_optional("closure", params.closure.as_ref());
157        operation.query_all_optional("terms[]", params.terms.as_deref());
158        self.scope.client().send_page(operation).await
159    }
160
161    /// `ListActivities` — `GET /{accountId}/activities.json`.
162    ///
163    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
164    ///
165    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
166    pub async fn list_activities(
167        &self,
168        params: &ListActivitiesParams,
169    ) -> Result<Page<Vec<Activity>>, Error> {
170        let mut operation = self.scope.operation(&routes::LIST_ACTIVITIES, &[])?;
171        operation.query_all_optional("creator_ids[]", params.creator_ids.as_deref());
172        operation.query_all_optional("board_ids[]", params.board_ids.as_deref());
173        self.scope.client().send_page(operation).await
174    }
175
176    /// `ListColumnCards` — `GET /{accountId}/boards/{boardId}/columns/{columnId}/cards.json`.
177    ///
178    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
179    ///
180    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
181    pub async fn list_column_cards(
182        &self,
183        board_id: &str,
184        column_id: &str,
185    ) -> Result<Page<Vec<Card>>, Error> {
186        let mut operation = self
187            .scope
188            .operation(&routes::LIST_COLUMN_CARDS, &[&board_id, &column_id])?;
189        operation.resource_id(board_id);
190        self.scope.client().send_page(operation).await
191    }
192
193    /// `MarkCardRead` — `POST /{accountId}/cards/{cardNumber}/reading.json`.
194    ///
195    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
196    pub async fn mark_read(&self, card_number: i32) -> Result<(), Error> {
197        let mut operation = self
198            .scope
199            .operation(&routes::MARK_CARD_READ, &[&card_number])?;
200        operation.resource_id(card_number);
201        self.scope.client().send_unit(operation).await
202    }
203
204    /// `MarkCardUnread` — `DELETE /{accountId}/cards/{cardNumber}/reading.json`.
205    ///
206    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
207    pub async fn mark_unread(&self, card_number: i32) -> Result<(), Error> {
208        let mut operation = self
209            .scope
210            .operation(&routes::MARK_CARD_UNREAD, &[&card_number])?;
211        operation.resource_id(card_number);
212        self.scope.client().send_unit(operation).await
213    }
214
215    /// `MoveCard` — `PATCH /{accountId}/cards/{cardNumber}/board.json`.
216    ///
217    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
218    pub async fn move_to_board(
219        &self,
220        card_number: i32,
221        body: &MoveCardRequestContent,
222    ) -> Result<Card, Error> {
223        let mut operation = self.scope.operation(&routes::MOVE_CARD, &[&card_number])?;
224        operation.resource_id(card_number);
225        operation.json(body)?;
226        self.scope.client().send(operation).await
227    }
228
229    /// `PinCard` — `POST /{accountId}/cards/{cardNumber}/pin.json`.
230    ///
231    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
232    pub async fn pin(&self, card_number: i32) -> Result<(), Error> {
233        let mut operation = self.scope.operation(&routes::PIN_CARD, &[&card_number])?;
234        operation.resource_id(card_number);
235        self.scope.client().send_unit(operation).await
236    }
237
238    /// `PostponeCard` — `POST /{accountId}/cards/{cardNumber}/not_now.json`.
239    ///
240    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
241    pub async fn postpone(&self, card_number: i32) -> Result<(), Error> {
242        let mut operation = self
243            .scope
244            .operation(&routes::POSTPONE_CARD, &[&card_number])?;
245        operation.resource_id(card_number);
246        self.scope.client().send_unit(operation).await
247    }
248
249    /// `PublishCard` — `POST /{accountId}/cards/{cardNumber}/publish.json`.
250    ///
251    /// Sent once and never resent.
252    pub async fn publish(&self, card_number: i32) -> Result<(), Error> {
253        let mut operation = self
254            .scope
255            .operation(&routes::PUBLISH_CARD, &[&card_number])?;
256        operation.resource_id(card_number);
257        self.scope.client().send_unit(operation).await
258    }
259
260    /// `ReopenCard` — `DELETE /{accountId}/cards/{cardNumber}/closure.json`.
261    ///
262    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
263    pub async fn reopen(&self, card_number: i32) -> Result<(), Error> {
264        let mut operation = self
265            .scope
266            .operation(&routes::REOPEN_CARD, &[&card_number])?;
267        operation.resource_id(card_number);
268        self.scope.client().send_unit(operation).await
269    }
270
271    /// `SelfAssignCard` — `POST /{accountId}/cards/{cardNumber}/self_assignment.json`.
272    ///
273    /// Sent once and never resent.
274    pub async fn self_assign(&self, card_number: i32) -> Result<(), Error> {
275        let mut operation = self
276            .scope
277            .operation(&routes::SELF_ASSIGN_CARD, &[&card_number])?;
278        operation.resource_id(card_number);
279        self.scope.client().send_unit(operation).await
280    }
281
282    /// `TagCard` — `POST /{accountId}/cards/{cardNumber}/taggings.json`.
283    ///
284    /// Sent once and never resent.
285    pub async fn tag(&self, card_number: i32, body: &TagCardRequestContent) -> Result<(), Error> {
286        let mut operation = self.scope.operation(&routes::TAG_CARD, &[&card_number])?;
287        operation.resource_id(card_number);
288        operation.json(body)?;
289        self.scope.client().send_unit(operation).await
290    }
291
292    /// `TriageCard` — `POST /{accountId}/cards/{cardNumber}/triage.json`.
293    ///
294    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
295    pub async fn triage(
296        &self,
297        card_number: i32,
298        body: &TriageCardRequestContent,
299    ) -> Result<(), Error> {
300        let mut operation = self
301            .scope
302            .operation(&routes::TRIAGE_CARD, &[&card_number])?;
303        operation.resource_id(card_number);
304        operation.json(body)?;
305        self.scope.client().send_unit(operation).await
306    }
307
308    /// `UnTriageCard` — `DELETE /{accountId}/cards/{cardNumber}/triage.json`.
309    ///
310    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
311    pub async fn un_triage(&self, card_number: i32) -> Result<(), Error> {
312        let mut operation = self
313            .scope
314            .operation(&routes::UN_TRIAGE_CARD, &[&card_number])?;
315        operation.resource_id(card_number);
316        self.scope.client().send_unit(operation).await
317    }
318
319    /// `UngoldCard` — `DELETE /{accountId}/cards/{cardNumber}/goldness.json`.
320    ///
321    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
322    pub async fn ungold(&self, card_number: i32) -> Result<(), Error> {
323        let mut operation = self
324            .scope
325            .operation(&routes::UNGOLD_CARD, &[&card_number])?;
326        operation.resource_id(card_number);
327        self.scope.client().send_unit(operation).await
328    }
329
330    /// `UnpinCard` — `DELETE /{accountId}/cards/{cardNumber}/pin.json`.
331    ///
332    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
333    pub async fn unpin(&self, card_number: i32) -> Result<(), Error> {
334        let mut operation = self.scope.operation(&routes::UNPIN_CARD, &[&card_number])?;
335        operation.resource_id(card_number);
336        self.scope.client().send_unit(operation).await
337    }
338
339    /// `UnwatchCard` — `DELETE /{accountId}/cards/{cardNumber}/watch.json`.
340    ///
341    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
342    pub async fn unwatch(&self, card_number: i32) -> Result<(), Error> {
343        let mut operation = self
344            .scope
345            .operation(&routes::UNWATCH_CARD, &[&card_number])?;
346        operation.resource_id(card_number);
347        self.scope.client().send_unit(operation).await
348    }
349
350    /// `UpdateCard` — `PATCH /{accountId}/cards/{cardNumber}`.
351    ///
352    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
353    pub async fn update(
354        &self,
355        card_number: i32,
356        body: &UpdateCardRequestContent,
357    ) -> Result<Card, Error> {
358        let mut operation = self
359            .scope
360            .operation(&routes::UPDATE_CARD, &[&card_number])?;
361        operation.resource_id(card_number);
362        operation.json(body)?;
363        self.scope.client().send(operation).await
364    }
365
366    /// `WatchCard` — `POST /{accountId}/cards/{cardNumber}/watch.json`.
367    ///
368    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
369    pub async fn watch(&self, card_number: i32) -> Result<(), Error> {
370        let mut operation = self.scope.operation(&routes::WATCH_CARD, &[&card_number])?;
371        operation.resource_id(card_number);
372        self.scope.client().send_unit(operation).await
373    }
374}