fizzy_sdk/generated/services/
boards.rs1use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7use crate::pagination::Page;
8
9#[derive(Debug, Clone, Default, PartialEq)]
11pub struct ListBoardAccessesParams {
12 pub page: Option<i32>,
14}
15
16pub struct BoardsService<'a> {
18 scope: Scope<'a>,
19}
20
21impl<'a> BoardsService<'a> {
22 pub(crate) fn new(scope: Scope<'a>) -> Self {
23 Self { scope }
24 }
25
26 pub fn scope(&self) -> &Scope<'a> {
28 &self.scope
29 }
30
31 pub async fn create(&self, body: &CreateBoardRequestContent) -> Result<Board, Error> {
35 let mut operation = self.scope.operation(&routes::CREATE_BOARD, &[])?;
36 operation.json(body)?;
37 self.scope.client().send(operation).await
38 }
39
40 pub async fn delete(&self, board_id: &str) -> Result<(), Error> {
44 let mut operation = self.scope.operation(&routes::DELETE_BOARD, &[&board_id])?;
45 operation.resource_id(board_id);
46 self.scope.client().send_unit(operation).await
47 }
48
49 pub async fn get(&self, board_id: &str) -> Result<Board, Error> {
53 let mut operation = self.scope.operation(&routes::GET_BOARD, &[&board_id])?;
54 operation.resource_id(board_id);
55 self.scope.client().send(operation).await
56 }
57
58 pub async fn list(&self) -> Result<Page<Vec<Board>>, Error> {
64 let operation = self.scope.operation(&routes::LIST_BOARDS, &[])?;
65 self.scope.client().send_page(operation).await
66 }
67
68 pub async fn list_board_accesses(
72 &self,
73 board_id: &str,
74 params: &ListBoardAccessesParams,
75 ) -> Result<BoardAccesses, Error> {
76 let mut operation = self
77 .scope
78 .operation(&routes::LIST_BOARD_ACCESSES, &[&board_id])?;
79 operation.resource_id(board_id);
80 operation.query_optional("page", params.page.as_ref());
81 self.scope.client().send(operation).await
82 }
83
84 pub async fn list_closed(&self, board_id: &str) -> Result<Page<Vec<Card>>, Error> {
90 let mut operation = self
91 .scope
92 .operation(&routes::LIST_CLOSED_CARDS, &[&board_id])?;
93 operation.resource_id(board_id);
94 self.scope.client().send_page(operation).await
95 }
96
97 pub async fn list_postponed(&self, board_id: &str) -> Result<Page<Vec<Card>>, Error> {
103 let mut operation = self
104 .scope
105 .operation(&routes::LIST_POSTPONED_CARDS, &[&board_id])?;
106 operation.resource_id(board_id);
107 self.scope.client().send_page(operation).await
108 }
109
110 pub async fn list_stream(&self, board_id: &str) -> Result<Page<Vec<Card>>, Error> {
116 let mut operation = self
117 .scope
118 .operation(&routes::LIST_STREAM_CARDS, &[&board_id])?;
119 operation.resource_id(board_id);
120 self.scope.client().send_page(operation).await
121 }
122
123 pub async fn publish(&self, board_id: &str) -> Result<(), Error> {
127 let mut operation = self.scope.operation(&routes::PUBLISH_BOARD, &[&board_id])?;
128 operation.resource_id(board_id);
129 self.scope.client().send_unit(operation).await
130 }
131
132 pub async fn unpublish(&self, board_id: &str) -> Result<(), Error> {
136 let mut operation = self
137 .scope
138 .operation(&routes::UNPUBLISH_BOARD, &[&board_id])?;
139 operation.resource_id(board_id);
140 self.scope.client().send_unit(operation).await
141 }
142
143 pub async fn update(
147 &self,
148 board_id: &str,
149 body: &UpdateBoardRequestContent,
150 ) -> Result<Board, Error> {
151 let mut operation = self.scope.operation(&routes::UPDATE_BOARD, &[&board_id])?;
152 operation.resource_id(board_id);
153 operation.json(body)?;
154 self.scope.client().send(operation).await
155 }
156
157 pub async fn update_entropy(
161 &self,
162 board_id: &str,
163 body: &UpdateBoardEntropyRequestContent,
164 ) -> Result<Board, Error> {
165 let mut operation = self
166 .scope
167 .operation(&routes::UPDATE_BOARD_ENTROPY, &[&board_id])?;
168 operation.resource_id(board_id);
169 operation.json(body)?;
170 self.scope.client().send(operation).await
171 }
172
173 pub async fn update_involvement(
177 &self,
178 board_id: &str,
179 body: &UpdateBoardInvolvementRequestContent,
180 ) -> Result<(), Error> {
181 let mut operation = self
182 .scope
183 .operation(&routes::UPDATE_BOARD_INVOLVEMENT, &[&board_id])?;
184 operation.resource_id(board_id);
185 operation.json(body)?;
186 self.scope.client().send_unit(operation).await
187 }
188}