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
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
//! MyNotifications 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::*;
use crate::pagination::Page;
/// Optional query parameters for `GetBubbleUps`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetBubbleUpsParams {
/// Page number. Defaults to 1. A positive value selects exactly that page, not a starting offset; see SPEC section 8.
pub page: Option<i32>,
}
/// Optional query parameters for `GetMyNotifications`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetMyNotificationsParams {
/// Page number for paginating through read items. Defaults to 1. This
/// operation is not auto-paginated in any SDK, so a page is returned as
/// asked for and later pages are not followed.
pub page: Option<i32>,
/// Set to true to cap `bubble_ups` at 2 current bubble-ups and omit the
/// `scheduled_bubble_ups` key entirely. Defaults to false. Use the dedicated
/// bubble-ups endpoint (GetBubbleUps) to page through all current and
/// scheduled bubble-ups.
pub limit_bubble_ups: Option<bool>,
}
/// `MyNotifications` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct MyNotificationsService<'a> {
client: &'a AccountClient,
}
impl<'a> MyNotificationsService<'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
}
/// Get the current user's current and scheduled bubble-ups (paginated, 50 per page).
/// Current bubble-ups are returned first, ordered by most recently bubbled up;
/// scheduled bubble-ups follow, ordered by scheduled bubble-up time. Each item
/// uses the same notification object shape as GetMyNotifications.
///
/// `GET /my/readings/bubble_ups.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn bubble_ups(
&self,
params: &GetBubbleUpsParams,
) -> Result<Page<GetBubbleUpsResponseContent>, Error> {
let mut operation = self.client.operation(&routes::GET_BUBBLE_UPS, &[]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
/// Mark specified items as read
///
/// A batch is capped at 500 readables; a larger one is refused with 422
/// before any per-item work (bc3 `f3437f5c732`).
///
/// `PUT /my/unreads.json` — idempotent; retries up to 2 attempt(s) on 429, 503.
pub async fn mark_as_read(&self, body: &MarkAsReadRequestContent) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::MARK_AS_READ, &[]);
operation.json(body)?;
self.client.send_unit(operation).await
}
/// Get the current user's notifications (the "Hey!" menu in Basecamp 4).
/// Notifications are grouped into unreads, reads, bubble-ups, and
/// scheduled bubble-ups (`memories` remains as an always-empty
/// placeholder on BC5). Reads are paginated (50 per page). Unreads are
/// capped at 100. Bubble-ups are capped per `limit_bubble_ups`.
///
/// `GET /my/readings.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
pub async fn my_notifications(
&self,
params: &GetMyNotificationsParams,
) -> Result<GetMyNotificationsResponseContent, Error> {
let mut operation = self.client.operation(&routes::GET_MY_NOTIFICATIONS, &[]);
operation.query_optional("page", params.page.as_ref());
operation.query_optional("limit_bubble_ups", params.limit_bubble_ups.as_ref());
self.client.send(operation).await
}
}