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
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
//! Boosts 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 `ListEventBoosts`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListEventBoostsParams {
/// 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 `ListRecordingBoosts`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListRecordingBoostsParams {
/// 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>,
}
/// `Boosts` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct BoostsService<'a> {
client: &'a AccountClient,
}
impl<'a> BoostsService<'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 boost on a specific event within a recording. Only boostable events accept one: those whose action is completed, adopted, column_changed or moved_in (their JSON includes boosts_count and boosts_url). Any other event answers 403 Forbidden, as does an event on a recording whose comments are closed; an event on a recording the person cannot see answers 404.
///
/// `POST /recordings/{recordingId}/events/{eventId}/boosts.json` — not idempotent, sent exactly once.
pub async fn create_for_event(
&self,
recording_id: i64,
event_id: i64,
body: &CreateEventBoostRequestContent,
) -> Result<CreateEventBoostResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::CREATE_EVENT_BOOST, &[&recording_id, &event_id]);
operation.json(body)?;
self.client.send(operation).await
}
/// Create a boost on a recording
///
/// `POST /recordings/{recordingId}/boosts.json` — not idempotent, sent exactly once.
pub async fn create_for_recording(
&self,
recording_id: i64,
body: &CreateRecordingBoostRequestContent,
) -> Result<CreateRecordingBoostResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::CREATE_RECORDING_BOOST, &[&recording_id]);
operation.json(body)?;
self.client.send(operation).await
}
/// Delete a boost
///
/// `DELETE /boosts/{boostId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn delete(&self, boost_id: i64) -> Result<(), Error> {
let operation = self.client.operation(&routes::DELETE_BOOST, &[&boost_id]);
self.client.send_unit(operation).await
}
/// Get a single boost
///
/// `GET /boosts/{boostId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn get(&self, boost_id: i64) -> Result<GetBoostResponseContent, Error> {
let operation = self.client.operation(&routes::GET_BOOST, &[&boost_id]);
self.client.send(operation).await
}
/// List boosts on a specific event within a recording. Only boostable events carry boosts: those whose action is completed, adopted, column_changed or moved_in (their JSON includes boosts_count and boosts_url). Any other event answers 403 Forbidden; an event on a recording the person cannot see answers 404.
///
/// `GET /recordings/{recordingId}/events/{eventId}/boosts.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn list_for_event(
&self,
recording_id: i64,
event_id: i64,
params: &ListEventBoostsParams,
) -> Result<Page<ListEventBoostsResponseContent>, Error> {
let mut operation = self
.client
.operation(&routes::LIST_EVENT_BOOSTS, &[&recording_id, &event_id]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
/// List boosts on a recording
///
/// `GET /recordings/{recordingId}/boosts.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn list_for_recording(
&self,
recording_id: i64,
params: &ListRecordingBoostsParams,
) -> Result<Page<ListRecordingBoostsResponseContent>, Error> {
let mut operation = self
.client
.operation(&routes::LIST_RECORDING_BOOSTS, &[&recording_id]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
/// Replace the content of a boost. Only the boost's creator may update it: an
/// admin updating someone else's boost gets 403 Forbidden, as does any caller
/// when comments are closed on the boosted recording. A boost on a deleted
/// recording, or in another account, answers 404. A missing or invalid
/// `content` answers a bodiless 422. There is no bucket-scoped route.
///
/// `PUT /boosts/{boostId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn update(
&self,
boost_id: i64,
body: &UpdateBoostRequestContent,
) -> Result<UpdateBoostResponseContent, Error> {
let mut operation = self.client.operation(&routes::UPDATE_BOOST, &[&boost_id]);
operation.json(body)?;
self.client.send(operation).await
}
}