farcaster_rs/notifications/
get_notifications.rs1use crate::constants::merkle::API_ROOT;
2use crate::types::notifications::notifications::NotificationsRoot;
3use crate::Farcaster;
4use std::error::Error;
5
6impl Farcaster {
7 pub async fn get_notifications(
18 &self,
19 limit: Option<i64>,
20 cursor: Option<&str>,
21 ) -> Result<NotificationsRoot, Box<dyn Error>> {
22 let mut url = format!("{}/v2/mention-and-reply-notifications", API_ROOT);
23
24 if limit.is_some() {
25 url.push_str(format!("&limit={}", limit.unwrap()).as_str())
26 }
27
28 if cursor.is_some() {
29 url.push_str(format!("&cursor={}", cursor.unwrap()).as_str())
30 }
31
32 let notifications_reqwest = &self.reqwest_get(&url).await?;
33
34 let notifications: NotificationsRoot = serde_json::from_str(¬ifications_reqwest)?;
35
36 Ok(notifications)
37 }
38}