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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
//! Subtasks 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 `ListSubtasks`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListSubtasksParams {
/// 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>,
}
/// `Subtasks` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct SubtasksService<'a> {
client: &'a AccountClient,
}
impl<'a> SubtasksService<'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
}
/// Mark a subtask as completed
///
/// `POST /subtasks/{subtaskId}/completion.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn complete(&self, subtask_id: i64) -> Result<(), Error> {
let operation = self
.client
.operation(&routes::COMPLETE_SUBTASK, &[&subtask_id]);
self.client.send_unit(operation).await
}
/// Create a subtask under a to-do or a card
///
/// Any other recording answers `403 Forbidden`.
///
/// `POST /recordings/{recordingId}/subtasks.json` — not idempotent, sent exactly once.
pub async fn create(
&self,
recording_id: i64,
body: &CreateSubtaskRequestContent,
) -> Result<CreateSubtaskResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::CREATE_SUBTASK, &[&recording_id]);
operation.json(body)?;
self.client.send(operation).await
}
/// Delete a subtask
///
/// On accounts where deleting is limited to admins and the creator, everyone
/// else gets `403 Forbidden`.
///
/// `DELETE /subtasks/{subtaskId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn delete(&self, subtask_id: i64) -> Result<(), Error> {
let operation = self
.client
.operation(&routes::DELETE_SUBTASK, &[&subtask_id]);
self.client.send_unit(operation).await
}
/// Get a subtask by ID
///
/// `GET /subtasks/{subtaskId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn get(&self, subtask_id: i64) -> Result<GetSubtaskResponseContent, Error> {
let operation = self.client.operation(&routes::GET_SUBTASK, &[&subtask_id]);
self.client.send(operation).await
}
/// List a recording's subtasks, in position order
///
/// Only to-dos and cards hold subtasks; check for `subtasks_count` and
/// `subtasks_url` on the parent's JSON.
///
/// **Pagination**: Uses Link header (RFC5988). Follow the `next` rel URL
/// to fetch additional pages. X-Total-Count header provides total count.
///
/// `GET /recordings/{recordingId}/subtasks.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn list(
&self,
recording_id: i64,
params: &ListSubtasksParams,
) -> Result<Page<ListSubtasksResponseContent>, Error> {
let mut operation = self
.client
.operation(&routes::LIST_SUBTASKS, &[&recording_id]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
/// Move a subtask to a new position among its siblings
///
/// `PUT /subtasks/{subtaskId}/position.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn reposition(
&self,
subtask_id: i64,
body: &RepositionSubtaskRequestContent,
) -> Result<(), Error> {
let mut operation = self
.client
.operation(&routes::REPOSITION_SUBTASK, &[&subtask_id]);
operation.json(body)?;
self.client.send_unit(operation).await
}
/// Mark a subtask as not completed
///
/// `DELETE /subtasks/{subtaskId}/completion.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn uncomplete(&self, subtask_id: i64) -> Result<(), Error> {
let operation = self
.client
.operation(&routes::UNCOMPLETE_SUBTASK, &[&subtask_id]);
self.client.send_unit(operation).await
}
/// Update a subtask
///
/// A partial update: every omitted parameter is left unchanged. Clearing a
/// value takes an explicit send — `"due_on": null` clears the due date (an
/// empty string is accepted too, and is what the Ruby, Python and TypeScript
/// SDKs send, since they drop nil, None and undefined from the body);
/// `"assignee_ids": \[\]` removes every assignee. Send at least one parameter:
/// an empty body is refused with `400 Bad Request`.
///
/// `PUT /subtasks/{subtaskId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn update(
&self,
subtask_id: i64,
body: &UpdateSubtaskRequestContent,
) -> Result<UpdateSubtaskResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::UPDATE_SUBTASK, &[&subtask_id]);
operation.json(body)?;
self.client.send(operation).await
}
}