Skip to main content

bitwarden_api_api/apis/
notifications_api.rs

1/*
2 * Bitwarden Internal API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: latest
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21    apis::{AuthRequired, ContentType, ResponseContent},
22    models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait NotificationsApi: Send + Sync {
29    /// GET /notifications
30    async fn list<'a>(
31        &self,
32        read_status_filter: Option<bool>,
33        deleted_status_filter: Option<bool>,
34        continuation_token: Option<&'a str>,
35        page_size: Option<i32>,
36    ) -> Result<models::NotificationResponseModelListResponseModel, Error<ListError>>;
37
38    /// PATCH /notifications/{id}/delete
39    async fn mark_as_deleted<'a>(&self, id: uuid::Uuid) -> Result<(), Error<MarkAsDeletedError>>;
40
41    /// PATCH /notifications/{id}/read
42    async fn mark_as_read<'a>(&self, id: uuid::Uuid) -> Result<(), Error<MarkAsReadError>>;
43}
44
45pub struct NotificationsApiClient {
46    configuration: Arc<configuration::Configuration>,
47}
48
49impl NotificationsApiClient {
50    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
51        Self { configuration }
52    }
53}
54
55#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
56#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
57impl NotificationsApi for NotificationsApiClient {
58    async fn list<'a>(
59        &self,
60        read_status_filter: Option<bool>,
61        deleted_status_filter: Option<bool>,
62        continuation_token: Option<&'a str>,
63        page_size: Option<i32>,
64    ) -> Result<models::NotificationResponseModelListResponseModel, Error<ListError>> {
65        let local_var_configuration = &self.configuration;
66
67        let local_var_client = &local_var_configuration.client;
68
69        let local_var_uri_str = format!("{}/notifications", local_var_configuration.base_path);
70        let mut local_var_req_builder =
71            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
72
73        if let Some(ref param_value) = read_status_filter {
74            local_var_req_builder =
75                local_var_req_builder.query(&[("readStatusFilter", &param_value.to_string())]);
76        }
77        if let Some(ref param_value) = deleted_status_filter {
78            local_var_req_builder =
79                local_var_req_builder.query(&[("deletedStatusFilter", &param_value.to_string())]);
80        }
81        if let Some(ref param_value) = continuation_token {
82            local_var_req_builder =
83                local_var_req_builder.query(&[("continuationToken", &param_value.to_string())]);
84        }
85        if let Some(ref param_value) = page_size {
86            local_var_req_builder =
87                local_var_req_builder.query(&[("pageSize", &param_value.to_string())]);
88        }
89        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
90
91        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
92    }
93
94    async fn mark_as_deleted<'a>(&self, id: uuid::Uuid) -> Result<(), Error<MarkAsDeletedError>> {
95        let local_var_configuration = &self.configuration;
96
97        let local_var_client = &local_var_configuration.client;
98
99        let local_var_uri_str = format!(
100            "{}/notifications/{id}/delete",
101            local_var_configuration.base_path,
102            id = id
103        );
104        let mut local_var_req_builder =
105            local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
106
107        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
108
109        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
110    }
111
112    async fn mark_as_read<'a>(&self, id: uuid::Uuid) -> Result<(), Error<MarkAsReadError>> {
113        let local_var_configuration = &self.configuration;
114
115        let local_var_client = &local_var_configuration.client;
116
117        let local_var_uri_str = format!(
118            "{}/notifications/{id}/read",
119            local_var_configuration.base_path,
120            id = id
121        );
122        let mut local_var_req_builder =
123            local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
124
125        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
126
127        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
128    }
129}
130
131/// struct for typed errors of method [`NotificationsApi::list`]
132#[derive(Debug, Clone, Serialize, Deserialize)]
133#[serde(untagged)]
134pub enum ListError {
135    UnknownValue(serde_json::Value),
136}
137/// struct for typed errors of method [`NotificationsApi::mark_as_deleted`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum MarkAsDeletedError {
141    UnknownValue(serde_json::Value),
142}
143/// struct for typed errors of method [`NotificationsApi::mark_as_read`]
144#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum MarkAsReadError {
147    UnknownValue(serde_json::Value),
148}