1use {
10 super::{Error, configuration},
11 crate::{
12 apis::{ContentType, ResponseContent},
13 models,
14 },
15 async_trait::async_trait,
16 reqwest,
17 serde::{Deserialize, Serialize, de::Error as _},
18 std::sync::Arc,
19};
20
21#[async_trait]
22pub trait GasStationApi: Send + Sync {
23 async fn get_gas_station_by_asset_id(
29 &self,
30 params: GetGasStationByAssetIdParams,
31 ) -> Result<models::GasStationPropertiesResponse, Error<GetGasStationByAssetIdError>>;
32
33 async fn get_gas_station_info(
38 &self,
39 ) -> Result<models::GasStationPropertiesResponse, Error<GetGasStationInfoError>>;
40
41 async fn update_gas_station_configuration(
45 &self,
46 params: UpdateGasStationConfigurationParams,
47 ) -> Result<
48 models::EditGasStationConfigurationResponse,
49 Error<UpdateGasStationConfigurationError>,
50 >;
51
52 async fn update_gas_station_configuration_by_asset_id(
56 &self,
57 params: UpdateGasStationConfigurationByAssetIdParams,
58 ) -> Result<
59 models::EditGasStationConfigurationResponse,
60 Error<UpdateGasStationConfigurationByAssetIdError>,
61 >;
62}
63
64pub struct GasStationApiClient {
65 configuration: Arc<configuration::Configuration>,
66}
67
68impl GasStationApiClient {
69 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
70 Self { configuration }
71 }
72}
73
74#[derive(Clone, Debug)]
77#[cfg_attr(feature = "bon", derive(::bon::Builder))]
78pub struct GetGasStationByAssetIdParams {
79 pub asset_id: String,
81}
82
83#[derive(Clone, Debug)]
86#[cfg_attr(feature = "bon", derive(::bon::Builder))]
87pub struct UpdateGasStationConfigurationParams {
88 pub gas_station_configuration: models::GasStationConfiguration,
89 pub idempotency_key: Option<String>,
94}
95
96#[derive(Clone, Debug)]
99#[cfg_attr(feature = "bon", derive(::bon::Builder))]
100pub struct UpdateGasStationConfigurationByAssetIdParams {
101 pub asset_id: String,
103 pub gas_station_configuration: models::GasStationConfiguration,
104 pub idempotency_key: Option<String>,
109}
110
111#[async_trait]
112impl GasStationApi for GasStationApiClient {
113 async fn get_gas_station_by_asset_id(
117 &self,
118 params: GetGasStationByAssetIdParams,
119 ) -> Result<models::GasStationPropertiesResponse, Error<GetGasStationByAssetIdError>> {
120 let GetGasStationByAssetIdParams { asset_id } = params;
121
122 let local_var_configuration = &self.configuration;
123
124 let local_var_client = &local_var_configuration.client;
125
126 let local_var_uri_str = format!(
127 "{}/gas_station/{assetId}",
128 local_var_configuration.base_path,
129 assetId = crate::apis::urlencode(asset_id)
130 );
131 let mut local_var_req_builder =
132 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
133
134 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
135 local_var_req_builder = local_var_req_builder
136 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
137 }
138
139 let local_var_req = local_var_req_builder.build()?;
140 let local_var_resp = local_var_client.execute(local_var_req).await?;
141
142 let local_var_status = local_var_resp.status();
143 let local_var_content_type = local_var_resp
144 .headers()
145 .get("content-type")
146 .and_then(|v| v.to_str().ok())
147 .unwrap_or("application/octet-stream");
148 let local_var_content_type = super::ContentType::from(local_var_content_type);
149 let local_var_content = local_var_resp.text().await?;
150
151 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
152 match local_var_content_type {
153 ContentType::Json => {
154 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
155 }
156 ContentType::Text => {
157 return Err(Error::from(serde_json::Error::custom(
158 "Received `text/plain` content type response that cannot be converted to \
159 `models::GasStationPropertiesResponse`",
160 )));
161 }
162 ContentType::Unsupported(local_var_unknown_type) => {
163 return Err(Error::from(serde_json::Error::custom(format!(
164 "Received `{local_var_unknown_type}` content type response that cannot be \
165 converted to `models::GasStationPropertiesResponse`"
166 ))));
167 }
168 }
169 } else {
170 let local_var_entity: Option<GetGasStationByAssetIdError> =
171 serde_json::from_str(&local_var_content).ok();
172 let local_var_error = ResponseContent {
173 status: local_var_status,
174 content: local_var_content,
175 entity: local_var_entity,
176 };
177 Err(Error::ResponseError(local_var_error))
178 }
179 }
180
181 async fn get_gas_station_info(
184 &self,
185 ) -> Result<models::GasStationPropertiesResponse, Error<GetGasStationInfoError>> {
186 let local_var_configuration = &self.configuration;
187
188 let local_var_client = &local_var_configuration.client;
189
190 let local_var_uri_str = format!("{}/gas_station", local_var_configuration.base_path);
191 let mut local_var_req_builder =
192 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
193
194 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
195 local_var_req_builder = local_var_req_builder
196 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
197 }
198
199 let local_var_req = local_var_req_builder.build()?;
200 let local_var_resp = local_var_client.execute(local_var_req).await?;
201
202 let local_var_status = local_var_resp.status();
203 let local_var_content_type = local_var_resp
204 .headers()
205 .get("content-type")
206 .and_then(|v| v.to_str().ok())
207 .unwrap_or("application/octet-stream");
208 let local_var_content_type = super::ContentType::from(local_var_content_type);
209 let local_var_content = local_var_resp.text().await?;
210
211 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
212 match local_var_content_type {
213 ContentType::Json => {
214 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
215 }
216 ContentType::Text => {
217 return Err(Error::from(serde_json::Error::custom(
218 "Received `text/plain` content type response that cannot be converted to \
219 `models::GasStationPropertiesResponse`",
220 )));
221 }
222 ContentType::Unsupported(local_var_unknown_type) => {
223 return Err(Error::from(serde_json::Error::custom(format!(
224 "Received `{local_var_unknown_type}` content type response that cannot be \
225 converted to `models::GasStationPropertiesResponse`"
226 ))));
227 }
228 }
229 } else {
230 let local_var_entity: Option<GetGasStationInfoError> =
231 serde_json::from_str(&local_var_content).ok();
232 let local_var_error = ResponseContent {
233 status: local_var_status,
234 content: local_var_content,
235 entity: local_var_entity,
236 };
237 Err(Error::ResponseError(local_var_error))
238 }
239 }
240
241 async fn update_gas_station_configuration(
243 &self,
244 params: UpdateGasStationConfigurationParams,
245 ) -> Result<
246 models::EditGasStationConfigurationResponse,
247 Error<UpdateGasStationConfigurationError>,
248 > {
249 let UpdateGasStationConfigurationParams {
250 gas_station_configuration,
251 idempotency_key,
252 } = params;
253
254 let local_var_configuration = &self.configuration;
255
256 let local_var_client = &local_var_configuration.client;
257
258 let local_var_uri_str = format!(
259 "{}/gas_station/configuration",
260 local_var_configuration.base_path
261 );
262 let mut local_var_req_builder =
263 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
264
265 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
266 local_var_req_builder = local_var_req_builder
267 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
268 }
269 if let Some(local_var_param_value) = idempotency_key {
270 local_var_req_builder =
271 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
272 }
273 local_var_req_builder = local_var_req_builder.json(&gas_station_configuration);
274
275 let local_var_req = local_var_req_builder.build()?;
276 let local_var_resp = local_var_client.execute(local_var_req).await?;
277
278 let local_var_status = local_var_resp.status();
279 let local_var_content_type = local_var_resp
280 .headers()
281 .get("content-type")
282 .and_then(|v| v.to_str().ok())
283 .unwrap_or("application/octet-stream");
284 let local_var_content_type = super::ContentType::from(local_var_content_type);
285 let local_var_content = local_var_resp.text().await?;
286
287 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
288 match local_var_content_type {
289 ContentType::Json => {
290 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
291 }
292 ContentType::Text => {
293 return Err(Error::from(serde_json::Error::custom(
294 "Received `text/plain` content type response that cannot be converted to \
295 `models::EditGasStationConfigurationResponse`",
296 )));
297 }
298 ContentType::Unsupported(local_var_unknown_type) => {
299 return Err(Error::from(serde_json::Error::custom(format!(
300 "Received `{local_var_unknown_type}` content type response that cannot be \
301 converted to `models::EditGasStationConfigurationResponse`"
302 ))));
303 }
304 }
305 } else {
306 let local_var_entity: Option<UpdateGasStationConfigurationError> =
307 serde_json::from_str(&local_var_content).ok();
308 let local_var_error = ResponseContent {
309 status: local_var_status,
310 content: local_var_content,
311 entity: local_var_entity,
312 };
313 Err(Error::ResponseError(local_var_error))
314 }
315 }
316
317 async fn update_gas_station_configuration_by_asset_id(
319 &self,
320 params: UpdateGasStationConfigurationByAssetIdParams,
321 ) -> Result<
322 models::EditGasStationConfigurationResponse,
323 Error<UpdateGasStationConfigurationByAssetIdError>,
324 > {
325 let UpdateGasStationConfigurationByAssetIdParams {
326 asset_id,
327 gas_station_configuration,
328 idempotency_key,
329 } = params;
330
331 let local_var_configuration = &self.configuration;
332
333 let local_var_client = &local_var_configuration.client;
334
335 let local_var_uri_str = format!(
336 "{}/gas_station/configuration/{assetId}",
337 local_var_configuration.base_path,
338 assetId = crate::apis::urlencode(asset_id)
339 );
340 let mut local_var_req_builder =
341 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
342
343 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
344 local_var_req_builder = local_var_req_builder
345 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
346 }
347 if let Some(local_var_param_value) = idempotency_key {
348 local_var_req_builder =
349 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
350 }
351 local_var_req_builder = local_var_req_builder.json(&gas_station_configuration);
352
353 let local_var_req = local_var_req_builder.build()?;
354 let local_var_resp = local_var_client.execute(local_var_req).await?;
355
356 let local_var_status = local_var_resp.status();
357 let local_var_content_type = local_var_resp
358 .headers()
359 .get("content-type")
360 .and_then(|v| v.to_str().ok())
361 .unwrap_or("application/octet-stream");
362 let local_var_content_type = super::ContentType::from(local_var_content_type);
363 let local_var_content = local_var_resp.text().await?;
364
365 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
366 match local_var_content_type {
367 ContentType::Json => {
368 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
369 }
370 ContentType::Text => {
371 return Err(Error::from(serde_json::Error::custom(
372 "Received `text/plain` content type response that cannot be converted to \
373 `models::EditGasStationConfigurationResponse`",
374 )));
375 }
376 ContentType::Unsupported(local_var_unknown_type) => {
377 return Err(Error::from(serde_json::Error::custom(format!(
378 "Received `{local_var_unknown_type}` content type response that cannot be \
379 converted to `models::EditGasStationConfigurationResponse`"
380 ))));
381 }
382 }
383 } else {
384 let local_var_entity: Option<UpdateGasStationConfigurationByAssetIdError> =
385 serde_json::from_str(&local_var_content).ok();
386 let local_var_error = ResponseContent {
387 status: local_var_status,
388 content: local_var_content,
389 entity: local_var_entity,
390 };
391 Err(Error::ResponseError(local_var_error))
392 }
393 }
394}
395
396#[derive(Debug, Clone, Serialize, Deserialize)]
399#[serde(untagged)]
400pub enum GetGasStationByAssetIdError {
401 DefaultResponse(models::ErrorSchema),
402 UnknownValue(serde_json::Value),
403}
404
405#[derive(Debug, Clone, Serialize, Deserialize)]
407#[serde(untagged)]
408pub enum GetGasStationInfoError {
409 DefaultResponse(models::ErrorSchema),
410 UnknownValue(serde_json::Value),
411}
412
413#[derive(Debug, Clone, Serialize, Deserialize)]
416#[serde(untagged)]
417pub enum UpdateGasStationConfigurationError {
418 DefaultResponse(models::ErrorSchema),
419 UnknownValue(serde_json::Value),
420}
421
422#[derive(Debug, Clone, Serialize, Deserialize)]
425#[serde(untagged)]
426pub enum UpdateGasStationConfigurationByAssetIdError {
427 DefaultResponse(models::ErrorSchema),
428 UnknownValue(serde_json::Value),
429}