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
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
//! Pings 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::*;
/// `Pings` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct PingsService<'a> {
client: &'a AccountClient,
}
impl<'a> PingsService<'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 Ping with people, or return the one that already holds exactly
/// them.
///
/// The caller is always included. Without `new_group`, an existing active
/// Ping with exactly these people (the oldest, if several) is returned rather
/// than a second one created; with `new_group: true` and more than one other
/// person, a new group is created every time. Either way the answer is
/// `201 Created` with the Ping.
///
/// Answers `403 Forbidden` (`{"error": "Pings have been disabled"}`) when the
/// caller cannot ping, and a bodiless `422` when nobody in the Ping would be a
/// person who can ping.
///
/// `POST /circles.json` — not idempotent, sent exactly once.
pub async fn create(
&self,
body: &CreatePingRequestContent,
) -> Result<CreatePingResponseContent, Error> {
let mut operation = self.client.operation(&routes::CREATE_PING, &[]);
operation.json(body)?;
self.client.send(operation).await
}
/// Get a Ping by its id, which is its bucket's id.
///
/// Answers `403 Forbidden` (`{"error": "Pings have been disabled"}`) when the
/// caller cannot ping, and `404 Not Found` for a bucket that is not a Ping the
/// caller is in.
///
/// `GET /circles/{pingId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn get(&self, ping_id: i64) -> Result<GetPingResponseContent, Error> {
let operation = self.client.operation(&routes::GET_PING, &[&ping_id]);
self.client.send(operation).await
}
/// Get Pings: the caller's active Pings that have a line in them, most
/// recently updated first, in one unpaginated response. Archived Pings, and
/// Pings no one has posted in yet, are not listed; GetPing reads either by id.
///
/// Answers `403 Forbidden` (`{"error": "Pings have been disabled"}`) when the
/// caller cannot ping.
///
/// `GET /circles.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn list(&self) -> Result<ListPingsResponseContent, Error> {
let operation = self.client.operation(&routes::LIST_PINGS, &[]);
self.client.send(operation).await
}
}