Skip to main content

ark_rest/apis/
wallet_initializer_service_api.rs

1/*
2 * Ark API
3 *
4 * Combined Ark Service, Indexer, Admin, Signer Manager, and Wallet API
5 *
6 * The version of the OpenAPI document: 1.0.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::configuration;
12use super::ContentType;
13use super::Error;
14use crate::apis::ResponseContent;
15use crate::models;
16use reqwest;
17use serde::de::Error as _;
18use serde::Deserialize;
19use serde::Serialize;
20
21/// struct for typed errors of method [`wallet_initializer_service_create`]
22#[derive(Debug, Clone, Serialize, Deserialize)]
23#[serde(untagged)]
24pub enum WalletInitializerServiceCreateError {
25    DefaultResponse(models::Status),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`wallet_initializer_service_gen_seed`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum WalletInitializerServiceGenSeedError {
33    DefaultResponse(models::Status),
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`wallet_initializer_service_get_status`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum WalletInitializerServiceGetStatusError {
41    DefaultResponse(models::Status),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`wallet_initializer_service_restore`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum WalletInitializerServiceRestoreError {
49    DefaultResponse(models::Status),
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`wallet_initializer_service_unlock`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum WalletInitializerServiceUnlockError {
57    DefaultResponse(models::Status),
58    UnknownValue(serde_json::Value),
59}
60
61pub async fn wallet_initializer_service_create(
62    configuration: &configuration::Configuration,
63    create_request: models::CreateRequest,
64) -> Result<serde_json::Value, Error<WalletInitializerServiceCreateError>> {
65    // add a prefix to parameters to efficiently prevent name collisions
66    let p_create_request = create_request;
67
68    let uri_str = format!("{}/v1/admin/wallet/create", configuration.base_path);
69    let mut req_builder = configuration
70        .client
71        .request(reqwest::Method::POST, &uri_str);
72
73    if let Some(ref user_agent) = configuration.user_agent {
74        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
75    }
76    req_builder = req_builder.json(&p_create_request);
77
78    let req = req_builder.build()?;
79    let resp = configuration.client.execute(req).await?;
80
81    let status = resp.status();
82    let content_type = resp
83        .headers()
84        .get("content-type")
85        .and_then(|v| v.to_str().ok())
86        .unwrap_or("application/octet-stream");
87    let content_type = super::ContentType::from(content_type);
88
89    if !status.is_client_error() && !status.is_server_error() {
90        let content = resp.text().await?;
91        match content_type {
92            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
93            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
94            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
95        }
96    } else {
97        let content = resp.text().await?;
98        let entity: Option<WalletInitializerServiceCreateError> =
99            serde_json::from_str(&content).ok();
100        Err(Error::ResponseError(ResponseContent {
101            status,
102            content,
103            entity,
104        }))
105    }
106}
107
108pub async fn wallet_initializer_service_gen_seed(
109    configuration: &configuration::Configuration,
110) -> Result<models::GenSeedResponse, Error<WalletInitializerServiceGenSeedError>> {
111    let uri_str = format!("{}/v1/admin/wallet/seed", configuration.base_path);
112    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
113
114    if let Some(ref user_agent) = configuration.user_agent {
115        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
116    }
117
118    let req = req_builder.build()?;
119    let resp = configuration.client.execute(req).await?;
120
121    let status = resp.status();
122    let content_type = resp
123        .headers()
124        .get("content-type")
125        .and_then(|v| v.to_str().ok())
126        .unwrap_or("application/octet-stream");
127    let content_type = super::ContentType::from(content_type);
128
129    if !status.is_client_error() && !status.is_server_error() {
130        let content = resp.text().await?;
131        match content_type {
132            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
133            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GenSeedResponse`"))),
134            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GenSeedResponse`")))),
135        }
136    } else {
137        let content = resp.text().await?;
138        let entity: Option<WalletInitializerServiceGenSeedError> =
139            serde_json::from_str(&content).ok();
140        Err(Error::ResponseError(ResponseContent {
141            status,
142            content,
143            entity,
144        }))
145    }
146}
147
148pub async fn wallet_initializer_service_get_status(
149    configuration: &configuration::Configuration,
150) -> Result<models::GetStatusResponse, Error<WalletInitializerServiceGetStatusError>> {
151    let uri_str = format!("{}/v1/admin/wallet/status", configuration.base_path);
152    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
153
154    if let Some(ref user_agent) = configuration.user_agent {
155        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
156    }
157
158    let req = req_builder.build()?;
159    let resp = configuration.client.execute(req).await?;
160
161    let status = resp.status();
162    let content_type = resp
163        .headers()
164        .get("content-type")
165        .and_then(|v| v.to_str().ok())
166        .unwrap_or("application/octet-stream");
167    let content_type = super::ContentType::from(content_type);
168
169    if !status.is_client_error() && !status.is_server_error() {
170        let content = resp.text().await?;
171        match content_type {
172            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
173            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetStatusResponse`"))),
174            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetStatusResponse`")))),
175        }
176    } else {
177        let content = resp.text().await?;
178        let entity: Option<WalletInitializerServiceGetStatusError> =
179            serde_json::from_str(&content).ok();
180        Err(Error::ResponseError(ResponseContent {
181            status,
182            content,
183            entity,
184        }))
185    }
186}
187
188pub async fn wallet_initializer_service_restore(
189    configuration: &configuration::Configuration,
190    restore_request: models::RestoreRequest,
191) -> Result<serde_json::Value, Error<WalletInitializerServiceRestoreError>> {
192    // add a prefix to parameters to efficiently prevent name collisions
193    let p_restore_request = restore_request;
194
195    let uri_str = format!("{}/v1/admin/wallet/restore", configuration.base_path);
196    let mut req_builder = configuration
197        .client
198        .request(reqwest::Method::POST, &uri_str);
199
200    if let Some(ref user_agent) = configuration.user_agent {
201        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
202    }
203    req_builder = req_builder.json(&p_restore_request);
204
205    let req = req_builder.build()?;
206    let resp = configuration.client.execute(req).await?;
207
208    let status = resp.status();
209    let content_type = resp
210        .headers()
211        .get("content-type")
212        .and_then(|v| v.to_str().ok())
213        .unwrap_or("application/octet-stream");
214    let content_type = super::ContentType::from(content_type);
215
216    if !status.is_client_error() && !status.is_server_error() {
217        let content = resp.text().await?;
218        match content_type {
219            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
220            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
221            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
222        }
223    } else {
224        let content = resp.text().await?;
225        let entity: Option<WalletInitializerServiceRestoreError> =
226            serde_json::from_str(&content).ok();
227        Err(Error::ResponseError(ResponseContent {
228            status,
229            content,
230            entity,
231        }))
232    }
233}
234
235pub async fn wallet_initializer_service_unlock(
236    configuration: &configuration::Configuration,
237    unlock_request: models::UnlockRequest,
238) -> Result<serde_json::Value, Error<WalletInitializerServiceUnlockError>> {
239    // add a prefix to parameters to efficiently prevent name collisions
240    let p_unlock_request = unlock_request;
241
242    let uri_str = format!("{}/v1/admin/wallet/unlock", configuration.base_path);
243    let mut req_builder = configuration
244        .client
245        .request(reqwest::Method::POST, &uri_str);
246
247    if let Some(ref user_agent) = configuration.user_agent {
248        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
249    }
250    req_builder = req_builder.json(&p_unlock_request);
251
252    let req = req_builder.build()?;
253    let resp = configuration.client.execute(req).await?;
254
255    let status = resp.status();
256    let content_type = resp
257        .headers()
258        .get("content-type")
259        .and_then(|v| v.to_str().ok())
260        .unwrap_or("application/octet-stream");
261    let content_type = super::ContentType::from(content_type);
262
263    if !status.is_client_error() && !status.is_server_error() {
264        let content = resp.text().await?;
265        match content_type {
266            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
267            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
268            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
269        }
270    } else {
271        let content = resp.text().await?;
272        let entity: Option<WalletInitializerServiceUnlockError> =
273            serde_json::from_str(&content).ok();
274        Err(Error::ResponseError(ResponseContent {
275            status,
276            content,
277            entity,
278        }))
279    }
280}