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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
//! Checkins 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 `GetAnswersByPerson`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetAnswersByPersonParams {
/// 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>,
}
/// Optional query parameters for `ListAnswers`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListAnswersParams {
/// 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>,
}
/// Optional query parameters for `ListQuestions`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListQuestionsParams {
/// 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>,
}
/// Optional query parameters for `GetQuestionReminders`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetQuestionRemindersParams {
/// 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>,
}
/// `Checkins` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct CheckinsService<'a> {
client: &'a AccountClient,
}
impl<'a> CheckinsService<'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 all people who have answered a question (answerers)
///
/// **Pagination**: Uses Link header (RFC5988). Follow the `next` rel URL
/// to fetch additional pages.
///
/// `GET /questions/{questionId}/answers/by.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn answerers(
&self,
question_id: i64,
) -> Result<Page<ListQuestionAnswerersResponseContent>, Error> {
let operation = self
.client
.operation(&routes::LIST_QUESTION_ANSWERERS, &[&question_id]);
self.client.send_page(operation).await
}
/// Get all answers from a specific person for a question
///
/// **Pagination**: Uses Link header (RFC5988). Follow the `next` rel URL
/// to fetch additional pages.
///
/// `GET /questions/{questionId}/answers/by/{personId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn by_person(
&self,
question_id: i64,
person_id: i64,
params: &GetAnswersByPersonParams,
) -> Result<Page<GetAnswersByPersonResponseContent>, Error> {
let mut operation = self
.client
.operation(&routes::GET_ANSWERS_BY_PERSON, &[&question_id, &person_id]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
/// Create a new answer for a question
///
/// `POST /questions/{questionId}/answers.json` — not idempotent, sent exactly once.
pub async fn create_answer(
&self,
question_id: i64,
body: &QuestionAnswerPayload,
) -> Result<CreateAnswerResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::CREATE_ANSWER, &[&question_id]);
operation.json(body)?;
self.client.send(operation).await
}
/// Create a new question in a questionnaire
///
/// `POST /questionnaires/{questionnaireId}/questions.json` — not idempotent, sent exactly once.
pub async fn create_question(
&self,
questionnaire_id: i64,
body: &CreateQuestionRequestContent,
) -> Result<CreateQuestionResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::CREATE_QUESTION, &[&questionnaire_id]);
operation.json(body)?;
self.client.send(operation).await
}
/// Get a single answer by id
///
/// `GET /question_answers/{answerId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn get_answer(&self, answer_id: i64) -> Result<GetAnswerResponseContent, Error> {
let operation = self.client.operation(&routes::GET_ANSWER, &[&answer_id]);
self.client.send(operation).await
}
/// Get a single question by id
///
/// `GET /questions/{questionId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn get_question(
&self,
question_id: i64,
) -> Result<GetQuestionResponseContent, Error> {
let operation = self
.client
.operation(&routes::GET_QUESTION, &[&question_id]);
self.client.send(operation).await
}
/// Get a questionnaire (automatic check-ins container) by id
///
/// `GET /questionnaires/{questionnaireId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn get_questionnaire(
&self,
questionnaire_id: i64,
) -> Result<GetQuestionnaireResponseContent, Error> {
let operation = self
.client
.operation(&routes::GET_QUESTIONNAIRE, &[&questionnaire_id]);
self.client.send(operation).await
}
/// List all answers for a question
///
/// **Pagination**: Uses Link header (RFC5988). Follow the `next` rel URL
/// to fetch additional pages. X-Total-Count header provides total count.
///
/// `GET /questions/{questionId}/answers.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn list_answers(
&self,
question_id: i64,
params: &ListAnswersParams,
) -> Result<Page<ListAnswersResponseContent>, Error> {
let mut operation = self
.client
.operation(&routes::LIST_ANSWERS, &[&question_id]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
/// List all questions in a questionnaire
///
/// **Pagination**: Uses Link header (RFC5988). Follow the `next` rel URL
/// to fetch additional pages. X-Total-Count header provides total count.
///
/// `GET /questionnaires/{questionnaireId}/questions.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn list_questions(
&self,
questionnaire_id: i64,
params: &ListQuestionsParams,
) -> Result<Page<ListQuestionsResponseContent>, Error> {
let mut operation = self
.client
.operation(&routes::LIST_QUESTIONS, &[&questionnaire_id]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
/// Pause a check-in question (stops sending reminders)
///
/// `POST /questions/{questionId}/pause.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn pause(&self, question_id: i64) -> Result<PauseQuestionResponseContent, Error> {
let operation = self
.client
.operation(&routes::PAUSE_QUESTION, &[&question_id]);
self.client.send(operation).await
}
/// Get pending check-in reminders for the current user
///
/// Returns questions that are pending a response from the authenticated user.
///
/// **Pagination**: Uses Link header (RFC5988). Follow the `next` rel URL
/// to fetch additional pages.
///
/// `GET /my/question_reminders.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn reminders(
&self,
params: &GetQuestionRemindersParams,
) -> Result<Page<GetQuestionRemindersResponseContent>, Error> {
let mut operation = self.client.operation(&routes::GET_QUESTION_REMINDERS, &[]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
/// Resume a paused check-in question (resumes sending reminders)
///
/// `DELETE /questions/{questionId}/pause.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn resume(&self, question_id: i64) -> Result<ResumeQuestionResponseContent, Error> {
let operation = self
.client
.operation(&routes::RESUME_QUESTION, &[&question_id]);
self.client.send(operation).await
}
/// Update an existing answer
///
/// `PUT /question_answers/{answerId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn update_answer(
&self,
answer_id: i64,
body: &QuestionAnswerUpdatePayload,
) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::UPDATE_ANSWER, &[&answer_id]);
operation.json(body)?;
self.client.send_unit(operation).await
}
/// Update notification settings for a check-in question
///
/// `PUT /questions/{questionId}/notification_settings.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn update_notification_settings(
&self,
question_id: i64,
body: &UpdateQuestionNotificationSettingsRequestContent,
) -> Result<UpdateQuestionNotificationSettingsResponseContent, Error> {
let mut operation = self.client.operation(
&routes::UPDATE_QUESTION_NOTIFICATION_SETTINGS,
&[&question_id],
);
operation.json(body)?;
self.client.send(operation).await
}
/// Update an existing question's title, schedule or both. A schedule replaces the whole schedule, so send every part of it: one without frequency or time_of_day is refused, and one without start_date re-anchors the recurrence on today. Pausing and resuming are PauseQuestion and ResumeQuestion.
///
/// `PUT /questions/{questionId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn update_question(
&self,
question_id: i64,
body: &UpdateQuestionRequestContent,
) -> Result<UpdateQuestionResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::UPDATE_QUESTION, &[&question_id]);
operation.json(body)?;
self.client.send(operation).await
}
}