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
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
//! Doors 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::*;
/// `Doors` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct DoorsService<'a> {
client: &'a AccountClient,
}
impl<'a> DoorsService<'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 an external link in a project
/// It goes at the end of the project's External links section. The link's
/// fields go under the `door` key and `visible_to_clients` sits beside it.
/// Omitting `visible_to_clients` keeps the link private to the team, whatever
/// the visibility of the project's other tools; a client caller always creates
/// a client-visible link. An unusable `url` (e.g. a `javascript:` address) is a
/// 422 with Rails' default error body, which names no field. Needs permission
/// to edit the project. The `door\[image\]`
/// thumbnail is multipart-only and not modelled.
///
/// `POST /buckets/{bucketId}/dock/doors.json` — not idempotent, sent exactly once.
pub async fn create(
&self,
bucket_id: i64,
body: &CreateDoorRequestContent,
) -> Result<CreateDoorResponseContent, Error> {
let mut operation = self.client.operation(&routes::CREATE_DOOR, &[&bucket_id]);
operation.json(body)?;
self.client.send(operation).await
}
/// Delete an external link (returns 204 No Content)
/// Its status becomes "deleted" and it leaves the project's External links section. It does not
/// go to the trash: Basecamp permanently destroys it about five days later.
/// Needs permission to edit the project.
///
/// `DELETE /dock/doors/{doorId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn delete(&self, door_id: i64) -> Result<(), Error> {
let operation = self.client.operation(&routes::DELETE_DOOR, &[&door_id]);
self.client.send_unit(operation).await
}
/// Get an external link by id
/// A door hidden from a client, an unknown id, or the id of a recording that is
/// not a door is a 404.
///
/// `GET /dock/doors/{doorId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn get(&self, door_id: i64) -> Result<GetDoorResponseContent, Error> {
let operation = self.client.operation(&routes::GET_DOOR, &[&door_id]);
self.client.send(operation).await
}
/// List the active external links in a project
/// They come in the order they appear in the project's External links section.
/// Not paginated: a project has a handful at most. Clients see only the
/// external links visible to them. Listing needs only access to the project,
/// not permission to edit it.
///
/// `GET /buckets/{bucketId}/dock/doors.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn list(&self, bucket_id: i64) -> Result<ListDoorsResponseContent, Error> {
let operation = self.client.operation(&routes::LIST_DOORS, &[&bucket_id]);
self.client.send(operation).await
}
/// Update an external link
/// A partial update: every field is optional, and those left out keep their
/// values. Omit `door` entirely to change only `visible_to_clients`; omit
/// `visible_to_clients` to keep the current visibility. An unusable `url` is a
/// 422 with Rails' default error body, as for CreateDoor. Needs permission to
/// edit the project.
///
/// `PUT /dock/doors/{doorId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn update(
&self,
door_id: i64,
body: &UpdateDoorRequestContent,
) -> Result<UpdateDoorResponseContent, Error> {
let mut operation = self.client.operation(&routes::UPDATE_DOOR, &[&door_id]);
operation.json(body)?;
self.client.send(operation).await
}
}