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
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
//! Folders 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::*;
/// `Folders` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct FoldersService<'a> {
client: &'a AccountClient,
}
impl<'a> FoldersService<'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 folder for the authenticated user and file the given projects into it.
///
/// Returns 201 with the new folder and its expanded `projects`, placed at the
/// top of the home screen. Filing an all-access project the user has not joined
/// **grants** them access to it. Every id is preflighted: if any is archived,
/// trashed, or an invitation-only project the user is not on, the whole request
/// fails with 404 and nothing is created — there is no partial success.
///
/// `POST /stacks.json` — not idempotent, sent exactly once.
pub async fn create_folder(
&self,
body: &CreateFolderRequestContent,
) -> Result<CreateFolderResponseContent, Error> {
let mut operation = self.client.operation(&routes::CREATE_FOLDER, &[]);
operation.json(body)?;
self.client.send(operation).await
}
/// Delete a folder and unpin its projects from the home screen (returns 204 No Content).
///
/// The projects themselves are not deleted and are not moved back out onto the
/// home screen; they simply stop appearing there until pinned again.
///
/// `DELETE /stacks/{folderId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn delete_folder(&self, folder_id: i64) -> Result<(), Error> {
let operation = self.client.operation(&routes::DELETE_FOLDER, &[&folder_id]);
self.client.send_unit(operation).await
}
/// Get one folder, with the projects grouped inside it expanded under `projects`.
///
/// `GET /stacks/{folderId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn get_folder(&self, folder_id: i64) -> Result<GetFolderResponseContent, Error> {
let operation = self.client.operation(&routes::GET_FOLDER, &[&folder_id]);
self.client.send(operation).await
}
/// List the authenticated user's folders in home-screen order.
///
/// Returns a bare array with no pagination envelope. Items are the base folder
/// shape: they carry `bucket_ids` but **not** the expanded `projects`, which
/// only the single-folder operations return.
///
/// `GET /stacks.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn list_folders(&self) -> Result<ListFoldersResponseContent, Error> {
let operation = self.client.operation(&routes::LIST_FOLDERS, &[]);
self.client.send(operation).await
}
/// Rename a folder.
///
/// `name` is the only writable attribute; a folder's projects, ordering, and
/// image are managed elsewhere and an image parameter sent here is ignored.
///
/// `PUT /stacks/{folderId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn update_folder(
&self,
folder_id: i64,
body: &UpdateFolderRequestContent,
) -> Result<UpdateFolderResponseContent, Error> {
let mut operation = self.client.operation(&routes::UPDATE_FOLDER, &[&folder_id]);
operation.json(body)?;
self.client.send(operation).await
}
}