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
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
//! Embeds 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::*;
/// `Embeds` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct EmbedsService<'a> {
client: &'a AccountClient,
}
impl<'a> EmbedsService<'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 embed for a URL, or return the one Basecamp already has for it.
///
/// Answers `200 OK` with the embed either way. A new embed's status is
/// `pending`; get it about once a second until its status is `active` or
/// `not_found`.
///
/// Answers `422` (`{"error": "Basecamp can't embed this URL. Link to it
/// instead."}`) for a URL no provider embeds. Past 100 new embeds in an hour,
/// creating another answers `429` (`{"error": "Too many new embeds. Try again
/// later."}`) with no Retry-After; asking for an embed Basecamp already has
/// still works. That 429 is a verdict for the rest of the hour, not
/// throttling, so this operation declares `retryOn: \[503\]` and the 429
/// surfaces on the first attempt.
///
/// `POST /embeds.json` — idempotent; retries up to 3 attempt(s) on 503.
pub async fn create(
&self,
body: &CreateEmbedRequestContent,
) -> Result<CreateEmbedResponseContent, Error> {
let mut operation = self.client.operation(&routes::CREATE_EMBED, &[]);
operation.json(body)?;
self.client.send(operation).await
}
/// Get an embed by its sgid.
///
/// Answers `404 Not Found` for an sgid that does not name an embed.
///
/// `GET /embeds/{sgid}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn get(&self, sgid: &str) -> Result<GetEmbedResponseContent, Error> {
let operation = self.client.operation(&routes::GET_EMBED, &[&sgid]);
self.client.send(operation).await
}
}