fireblocks_sdk/apis/
staking_api.rs

1// Fireblocks API
2//
3// Fireblocks provides a suite of applications to manage digital asset operations and a complete development platform to build your business on the blockchain.  - Visit our website for more information: [Fireblocks Website](https://fireblocks.com) - Visit our developer docs: [Fireblocks DevPortal](https://developers.fireblocks.com)
4//
5// The version of the OpenAPI document: 1.8.0
6// Contact: developers@fireblocks.com
7// Generated by: https://openapi-generator.tech
8
9use {
10    super::{configuration, Error},
11    crate::{apis::ResponseContent, models},
12    async_trait::async_trait,
13    reqwest,
14    serde::{Deserialize, Serialize},
15    std::sync::Arc,
16};
17
18#[async_trait]
19pub trait StakingApi: Send + Sync {
20    async fn approve_terms_of_service_by_provider_id(
21        &self,
22        params: ApproveTermsOfServiceByProviderIdParams,
23    ) -> Result<(), Error<ApproveTermsOfServiceByProviderIdError>>;
24    async fn claim_rewards(
25        &self,
26        params: ClaimRewardsParams,
27    ) -> Result<(), Error<ClaimRewardsError>>;
28    async fn get_all_delegations(
29        &self,
30        params: GetAllDelegationsParams,
31    ) -> Result<Vec<models::Delegation>, Error<GetAllDelegationsError>>;
32    async fn get_chain_info(
33        &self,
34        params: GetChainInfoParams,
35    ) -> Result<models::ChainInfoResponse, Error<GetChainInfoError>>;
36    async fn get_chains(&self) -> Result<Vec<models::ChainDescriptor>, Error<GetChainsError>>;
37    async fn get_delegation_by_id(
38        &self,
39        params: GetDelegationByIdParams,
40    ) -> Result<models::Delegation, Error<GetDelegationByIdError>>;
41    async fn get_providers(&self) -> Result<Vec<models::Provider>, Error<GetProvidersError>>;
42    async fn get_summary(&self) -> Result<models::DelegationSummary, Error<GetSummaryError>>;
43    async fn get_summary_by_vault(
44        &self,
45    ) -> Result<
46        std::collections::HashMap<String, models::DelegationSummary>,
47        Error<GetSummaryByVaultError>,
48    >;
49    async fn split(&self, params: SplitParams) -> Result<models::SplitResponse, Error<SplitError>>;
50    async fn stake(&self, params: StakeParams) -> Result<models::StakeResponse, Error<StakeError>>;
51    async fn unstake(&self, params: UnstakeParams) -> Result<(), Error<UnstakeError>>;
52    async fn withdraw(&self, params: WithdrawParams) -> Result<(), Error<WithdrawError>>;
53}
54
55pub struct StakingApiClient {
56    configuration: Arc<configuration::Configuration>,
57}
58
59impl StakingApiClient {
60    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
61        Self { configuration }
62    }
63}
64
65/// struct for passing parameters to the method
66/// [`approve_terms_of_service_by_provider_id`]
67#[derive(Clone, Debug)]
68#[cfg_attr(feature = "bon", derive(::bon::Builder))]
69pub struct ApproveTermsOfServiceByProviderIdParams {
70    /// The unique identifier of the staking provider
71    pub provider_id: models::StakingProvider,
72    /// A unique identifier for the request. If the request is sent multiple
73    /// times with the same idempotency key, the server will return the same
74    /// response as the first request. The idempotency key is valid for 24
75    /// hours.
76    pub idempotency_key: Option<String>,
77}
78
79/// struct for passing parameters to the method [`claim_rewards`]
80#[derive(Clone, Debug)]
81#[cfg_attr(feature = "bon", derive(::bon::Builder))]
82pub struct ClaimRewardsParams {
83    /// The protocol identifier (e.g. \"MATIC\"/\"SOL\") to use
84    pub chain_descriptor: String,
85    pub claim_rewards_request: models::ClaimRewardsRequest,
86    /// A unique identifier for the request. If the request is sent multiple
87    /// times with the same idempotency key, the server will return the same
88    /// response as the first request. The idempotency key is valid for 24
89    /// hours.
90    pub idempotency_key: Option<String>,
91}
92
93/// struct for passing parameters to the method [`get_all_delegations`]
94#[derive(Clone, Debug)]
95#[cfg_attr(feature = "bon", derive(::bon::Builder))]
96pub struct GetAllDelegationsParams {
97    /// Use \"ETH\" / \"SOL\" / \"MATIC\" / \"STETH_ETH\" in order to obtain
98    /// information related to the specific blockchain network or retrieve
99    /// information about all chains that have data available by providing no
100    /// argument.
101    pub chain_descriptor: Option<models::ChainDescriptor>,
102}
103
104/// struct for passing parameters to the method [`get_chain_info`]
105#[derive(Clone, Debug)]
106#[cfg_attr(feature = "bon", derive(::bon::Builder))]
107pub struct GetChainInfoParams {
108    /// The protocol identifier (e.g. \"ETH\"/\"SOL\"/\"MATIC\"/\"STETH_ETH\")
109    /// to use
110    pub chain_descriptor: models::ChainDescriptor,
111}
112
113/// struct for passing parameters to the method [`get_delegation_by_id`]
114#[derive(Clone, Debug)]
115#[cfg_attr(feature = "bon", derive(::bon::Builder))]
116pub struct GetDelegationByIdParams {
117    /// The unique identifier of the staking position
118    pub id: String,
119}
120
121/// struct for passing parameters to the method [`split`]
122#[derive(Clone, Debug)]
123#[cfg_attr(feature = "bon", derive(::bon::Builder))]
124pub struct SplitParams {
125    /// The protocol identifier (e.g. \"SOL\"/\"SOL_TEST\") to use
126    pub chain_descriptor: String,
127    pub split_request: models::SplitRequest,
128    /// A unique identifier for the request. If the request is sent multiple
129    /// times with the same idempotency key, the server will return the same
130    /// response as the first request. The idempotency key is valid for 24
131    /// hours.
132    pub idempotency_key: Option<String>,
133}
134
135/// struct for passing parameters to the method [`stake`]
136#[derive(Clone, Debug)]
137#[cfg_attr(feature = "bon", derive(::bon::Builder))]
138pub struct StakeParams {
139    /// The protocol identifier (e.g. \"ETH\"/\"SOL\"/\"MATIC\") to use
140    pub chain_descriptor: models::ChainDescriptor,
141    pub stake_request: models::StakeRequest,
142    /// A unique identifier for the request. If the request is sent multiple
143    /// times with the same idempotency key, the server will return the same
144    /// response as the first request. The idempotency key is valid for 24
145    /// hours.
146    pub idempotency_key: Option<String>,
147}
148
149/// struct for passing parameters to the method [`unstake`]
150#[derive(Clone, Debug)]
151#[cfg_attr(feature = "bon", derive(::bon::Builder))]
152pub struct UnstakeParams {
153    /// The protocol identifier (e.g. \"ETH\"/\"SOL\"/\"MATIC\") to use
154    pub chain_descriptor: models::ChainDescriptor,
155    pub unstake_request: models::UnstakeRequest,
156    /// A unique identifier for the request. If the request is sent multiple
157    /// times with the same idempotency key, the server will return the same
158    /// response as the first request. The idempotency key is valid for 24
159    /// hours.
160    pub idempotency_key: Option<String>,
161}
162
163/// struct for passing parameters to the method [`withdraw`]
164#[derive(Clone, Debug)]
165#[cfg_attr(feature = "bon", derive(::bon::Builder))]
166pub struct WithdrawParams {
167    /// The protocol identifier (e.g. \"ETH\"/\"SOL\"/\"MATIC\") to use
168    pub chain_descriptor: models::ChainDescriptor,
169    pub withdraw_request: models::WithdrawRequest,
170    /// A unique identifier for the request. If the request is sent multiple
171    /// times with the same idempotency key, the server will return the same
172    /// response as the first request. The idempotency key is valid for 24
173    /// hours.
174    pub idempotency_key: Option<String>,
175}
176
177#[async_trait]
178impl StakingApi for StakingApiClient {
179    /// Approve the terms of service of the staking provider. This must be
180    /// called before performing a staking action for the first time with this
181    /// provider. </br>Endpoint Permission: Admin, Non-Signing Admin, Signer,
182    /// Approver, Editor.
183    async fn approve_terms_of_service_by_provider_id(
184        &self,
185        params: ApproveTermsOfServiceByProviderIdParams,
186    ) -> Result<(), Error<ApproveTermsOfServiceByProviderIdError>> {
187        let ApproveTermsOfServiceByProviderIdParams {
188            provider_id,
189            idempotency_key,
190        } = params;
191
192        let local_var_configuration = &self.configuration;
193
194        let local_var_client = &local_var_configuration.client;
195
196        let local_var_uri_str = format!(
197            "{}/staking/providers/{providerId}/approveTermsOfService",
198            local_var_configuration.base_path,
199            providerId = provider_id.to_string()
200        );
201        let mut local_var_req_builder =
202            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
203
204        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
205            local_var_req_builder = local_var_req_builder
206                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
207        }
208        if let Some(local_var_param_value) = idempotency_key {
209            local_var_req_builder =
210                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
211        }
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            Ok(())
221        } else {
222            let local_var_entity: Option<ApproveTermsOfServiceByProviderIdError> =
223                serde_json::from_str(&local_var_content).ok();
224            let local_var_error = ResponseContent {
225                status: local_var_status,
226                content: local_var_content,
227                entity: local_var_entity,
228            };
229            Err(Error::ResponseError(local_var_error))
230        }
231    }
232
233    /// Perform a chain-specific Claim Rewards.
234    async fn claim_rewards(
235        &self,
236        params: ClaimRewardsParams,
237    ) -> Result<(), Error<ClaimRewardsError>> {
238        let ClaimRewardsParams {
239            chain_descriptor,
240            claim_rewards_request,
241            idempotency_key,
242        } = params;
243
244        let local_var_configuration = &self.configuration;
245
246        let local_var_client = &local_var_configuration.client;
247
248        let local_var_uri_str = format!(
249            "{}/staking/chains/{chainDescriptor}/claim_rewards",
250            local_var_configuration.base_path,
251            chainDescriptor = crate::apis::urlencode(chain_descriptor)
252        );
253        let mut local_var_req_builder =
254            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
255
256        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
257            local_var_req_builder = local_var_req_builder
258                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
259        }
260        if let Some(local_var_param_value) = idempotency_key {
261            local_var_req_builder =
262                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
263        }
264        local_var_req_builder = local_var_req_builder.json(&claim_rewards_request);
265
266        let local_var_req = local_var_req_builder.build()?;
267        let local_var_resp = local_var_client.execute(local_var_req).await?;
268
269        let local_var_status = local_var_resp.status();
270        let local_var_content = local_var_resp.text().await?;
271
272        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
273            Ok(())
274        } else {
275            let local_var_entity: Option<ClaimRewardsError> =
276                serde_json::from_str(&local_var_content).ok();
277            let local_var_error = ResponseContent {
278                status: local_var_status,
279                content: local_var_content,
280                entity: local_var_entity,
281            };
282            Err(Error::ResponseError(local_var_error))
283        }
284    }
285
286    /// Return detailed information on all staking positions, including the
287    /// staked amount, rewards, status and more. </br>Endpoint Permission:
288    /// Admin, Non-Signing Admin, Signer, Approver, Editor.
289    async fn get_all_delegations(
290        &self,
291        params: GetAllDelegationsParams,
292    ) -> Result<Vec<models::Delegation>, Error<GetAllDelegationsError>> {
293        let GetAllDelegationsParams { chain_descriptor } = params;
294
295        let local_var_configuration = &self.configuration;
296
297        let local_var_client = &local_var_configuration.client;
298
299        let local_var_uri_str = format!("{}/staking/positions", local_var_configuration.base_path);
300        let mut local_var_req_builder =
301            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
302
303        if let Some(ref local_var_str) = chain_descriptor {
304            local_var_req_builder =
305                local_var_req_builder.query(&[("chainDescriptor", &local_var_str.to_string())]);
306        }
307        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
308            local_var_req_builder = local_var_req_builder
309                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
310        }
311
312        let local_var_req = local_var_req_builder.build()?;
313        let local_var_resp = local_var_client.execute(local_var_req).await?;
314
315        let local_var_status = local_var_resp.status();
316        let local_var_content = local_var_resp.text().await?;
317
318        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
319            serde_json::from_str(&local_var_content).map_err(Error::from)
320        } else {
321            let local_var_entity: Option<GetAllDelegationsError> =
322                serde_json::from_str(&local_var_content).ok();
323            let local_var_error = ResponseContent {
324                status: local_var_status,
325                content: local_var_content,
326                entity: local_var_entity,
327            };
328            Err(Error::ResponseError(local_var_error))
329        }
330    }
331
332    /// Return chain-specific, staking-related information summary (e.g. epoch
333    /// details, lockup durations, estimated rewards, etc.). </br>Endpoint
334    /// Permission: Admin, Non-Signing Admin, Signer, Approver, Editor.
335    async fn get_chain_info(
336        &self,
337        params: GetChainInfoParams,
338    ) -> Result<models::ChainInfoResponse, Error<GetChainInfoError>> {
339        let GetChainInfoParams { chain_descriptor } = params;
340
341        let local_var_configuration = &self.configuration;
342
343        let local_var_client = &local_var_configuration.client;
344
345        let local_var_uri_str = format!(
346            "{}/staking/chains/{chainDescriptor}/chainInfo",
347            local_var_configuration.base_path,
348            chainDescriptor = chain_descriptor.to_string()
349        );
350        let mut local_var_req_builder =
351            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
352
353        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
354            local_var_req_builder = local_var_req_builder
355                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
356        }
357
358        let local_var_req = local_var_req_builder.build()?;
359        let local_var_resp = local_var_client.execute(local_var_req).await?;
360
361        let local_var_status = local_var_resp.status();
362        let local_var_content = local_var_resp.text().await?;
363
364        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
365            serde_json::from_str(&local_var_content).map_err(Error::from)
366        } else {
367            let local_var_entity: Option<GetChainInfoError> =
368                serde_json::from_str(&local_var_content).ok();
369            let local_var_error = ResponseContent {
370                status: local_var_status,
371                content: local_var_content,
372                entity: local_var_entity,
373            };
374            Err(Error::ResponseError(local_var_error))
375        }
376    }
377
378    /// Return an alphabetical list of supported chains. </br>Endpoint
379    /// Permission: Admin, Non-Signing Admin, Signer, Approver, Editor.
380    async fn get_chains(&self) -> Result<Vec<models::ChainDescriptor>, Error<GetChainsError>> {
381        let local_var_configuration = &self.configuration;
382
383        let local_var_client = &local_var_configuration.client;
384
385        let local_var_uri_str = format!("{}/staking/chains", local_var_configuration.base_path);
386        let mut local_var_req_builder =
387            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
388
389        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
390            local_var_req_builder = local_var_req_builder
391                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
392        }
393
394        let local_var_req = local_var_req_builder.build()?;
395        let local_var_resp = local_var_client.execute(local_var_req).await?;
396
397        let local_var_status = local_var_resp.status();
398        let local_var_content = local_var_resp.text().await?;
399
400        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
401            serde_json::from_str(&local_var_content).map_err(Error::from)
402        } else {
403            let local_var_entity: Option<GetChainsError> =
404                serde_json::from_str(&local_var_content).ok();
405            let local_var_error = ResponseContent {
406                status: local_var_status,
407                content: local_var_content,
408                entity: local_var_entity,
409            };
410            Err(Error::ResponseError(local_var_error))
411        }
412    }
413
414    /// Return detailed information on a staking position, including the staked
415    /// amount, rewards, status and more. </br>Endpoint Permission: Admin,
416    /// Non-Signing Admin, Signer, Approver, Editor.
417    async fn get_delegation_by_id(
418        &self,
419        params: GetDelegationByIdParams,
420    ) -> Result<models::Delegation, Error<GetDelegationByIdError>> {
421        let GetDelegationByIdParams { id } = params;
422
423        let local_var_configuration = &self.configuration;
424
425        let local_var_client = &local_var_configuration.client;
426
427        let local_var_uri_str = format!(
428            "{}/staking/positions/{id}",
429            local_var_configuration.base_path,
430            id = crate::apis::urlencode(id)
431        );
432        let mut local_var_req_builder =
433            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
434
435        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
436            local_var_req_builder = local_var_req_builder
437                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
438        }
439
440        let local_var_req = local_var_req_builder.build()?;
441        let local_var_resp = local_var_client.execute(local_var_req).await?;
442
443        let local_var_status = local_var_resp.status();
444        let local_var_content = local_var_resp.text().await?;
445
446        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
447            serde_json::from_str(&local_var_content).map_err(Error::from)
448        } else {
449            let local_var_entity: Option<GetDelegationByIdError> =
450                serde_json::from_str(&local_var_content).ok();
451            let local_var_error = ResponseContent {
452                status: local_var_status,
453                content: local_var_content,
454                entity: local_var_entity,
455            };
456            Err(Error::ResponseError(local_var_error))
457        }
458    }
459
460    /// Return information on all the available staking providers. </br>Endpoint
461    /// Permission: Admin, Non-Signing Admin, Signer, Approver, Editor.
462    async fn get_providers(&self) -> Result<Vec<models::Provider>, Error<GetProvidersError>> {
463        let local_var_configuration = &self.configuration;
464
465        let local_var_client = &local_var_configuration.client;
466
467        let local_var_uri_str = format!("{}/staking/providers", local_var_configuration.base_path);
468        let mut local_var_req_builder =
469            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
470
471        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
472            local_var_req_builder = local_var_req_builder
473                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
474        }
475
476        let local_var_req = local_var_req_builder.build()?;
477        let local_var_resp = local_var_client.execute(local_var_req).await?;
478
479        let local_var_status = local_var_resp.status();
480        let local_var_content = local_var_resp.text().await?;
481
482        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
483            serde_json::from_str(&local_var_content).map_err(Error::from)
484        } else {
485            let local_var_entity: Option<GetProvidersError> =
486                serde_json::from_str(&local_var_content).ok();
487            let local_var_error = ResponseContent {
488                status: local_var_status,
489                content: local_var_content,
490                entity: local_var_entity,
491            };
492            Err(Error::ResponseError(local_var_error))
493        }
494    }
495
496    /// Return a summary of all vaults, categorized by their status (active,
497    /// inactive), the total amounts staked and total rewards per-chain.
498    /// </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver,
499    /// Editor.
500    async fn get_summary(&self) -> Result<models::DelegationSummary, Error<GetSummaryError>> {
501        let local_var_configuration = &self.configuration;
502
503        let local_var_client = &local_var_configuration.client;
504
505        let local_var_uri_str = format!(
506            "{}/staking/positions/summary",
507            local_var_configuration.base_path
508        );
509        let mut local_var_req_builder =
510            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
511
512        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
513            local_var_req_builder = local_var_req_builder
514                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
515        }
516
517        let local_var_req = local_var_req_builder.build()?;
518        let local_var_resp = local_var_client.execute(local_var_req).await?;
519
520        let local_var_status = local_var_resp.status();
521        let local_var_content = local_var_resp.text().await?;
522
523        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
524            serde_json::from_str(&local_var_content).map_err(Error::from)
525        } else {
526            let local_var_entity: Option<GetSummaryError> =
527                serde_json::from_str(&local_var_content).ok();
528            let local_var_error = ResponseContent {
529                status: local_var_status,
530                content: local_var_content,
531                entity: local_var_entity,
532            };
533            Err(Error::ResponseError(local_var_error))
534        }
535    }
536
537    /// Return a summary for each vault, categorized by their status (active,
538    /// inactive), the total amounts staked and total rewards per-chain.
539    /// </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver,
540    /// Editor.
541    async fn get_summary_by_vault(
542        &self,
543    ) -> Result<
544        std::collections::HashMap<String, models::DelegationSummary>,
545        Error<GetSummaryByVaultError>,
546    > {
547        let local_var_configuration = &self.configuration;
548
549        let local_var_client = &local_var_configuration.client;
550
551        let local_var_uri_str = format!(
552            "{}/staking/positions/summary/vaults",
553            local_var_configuration.base_path
554        );
555        let mut local_var_req_builder =
556            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
557
558        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
559            local_var_req_builder = local_var_req_builder
560                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
561        }
562
563        let local_var_req = local_var_req_builder.build()?;
564        let local_var_resp = local_var_client.execute(local_var_req).await?;
565
566        let local_var_status = local_var_resp.status();
567        let local_var_content = local_var_resp.text().await?;
568
569        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
570            serde_json::from_str(&local_var_content).map_err(Error::from)
571        } else {
572            let local_var_entity: Option<GetSummaryByVaultError> =
573                serde_json::from_str(&local_var_content).ok();
574            let local_var_error = ResponseContent {
575                status: local_var_status,
576                content: local_var_content,
577                entity: local_var_entity,
578            };
579            Err(Error::ResponseError(local_var_error))
580        }
581    }
582
583    /// Perform a SOL/SOL_TEST Split on a stake account.
584    async fn split(&self, params: SplitParams) -> Result<models::SplitResponse, Error<SplitError>> {
585        let SplitParams {
586            chain_descriptor,
587            split_request,
588            idempotency_key,
589        } = params;
590
591        let local_var_configuration = &self.configuration;
592
593        let local_var_client = &local_var_configuration.client;
594
595        let local_var_uri_str = format!(
596            "{}/staking/chains/{chainDescriptor}/split",
597            local_var_configuration.base_path,
598            chainDescriptor = crate::apis::urlencode(chain_descriptor)
599        );
600        let mut local_var_req_builder =
601            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
602
603        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
604            local_var_req_builder = local_var_req_builder
605                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
606        }
607        if let Some(local_var_param_value) = idempotency_key {
608            local_var_req_builder =
609                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
610        }
611        local_var_req_builder = local_var_req_builder.json(&split_request);
612
613        let local_var_req = local_var_req_builder.build()?;
614        let local_var_resp = local_var_client.execute(local_var_req).await?;
615
616        let local_var_status = local_var_resp.status();
617        let local_var_content = local_var_resp.text().await?;
618
619        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
620            serde_json::from_str(&local_var_content).map_err(Error::from)
621        } else {
622            let local_var_entity: Option<SplitError> =
623                serde_json::from_str(&local_var_content).ok();
624            let local_var_error = ResponseContent {
625                status: local_var_status,
626                content: local_var_content,
627                entity: local_var_entity,
628            };
629            Err(Error::ResponseError(local_var_error))
630        }
631    }
632
633    /// Perform a chain-specific Stake.
634    async fn stake(&self, params: StakeParams) -> Result<models::StakeResponse, Error<StakeError>> {
635        let StakeParams {
636            chain_descriptor,
637            stake_request,
638            idempotency_key,
639        } = params;
640
641        let local_var_configuration = &self.configuration;
642
643        let local_var_client = &local_var_configuration.client;
644
645        let local_var_uri_str = format!(
646            "{}/staking/chains/{chainDescriptor}/stake",
647            local_var_configuration.base_path,
648            chainDescriptor = chain_descriptor.to_string()
649        );
650        let mut local_var_req_builder =
651            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
652
653        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
654            local_var_req_builder = local_var_req_builder
655                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
656        }
657        if let Some(local_var_param_value) = idempotency_key {
658            local_var_req_builder =
659                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
660        }
661        local_var_req_builder = local_var_req_builder.json(&stake_request);
662
663        let local_var_req = local_var_req_builder.build()?;
664        let local_var_resp = local_var_client.execute(local_var_req).await?;
665
666        let local_var_status = local_var_resp.status();
667        let local_var_content = local_var_resp.text().await?;
668
669        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
670            serde_json::from_str(&local_var_content).map_err(Error::from)
671        } else {
672            let local_var_entity: Option<StakeError> =
673                serde_json::from_str(&local_var_content).ok();
674            let local_var_error = ResponseContent {
675                status: local_var_status,
676                content: local_var_content,
677                entity: local_var_entity,
678            };
679            Err(Error::ResponseError(local_var_error))
680        }
681    }
682
683    /// Execute an Unstake operation
684    async fn unstake(&self, params: UnstakeParams) -> Result<(), Error<UnstakeError>> {
685        let UnstakeParams {
686            chain_descriptor,
687            unstake_request,
688            idempotency_key,
689        } = params;
690
691        let local_var_configuration = &self.configuration;
692
693        let local_var_client = &local_var_configuration.client;
694
695        let local_var_uri_str = format!(
696            "{}/staking/chains/{chainDescriptor}/unstake",
697            local_var_configuration.base_path,
698            chainDescriptor = chain_descriptor.to_string()
699        );
700        let mut local_var_req_builder =
701            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
702
703        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
704            local_var_req_builder = local_var_req_builder
705                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
706        }
707        if let Some(local_var_param_value) = idempotency_key {
708            local_var_req_builder =
709                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
710        }
711        local_var_req_builder = local_var_req_builder.json(&unstake_request);
712
713        let local_var_req = local_var_req_builder.build()?;
714        let local_var_resp = local_var_client.execute(local_var_req).await?;
715
716        let local_var_status = local_var_resp.status();
717        let local_var_content = local_var_resp.text().await?;
718
719        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
720            Ok(())
721        } else {
722            let local_var_entity: Option<UnstakeError> =
723                serde_json::from_str(&local_var_content).ok();
724            let local_var_error = ResponseContent {
725                status: local_var_status,
726                content: local_var_content,
727                entity: local_var_entity,
728            };
729            Err(Error::ResponseError(local_var_error))
730        }
731    }
732
733    /// Perform a chain-specific Withdraw.
734    async fn withdraw(&self, params: WithdrawParams) -> Result<(), Error<WithdrawError>> {
735        let WithdrawParams {
736            chain_descriptor,
737            withdraw_request,
738            idempotency_key,
739        } = params;
740
741        let local_var_configuration = &self.configuration;
742
743        let local_var_client = &local_var_configuration.client;
744
745        let local_var_uri_str = format!(
746            "{}/staking/chains/{chainDescriptor}/withdraw",
747            local_var_configuration.base_path,
748            chainDescriptor = chain_descriptor.to_string()
749        );
750        let mut local_var_req_builder =
751            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
752
753        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
754            local_var_req_builder = local_var_req_builder
755                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
756        }
757        if let Some(local_var_param_value) = idempotency_key {
758            local_var_req_builder =
759                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
760        }
761        local_var_req_builder = local_var_req_builder.json(&withdraw_request);
762
763        let local_var_req = local_var_req_builder.build()?;
764        let local_var_resp = local_var_client.execute(local_var_req).await?;
765
766        let local_var_status = local_var_resp.status();
767        let local_var_content = local_var_resp.text().await?;
768
769        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
770            Ok(())
771        } else {
772            let local_var_entity: Option<WithdrawError> =
773                serde_json::from_str(&local_var_content).ok();
774            let local_var_error = ResponseContent {
775                status: local_var_status,
776                content: local_var_content,
777                entity: local_var_entity,
778            };
779            Err(Error::ResponseError(local_var_error))
780        }
781    }
782}
783
784/// struct for typed errors of method
785/// [`approve_terms_of_service_by_provider_id`]
786#[derive(Debug, Clone, Serialize, Deserialize)]
787#[serde(untagged)]
788pub enum ApproveTermsOfServiceByProviderIdError {
789    DefaultResponse(models::ErrorSchema),
790    UnknownValue(serde_json::Value),
791}
792
793/// struct for typed errors of method [`claim_rewards`]
794#[derive(Debug, Clone, Serialize, Deserialize)]
795#[serde(untagged)]
796pub enum ClaimRewardsError {
797    DefaultResponse(models::ErrorSchema),
798    UnknownValue(serde_json::Value),
799}
800
801/// struct for typed errors of method [`get_all_delegations`]
802#[derive(Debug, Clone, Serialize, Deserialize)]
803#[serde(untagged)]
804pub enum GetAllDelegationsError {
805    DefaultResponse(models::ErrorSchema),
806    UnknownValue(serde_json::Value),
807}
808
809/// struct for typed errors of method [`get_chain_info`]
810#[derive(Debug, Clone, Serialize, Deserialize)]
811#[serde(untagged)]
812pub enum GetChainInfoError {
813    DefaultResponse(models::ErrorSchema),
814    UnknownValue(serde_json::Value),
815}
816
817/// struct for typed errors of method [`get_chains`]
818#[derive(Debug, Clone, Serialize, Deserialize)]
819#[serde(untagged)]
820pub enum GetChainsError {
821    DefaultResponse(models::ErrorSchema),
822    UnknownValue(serde_json::Value),
823}
824
825/// struct for typed errors of method [`get_delegation_by_id`]
826#[derive(Debug, Clone, Serialize, Deserialize)]
827#[serde(untagged)]
828pub enum GetDelegationByIdError {
829    DefaultResponse(models::ErrorSchema),
830    UnknownValue(serde_json::Value),
831}
832
833/// struct for typed errors of method [`get_providers`]
834#[derive(Debug, Clone, Serialize, Deserialize)]
835#[serde(untagged)]
836pub enum GetProvidersError {
837    DefaultResponse(models::ErrorSchema),
838    UnknownValue(serde_json::Value),
839}
840
841/// struct for typed errors of method [`get_summary`]
842#[derive(Debug, Clone, Serialize, Deserialize)]
843#[serde(untagged)]
844pub enum GetSummaryError {
845    DefaultResponse(models::ErrorSchema),
846    UnknownValue(serde_json::Value),
847}
848
849/// struct for typed errors of method [`get_summary_by_vault`]
850#[derive(Debug, Clone, Serialize, Deserialize)]
851#[serde(untagged)]
852pub enum GetSummaryByVaultError {
853    DefaultResponse(models::ErrorSchema),
854    UnknownValue(serde_json::Value),
855}
856
857/// struct for typed errors of method [`split`]
858#[derive(Debug, Clone, Serialize, Deserialize)]
859#[serde(untagged)]
860pub enum SplitError {
861    DefaultResponse(models::ErrorSchema),
862    UnknownValue(serde_json::Value),
863}
864
865/// struct for typed errors of method [`stake`]
866#[derive(Debug, Clone, Serialize, Deserialize)]
867#[serde(untagged)]
868pub enum StakeError {
869    DefaultResponse(models::ErrorSchema),
870    UnknownValue(serde_json::Value),
871}
872
873/// struct for typed errors of method [`unstake`]
874#[derive(Debug, Clone, Serialize, Deserialize)]
875#[serde(untagged)]
876pub enum UnstakeError {
877    DefaultResponse(models::ErrorSchema),
878    UnknownValue(serde_json::Value),
879}
880
881/// struct for typed errors of method [`withdraw`]
882#[derive(Debug, Clone, Serialize, Deserialize)]
883#[serde(untagged)]
884pub enum WithdrawError {
885    DefaultResponse(models::ErrorSchema),
886    UnknownValue(serde_json::Value),
887}