bitwarden_api_api/apis/
notifications_api.rs1use reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum NotificationsGetError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum NotificationsIdDeletePatchError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum NotificationsIdReadPatchError {
35 UnknownValue(serde_json::Value),
36}
37
38pub async fn notifications_get(
39 configuration: &configuration::Configuration,
40 read_status_filter: Option<bool>,
41 deleted_status_filter: Option<bool>,
42 continuation_token: Option<&str>,
43 page_size: Option<i32>,
44) -> Result<models::NotificationResponseModelListResponseModel, Error<NotificationsGetError>> {
45 let local_var_configuration = configuration;
46
47 let local_var_client = &local_var_configuration.client;
48
49 let local_var_uri_str = format!("{}/notifications", local_var_configuration.base_path);
50 let mut local_var_req_builder =
51 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
52
53 if let Some(ref local_var_str) = read_status_filter {
54 local_var_req_builder =
55 local_var_req_builder.query(&[("readStatusFilter", &local_var_str.to_string())]);
56 }
57 if let Some(ref local_var_str) = deleted_status_filter {
58 local_var_req_builder =
59 local_var_req_builder.query(&[("deletedStatusFilter", &local_var_str.to_string())]);
60 }
61 if let Some(ref local_var_str) = continuation_token {
62 local_var_req_builder =
63 local_var_req_builder.query(&[("continuationToken", &local_var_str.to_string())]);
64 }
65 if let Some(ref local_var_str) = page_size {
66 local_var_req_builder =
67 local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
68 }
69 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
70 local_var_req_builder =
71 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
72 }
73 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
74 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
75 };
76
77 let local_var_req = local_var_req_builder.build()?;
78 let local_var_resp = local_var_client.execute(local_var_req).await?;
79
80 let local_var_status = local_var_resp.status();
81 let local_var_content = local_var_resp.text().await?;
82
83 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
84 serde_json::from_str(&local_var_content).map_err(Error::from)
85 } else {
86 let local_var_entity: Option<NotificationsGetError> =
87 serde_json::from_str(&local_var_content).ok();
88 let local_var_error = ResponseContent {
89 status: local_var_status,
90 content: local_var_content,
91 entity: local_var_entity,
92 };
93 Err(Error::ResponseError(local_var_error))
94 }
95}
96
97pub async fn notifications_id_delete_patch(
98 configuration: &configuration::Configuration,
99 id: uuid::Uuid,
100) -> Result<(), Error<NotificationsIdDeletePatchError>> {
101 let local_var_configuration = configuration;
102
103 let local_var_client = &local_var_configuration.client;
104
105 let local_var_uri_str = format!(
106 "{}/notifications/{id}/delete",
107 local_var_configuration.base_path,
108 id = crate::apis::urlencode(id.to_string())
109 );
110 let mut local_var_req_builder =
111 local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
112
113 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
114 local_var_req_builder =
115 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
116 }
117 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
118 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
119 };
120
121 let local_var_req = local_var_req_builder.build()?;
122 let local_var_resp = local_var_client.execute(local_var_req).await?;
123
124 let local_var_status = local_var_resp.status();
125 let local_var_content = local_var_resp.text().await?;
126
127 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
128 Ok(())
129 } else {
130 let local_var_entity: Option<NotificationsIdDeletePatchError> =
131 serde_json::from_str(&local_var_content).ok();
132 let local_var_error = ResponseContent {
133 status: local_var_status,
134 content: local_var_content,
135 entity: local_var_entity,
136 };
137 Err(Error::ResponseError(local_var_error))
138 }
139}
140
141pub async fn notifications_id_read_patch(
142 configuration: &configuration::Configuration,
143 id: uuid::Uuid,
144) -> Result<(), Error<NotificationsIdReadPatchError>> {
145 let local_var_configuration = configuration;
146
147 let local_var_client = &local_var_configuration.client;
148
149 let local_var_uri_str = format!(
150 "{}/notifications/{id}/read",
151 local_var_configuration.base_path,
152 id = crate::apis::urlencode(id.to_string())
153 );
154 let mut local_var_req_builder =
155 local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
156
157 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
158 local_var_req_builder =
159 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
160 }
161 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
162 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
163 };
164
165 let local_var_req = local_var_req_builder.build()?;
166 let local_var_resp = local_var_client.execute(local_var_req).await?;
167
168 let local_var_status = local_var_resp.status();
169 let local_var_content = local_var_resp.text().await?;
170
171 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
172 Ok(())
173 } else {
174 let local_var_entity: Option<NotificationsIdReadPatchError> =
175 serde_json::from_str(&local_var_content).ok();
176 let local_var_error = ResponseContent {
177 status: local_var_status,
178 content: local_var_content,
179 entity: local_var_entity,
180 };
181 Err(Error::ResponseError(local_var_error))
182 }
183}