1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ConstructionCombineError {
22 Status500(models::Error),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum ConstructionDeriveError {
30 Status500(models::Error),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum ConstructionHashError {
38 Status500(models::Error),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum ConstructionMetadataError {
46 Status500(models::Error),
47 UnknownValue(serde_json::Value),
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum ConstructionParseError {
54 Status500(models::Error),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum ConstructionPayloadsError {
62 Status500(models::Error),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum ConstructionPreprocessError {
70 Status500(models::Error),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ConstructionSubmitError {
78 Status500(models::Error),
79 UnknownValue(serde_json::Value),
80}
81
82
83pub async fn construction_combine(configuration: &configuration::Configuration, construction_combine_request: models::ConstructionCombineRequest) -> Result<models::ConstructionCombineResponse, Error<ConstructionCombineError>> {
85 let local_var_configuration = configuration;
86
87 let local_var_client = &local_var_configuration.client;
88
89 let local_var_uri_str = format!("{}/construction/combine", local_var_configuration.base_path);
90 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
91
92 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
93 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
94 }
95 local_var_req_builder = local_var_req_builder.json(&construction_combine_request);
96
97 let local_var_req = local_var_req_builder.build()?;
98 let local_var_resp = local_var_client.execute(local_var_req).await?;
99
100 let local_var_status = local_var_resp.status();
101 let local_var_content = local_var_resp.text().await?;
102
103 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
104 serde_json::from_str(&local_var_content).map_err(Error::from)
105 } else {
106 let local_var_entity: Option<ConstructionCombineError> = serde_json::from_str(&local_var_content).ok();
107 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
108 Err(Error::ResponseError(local_var_error))
109 }
110}
111
112pub async fn construction_derive(configuration: &configuration::Configuration, construction_derive_request: models::ConstructionDeriveRequest) -> Result<models::ConstructionDeriveResponse, Error<ConstructionDeriveError>> {
114 let local_var_configuration = configuration;
115
116 let local_var_client = &local_var_configuration.client;
117
118 let local_var_uri_str = format!("{}/construction/derive", local_var_configuration.base_path);
119 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
120
121 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
122 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
123 }
124 local_var_req_builder = local_var_req_builder.json(&construction_derive_request);
125
126 let local_var_req = local_var_req_builder.build()?;
127 let local_var_resp = local_var_client.execute(local_var_req).await?;
128
129 let local_var_status = local_var_resp.status();
130 let local_var_content = local_var_resp.text().await?;
131
132 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
133 serde_json::from_str(&local_var_content).map_err(Error::from)
134 } else {
135 let local_var_entity: Option<ConstructionDeriveError> = serde_json::from_str(&local_var_content).ok();
136 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
137 Err(Error::ResponseError(local_var_error))
138 }
139}
140
141pub async fn construction_hash(configuration: &configuration::Configuration, construction_hash_request: models::ConstructionHashRequest) -> Result<models::TransactionIdentifierResponse, Error<ConstructionHashError>> {
143 let local_var_configuration = configuration;
144
145 let local_var_client = &local_var_configuration.client;
146
147 let local_var_uri_str = format!("{}/construction/hash", local_var_configuration.base_path);
148 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
149
150 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
151 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
152 }
153 local_var_req_builder = local_var_req_builder.json(&construction_hash_request);
154
155 let local_var_req = local_var_req_builder.build()?;
156 let local_var_resp = local_var_client.execute(local_var_req).await?;
157
158 let local_var_status = local_var_resp.status();
159 let local_var_content = local_var_resp.text().await?;
160
161 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
162 serde_json::from_str(&local_var_content).map_err(Error::from)
163 } else {
164 let local_var_entity: Option<ConstructionHashError> = serde_json::from_str(&local_var_content).ok();
165 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
166 Err(Error::ResponseError(local_var_error))
167 }
168}
169
170pub async fn construction_metadata(configuration: &configuration::Configuration, construction_metadata_request: models::ConstructionMetadataRequest) -> Result<models::ConstructionMetadataResponse, Error<ConstructionMetadataError>> {
172 let local_var_configuration = configuration;
173
174 let local_var_client = &local_var_configuration.client;
175
176 let local_var_uri_str = format!("{}/construction/metadata", local_var_configuration.base_path);
177 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
178
179 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
180 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
181 }
182 local_var_req_builder = local_var_req_builder.json(&construction_metadata_request);
183
184 let local_var_req = local_var_req_builder.build()?;
185 let local_var_resp = local_var_client.execute(local_var_req).await?;
186
187 let local_var_status = local_var_resp.status();
188 let local_var_content = local_var_resp.text().await?;
189
190 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
191 serde_json::from_str(&local_var_content).map_err(Error::from)
192 } else {
193 let local_var_entity: Option<ConstructionMetadataError> = serde_json::from_str(&local_var_content).ok();
194 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
195 Err(Error::ResponseError(local_var_error))
196 }
197}
198
199pub async fn construction_parse(configuration: &configuration::Configuration, construction_parse_request: models::ConstructionParseRequest) -> Result<models::ConstructionParseResponse, Error<ConstructionParseError>> {
201 let local_var_configuration = configuration;
202
203 let local_var_client = &local_var_configuration.client;
204
205 let local_var_uri_str = format!("{}/construction/parse", local_var_configuration.base_path);
206 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
207
208 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
209 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
210 }
211 local_var_req_builder = local_var_req_builder.json(&construction_parse_request);
212
213 let local_var_req = local_var_req_builder.build()?;
214 let local_var_resp = local_var_client.execute(local_var_req).await?;
215
216 let local_var_status = local_var_resp.status();
217 let local_var_content = local_var_resp.text().await?;
218
219 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
220 serde_json::from_str(&local_var_content).map_err(Error::from)
221 } else {
222 let local_var_entity: Option<ConstructionParseError> = serde_json::from_str(&local_var_content).ok();
223 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
224 Err(Error::ResponseError(local_var_error))
225 }
226}
227
228pub async fn construction_payloads(configuration: &configuration::Configuration, construction_payloads_request: models::ConstructionPayloadsRequest) -> Result<models::ConstructionPayloadsResponse, Error<ConstructionPayloadsError>> {
230 let local_var_configuration = configuration;
231
232 let local_var_client = &local_var_configuration.client;
233
234 let local_var_uri_str = format!("{}/construction/payloads", local_var_configuration.base_path);
235 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
236
237 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
238 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
239 }
240 local_var_req_builder = local_var_req_builder.json(&construction_payloads_request);
241
242 let local_var_req = local_var_req_builder.build()?;
243 let local_var_resp = local_var_client.execute(local_var_req).await?;
244
245 let local_var_status = local_var_resp.status();
246 let local_var_content = local_var_resp.text().await?;
247
248 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
249 serde_json::from_str(&local_var_content).map_err(Error::from)
250 } else {
251 let local_var_entity: Option<ConstructionPayloadsError> = serde_json::from_str(&local_var_content).ok();
252 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
253 Err(Error::ResponseError(local_var_error))
254 }
255}
256
257pub async fn construction_preprocess(configuration: &configuration::Configuration, construction_preprocess_request: models::ConstructionPreprocessRequest) -> Result<models::ConstructionPreprocessResponse, Error<ConstructionPreprocessError>> {
259 let local_var_configuration = configuration;
260
261 let local_var_client = &local_var_configuration.client;
262
263 let local_var_uri_str = format!("{}/construction/preprocess", local_var_configuration.base_path);
264 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
265
266 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
267 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
268 }
269 local_var_req_builder = local_var_req_builder.json(&construction_preprocess_request);
270
271 let local_var_req = local_var_req_builder.build()?;
272 let local_var_resp = local_var_client.execute(local_var_req).await?;
273
274 let local_var_status = local_var_resp.status();
275 let local_var_content = local_var_resp.text().await?;
276
277 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
278 serde_json::from_str(&local_var_content).map_err(Error::from)
279 } else {
280 let local_var_entity: Option<ConstructionPreprocessError> = serde_json::from_str(&local_var_content).ok();
281 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
282 Err(Error::ResponseError(local_var_error))
283 }
284}
285
286pub async fn construction_submit(configuration: &configuration::Configuration, construction_submit_request: models::ConstructionSubmitRequest) -> Result<models::TransactionIdentifierResponse, Error<ConstructionSubmitError>> {
288 let local_var_configuration = configuration;
289
290 let local_var_client = &local_var_configuration.client;
291
292 let local_var_uri_str = format!("{}/construction/submit", local_var_configuration.base_path);
293 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
294
295 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
296 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
297 }
298 local_var_req_builder = local_var_req_builder.json(&construction_submit_request);
299
300 let local_var_req = local_var_req_builder.build()?;
301 let local_var_resp = local_var_client.execute(local_var_req).await?;
302
303 let local_var_status = local_var_resp.status();
304 let local_var_content = local_var_resp.text().await?;
305
306 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
307 serde_json::from_str(&local_var_content).map_err(Error::from)
308 } else {
309 let local_var_entity: Option<ConstructionSubmitError> = serde_json::from_str(&local_var_content).ok();
310 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
311 Err(Error::ResponseError(local_var_error))
312 }
313}
314