Skip to main content

bitwarden_api_api/apis/
push_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 PushApi: Send + Sync {
29    /// PUT /push/add-organization
30    async fn add_organization<'a>(
31        &self,
32        push_update_request_model: Option<models::PushUpdateRequestModel>,
33    ) -> Result<(), Error<AddOrganizationError>>;
34
35    /// POST /push/delete
36    async fn delete<'a>(
37        &self,
38        push_device_request_model: Option<models::PushDeviceRequestModel>,
39    ) -> Result<(), Error<DeleteError>>;
40
41    /// PUT /push/delete-organization
42    async fn delete_organization<'a>(
43        &self,
44        push_update_request_model: Option<models::PushUpdateRequestModel>,
45    ) -> Result<(), Error<DeleteOrganizationError>>;
46
47    /// POST /push/register
48    async fn register<'a>(
49        &self,
50        push_registration_request_model: Option<models::PushRegistrationRequestModel>,
51    ) -> Result<(), Error<RegisterError>>;
52
53    /// POST /push/send
54    async fn send<'a>(
55        &self,
56        json_element_push_send_request_model: Option<models::JsonElementPushSendRequestModel>,
57    ) -> Result<(), Error<SendError>>;
58}
59
60pub struct PushApiClient {
61    configuration: Arc<configuration::Configuration>,
62}
63
64impl PushApiClient {
65    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
66        Self { configuration }
67    }
68}
69
70#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
71#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
72impl PushApi for PushApiClient {
73    async fn add_organization<'a>(
74        &self,
75        push_update_request_model: Option<models::PushUpdateRequestModel>,
76    ) -> Result<(), Error<AddOrganizationError>> {
77        let local_var_configuration = &self.configuration;
78
79        let local_var_client = &local_var_configuration.client;
80
81        let local_var_uri_str = format!(
82            "{}/push/add-organization",
83            local_var_configuration.base_path
84        );
85        let mut local_var_req_builder =
86            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
87
88        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
89        local_var_req_builder = local_var_req_builder.json(&push_update_request_model);
90
91        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
92    }
93
94    async fn delete<'a>(
95        &self,
96        push_device_request_model: Option<models::PushDeviceRequestModel>,
97    ) -> Result<(), Error<DeleteError>> {
98        let local_var_configuration = &self.configuration;
99
100        let local_var_client = &local_var_configuration.client;
101
102        let local_var_uri_str = format!("{}/push/delete", local_var_configuration.base_path);
103        let mut local_var_req_builder =
104            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
105
106        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
107        local_var_req_builder = local_var_req_builder.json(&push_device_request_model);
108
109        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
110    }
111
112    async fn delete_organization<'a>(
113        &self,
114        push_update_request_model: Option<models::PushUpdateRequestModel>,
115    ) -> Result<(), Error<DeleteOrganizationError>> {
116        let local_var_configuration = &self.configuration;
117
118        let local_var_client = &local_var_configuration.client;
119
120        let local_var_uri_str = format!(
121            "{}/push/delete-organization",
122            local_var_configuration.base_path
123        );
124        let mut local_var_req_builder =
125            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
126
127        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
128        local_var_req_builder = local_var_req_builder.json(&push_update_request_model);
129
130        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
131    }
132
133    async fn register<'a>(
134        &self,
135        push_registration_request_model: Option<models::PushRegistrationRequestModel>,
136    ) -> Result<(), Error<RegisterError>> {
137        let local_var_configuration = &self.configuration;
138
139        let local_var_client = &local_var_configuration.client;
140
141        let local_var_uri_str = format!("{}/push/register", local_var_configuration.base_path);
142        let mut local_var_req_builder =
143            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
144
145        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
146        local_var_req_builder = local_var_req_builder.json(&push_registration_request_model);
147
148        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
149    }
150
151    async fn send<'a>(
152        &self,
153        json_element_push_send_request_model: Option<models::JsonElementPushSendRequestModel>,
154    ) -> Result<(), Error<SendError>> {
155        let local_var_configuration = &self.configuration;
156
157        let local_var_client = &local_var_configuration.client;
158
159        let local_var_uri_str = format!("{}/push/send", local_var_configuration.base_path);
160        let mut local_var_req_builder =
161            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
162
163        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
164        local_var_req_builder = local_var_req_builder.json(&json_element_push_send_request_model);
165
166        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
167    }
168}
169
170/// struct for typed errors of method [`PushApi::add_organization`]
171#[derive(Debug, Clone, Serialize, Deserialize)]
172#[serde(untagged)]
173pub enum AddOrganizationError {
174    UnknownValue(serde_json::Value),
175}
176/// struct for typed errors of method [`PushApi::delete`]
177#[derive(Debug, Clone, Serialize, Deserialize)]
178#[serde(untagged)]
179pub enum DeleteError {
180    UnknownValue(serde_json::Value),
181}
182/// struct for typed errors of method [`PushApi::delete_organization`]
183#[derive(Debug, Clone, Serialize, Deserialize)]
184#[serde(untagged)]
185pub enum DeleteOrganizationError {
186    UnknownValue(serde_json::Value),
187}
188/// struct for typed errors of method [`PushApi::register`]
189#[derive(Debug, Clone, Serialize, Deserialize)]
190#[serde(untagged)]
191pub enum RegisterError {
192    UnknownValue(serde_json::Value),
193}
194/// struct for typed errors of method [`PushApi::send`]
195#[derive(Debug, Clone, Serialize, Deserialize)]
196#[serde(untagged)]
197pub enum SendError {
198    UnknownValue(serde_json::Value),
199}