Skip to main content

binance_sdk/staking/rest_api/apis/
on_chain_yields_api.rs

1/*
2 * Staking REST API
3 *
4 * Subscribe to staking products, track positions, and query rewards via the Binance Staking API.
5 *
6 * The version of the OpenAPI document: 1.0.0
7 *
8 *
9 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10 * https://openapi-generator.tech
11 * Do not edit the class manually.
12 */
13
14#![allow(unused_imports)]
15use async_trait::async_trait;
16use derive_builder::Builder;
17use reqwest;
18use rust_decimal::prelude::*;
19use serde::{Deserialize, Serialize};
20use serde_json::{Value, json};
21use std::collections::BTreeMap;
22
23use crate::common::{
24    config::ConfigurationRestApi,
25    models::{ParamBuildError, RestApiResponse},
26    utils::send_request,
27};
28use crate::staking::rest_api::models;
29
30const HAS_TIME_UNIT: bool = false;
31
32#[async_trait]
33pub trait OnChainYieldsApi: Send + Sync {
34    async fn get_on_chain_yields_locked_personal_left_quota(
35        &self,
36        params: GetOnChainYieldsLockedPersonalLeftQuotaParams,
37    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedPersonalLeftQuotaResponse>>;
38    async fn get_on_chain_yields_locked_product_list(
39        &self,
40        params: GetOnChainYieldsLockedProductListParams,
41    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedProductListResponse>>;
42    async fn get_on_chain_yields_locked_product_position(
43        &self,
44        params: GetOnChainYieldsLockedProductPositionParams,
45    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedProductPositionResponse>>;
46    async fn get_on_chain_yields_locked_redemption_record(
47        &self,
48        params: GetOnChainYieldsLockedRedemptionRecordParams,
49    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedRedemptionRecordResponse>>;
50    async fn get_on_chain_yields_locked_rewards_history(
51        &self,
52        params: GetOnChainYieldsLockedRewardsHistoryParams,
53    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedRewardsHistoryResponse>>;
54    async fn get_on_chain_yields_locked_subscription_preview(
55        &self,
56        params: GetOnChainYieldsLockedSubscriptionPreviewParams,
57    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedSubscriptionPreviewResponse>>;
58    async fn get_on_chain_yields_locked_subscription_record(
59        &self,
60        params: GetOnChainYieldsLockedSubscriptionRecordParams,
61    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedSubscriptionRecordResponse>>;
62    async fn on_chain_yields_account(
63        &self,
64        params: OnChainYieldsAccountParams,
65    ) -> anyhow::Result<RestApiResponse<models::OnChainYieldsAccountResponse>>;
66    async fn redeem_on_chain_yields_locked_product(
67        &self,
68        params: RedeemOnChainYieldsLockedProductParams,
69    ) -> anyhow::Result<RestApiResponse<models::RedeemOnChainYieldsLockedProductResponse>>;
70    async fn set_on_chain_yields_locked_auto_subscribe(
71        &self,
72        params: SetOnChainYieldsLockedAutoSubscribeParams,
73    ) -> anyhow::Result<RestApiResponse<models::SetOnChainYieldsLockedAutoSubscribeResponse>>;
74    async fn set_on_chain_yields_locked_product_redeem_option(
75        &self,
76        params: SetOnChainYieldsLockedProductRedeemOptionParams,
77    ) -> anyhow::Result<RestApiResponse<models::SetOnChainYieldsLockedProductRedeemOptionResponse>>;
78    async fn subscribe_on_chain_yields_locked_product(
79        &self,
80        params: SubscribeOnChainYieldsLockedProductParams,
81    ) -> anyhow::Result<RestApiResponse<models::SubscribeOnChainYieldsLockedProductResponse>>;
82}
83
84#[derive(Debug, Clone)]
85pub struct OnChainYieldsApiClient {
86    configuration: ConfigurationRestApi,
87}
88
89impl OnChainYieldsApiClient {
90    pub fn new(configuration: ConfigurationRestApi) -> Self {
91        Self { configuration }
92    }
93}
94
95#[allow(non_camel_case_types)]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97pub enum SetOnChainYieldsLockedProductRedeemOptionRedeemToEnum {
98    #[serde(rename = "SPOT")]
99    Spot,
100    #[serde(rename = "FLEXIBLE")]
101    Flexible,
102}
103
104impl SetOnChainYieldsLockedProductRedeemOptionRedeemToEnum {
105    #[must_use]
106    pub fn as_str(&self) -> &'static str {
107        match self {
108            Self::Spot => "SPOT",
109            Self::Flexible => "FLEXIBLE",
110        }
111    }
112}
113
114impl std::str::FromStr for SetOnChainYieldsLockedProductRedeemOptionRedeemToEnum {
115    type Err = Box<dyn std::error::Error + Send + Sync>;
116
117    fn from_str(s: &str) -> Result<Self, Self::Err> {
118        match s {
119            "SPOT" => Ok(Self::Spot),
120            "FLEXIBLE" => Ok(Self::Flexible),
121            other => Err(format!(
122                "invalid SetOnChainYieldsLockedProductRedeemOptionRedeemToEnum: {}",
123                other
124            )
125            .into()),
126        }
127    }
128}
129
130#[allow(non_camel_case_types)]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132pub enum SubscribeOnChainYieldsLockedProductSourceAccountEnum {
133    #[serde(rename = "SPOT")]
134    Spot,
135    #[serde(rename = "FUND")]
136    Fund,
137    #[serde(rename = "ALL")]
138    All,
139}
140
141impl SubscribeOnChainYieldsLockedProductSourceAccountEnum {
142    #[must_use]
143    pub fn as_str(&self) -> &'static str {
144        match self {
145            Self::Spot => "SPOT",
146            Self::Fund => "FUND",
147            Self::All => "ALL",
148        }
149    }
150}
151
152impl std::str::FromStr for SubscribeOnChainYieldsLockedProductSourceAccountEnum {
153    type Err = Box<dyn std::error::Error + Send + Sync>;
154
155    fn from_str(s: &str) -> Result<Self, Self::Err> {
156        match s {
157            "SPOT" => Ok(Self::Spot),
158            "FUND" => Ok(Self::Fund),
159            "ALL" => Ok(Self::All),
160            other => Err(format!(
161                "invalid SubscribeOnChainYieldsLockedProductSourceAccountEnum: {}",
162                other
163            )
164            .into()),
165        }
166    }
167}
168
169#[allow(non_camel_case_types)]
170#[derive(Debug, Clone, Serialize, Deserialize)]
171pub enum SubscribeOnChainYieldsLockedProductRedeemToEnum {
172    #[serde(rename = "SPOT")]
173    Spot,
174    #[serde(rename = "FLEXIBLE")]
175    Flexible,
176}
177
178impl SubscribeOnChainYieldsLockedProductRedeemToEnum {
179    #[must_use]
180    pub fn as_str(&self) -> &'static str {
181        match self {
182            Self::Spot => "SPOT",
183            Self::Flexible => "FLEXIBLE",
184        }
185    }
186}
187
188impl std::str::FromStr for SubscribeOnChainYieldsLockedProductRedeemToEnum {
189    type Err = Box<dyn std::error::Error + Send + Sync>;
190
191    fn from_str(s: &str) -> Result<Self, Self::Err> {
192        match s {
193            "SPOT" => Ok(Self::Spot),
194            "FLEXIBLE" => Ok(Self::Flexible),
195            other => Err(format!(
196                "invalid SubscribeOnChainYieldsLockedProductRedeemToEnum: {}",
197                other
198            )
199            .into()),
200        }
201    }
202}
203
204/// Request parameters for the [`get_on_chain_yields_locked_personal_left_quota`] operation.
205///
206/// This struct holds all of the inputs you can pass when calling
207/// [`get_on_chain_yields_locked_personal_left_quota`](#method.get_on_chain_yields_locked_personal_left_quota).
208#[derive(Clone, Debug, Builder, Deserialize)]
209#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
210pub struct GetOnChainYieldsLockedPersonalLeftQuotaParams {
211    ///
212    /// The `project_id` parameter.
213    ///
214    /// This field is **required.
215    #[builder(setter(into))]
216    #[serde(rename = "projectId")]
217    pub project_id: String,
218    /// Request validity window in milliseconds.
219    ///
220    /// This field is **optional.
221    #[builder(setter(into), default)]
222    #[serde(rename = "recvWindow", default)]
223    pub recv_window: Option<i64>,
224}
225
226impl GetOnChainYieldsLockedPersonalLeftQuotaParams {
227    /// Create a builder for [`get_on_chain_yields_locked_personal_left_quota`].
228    ///
229    /// Required parameters:
230    ///
231    /// * `project_id` — String
232    ///
233    #[must_use]
234    pub fn builder(project_id: String) -> GetOnChainYieldsLockedPersonalLeftQuotaParamsBuilder {
235        GetOnChainYieldsLockedPersonalLeftQuotaParamsBuilder::default().project_id(project_id)
236    }
237}
238/// Request parameters for the [`get_on_chain_yields_locked_product_list`] operation.
239///
240/// This struct holds all of the inputs you can pass when calling
241/// [`get_on_chain_yields_locked_product_list`](#method.get_on_chain_yields_locked_product_list).
242#[derive(Clone, Debug, Builder, Deserialize, Default)]
243#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
244pub struct GetOnChainYieldsLockedProductListParams {
245    ///
246    /// The `asset` parameter.
247    ///
248    /// This field is **optional.
249    #[builder(setter(into), default)]
250    #[serde(rename = "asset", default)]
251    pub asset: Option<String>,
252    /// Currently querying page
253    ///
254    /// This field is **optional.
255    #[builder(setter(into), default)]
256    #[serde(rename = "current", default)]
257    pub current: Option<i64>,
258    /// Number of results per page.
259    ///
260    /// This field is **optional.
261    #[builder(setter(into), default)]
262    #[serde(rename = "size", default)]
263    pub size: Option<i64>,
264    /// Request validity window in milliseconds.
265    ///
266    /// This field is **optional.
267    #[builder(setter(into), default)]
268    #[serde(rename = "recvWindow", default)]
269    pub recv_window: Option<i64>,
270}
271
272impl GetOnChainYieldsLockedProductListParams {
273    /// Create a builder for [`get_on_chain_yields_locked_product_list`].
274    ///
275    #[must_use]
276    pub fn builder() -> GetOnChainYieldsLockedProductListParamsBuilder {
277        GetOnChainYieldsLockedProductListParamsBuilder::default()
278    }
279}
280/// Request parameters for the [`get_on_chain_yields_locked_product_position`] operation.
281///
282/// This struct holds all of the inputs you can pass when calling
283/// [`get_on_chain_yields_locked_product_position`](#method.get_on_chain_yields_locked_product_position).
284#[derive(Clone, Debug, Builder, Deserialize, Default)]
285#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
286pub struct GetOnChainYieldsLockedProductPositionParams {
287    ///
288    /// The `asset` parameter.
289    ///
290    /// This field is **optional.
291    #[builder(setter(into), default)]
292    #[serde(rename = "asset", default)]
293    pub asset: Option<String>,
294    ///
295    /// The `position_id` parameter.
296    ///
297    /// This field is **optional.
298    #[builder(setter(into), default)]
299    #[serde(rename = "positionId", default)]
300    pub position_id: Option<String>,
301    ///
302    /// The `project_id` parameter.
303    ///
304    /// This field is **optional.
305    #[builder(setter(into), default)]
306    #[serde(rename = "projectId", default)]
307    pub project_id: Option<String>,
308    /// Currently querying page
309    ///
310    /// This field is **optional.
311    #[builder(setter(into), default)]
312    #[serde(rename = "current", default)]
313    pub current: Option<i64>,
314    /// Number of results per page.
315    ///
316    /// This field is **optional.
317    #[builder(setter(into), default)]
318    #[serde(rename = "size", default)]
319    pub size: Option<i64>,
320    /// Request validity window in milliseconds.
321    ///
322    /// This field is **optional.
323    #[builder(setter(into), default)]
324    #[serde(rename = "recvWindow", default)]
325    pub recv_window: Option<i64>,
326}
327
328impl GetOnChainYieldsLockedProductPositionParams {
329    /// Create a builder for [`get_on_chain_yields_locked_product_position`].
330    ///
331    #[must_use]
332    pub fn builder() -> GetOnChainYieldsLockedProductPositionParamsBuilder {
333        GetOnChainYieldsLockedProductPositionParamsBuilder::default()
334    }
335}
336/// Request parameters for the [`get_on_chain_yields_locked_redemption_record`] operation.
337///
338/// This struct holds all of the inputs you can pass when calling
339/// [`get_on_chain_yields_locked_redemption_record`](#method.get_on_chain_yields_locked_redemption_record).
340#[derive(Clone, Debug, Builder, Deserialize, Default)]
341#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
342pub struct GetOnChainYieldsLockedRedemptionRecordParams {
343    ///
344    /// The `position_id` parameter.
345    ///
346    /// This field is **optional.
347    #[builder(setter(into), default)]
348    #[serde(rename = "positionId", default)]
349    pub position_id: Option<String>,
350    ///
351    /// The `redeem_id` parameter.
352    ///
353    /// This field is **optional.
354    #[builder(setter(into), default)]
355    #[serde(rename = "redeemId", default)]
356    pub redeem_id: Option<String>,
357    ///
358    /// The `asset` parameter.
359    ///
360    /// This field is **optional.
361    #[builder(setter(into), default)]
362    #[serde(rename = "asset", default)]
363    pub asset: Option<String>,
364    ///
365    /// The `start_time` parameter.
366    ///
367    /// This field is **optional.
368    #[builder(setter(into), default)]
369    #[serde(rename = "startTime", default)]
370    pub start_time: Option<i64>,
371    ///
372    /// The `end_time` parameter.
373    ///
374    /// This field is **optional.
375    #[builder(setter(into), default)]
376    #[serde(rename = "endTime", default)]
377    pub end_time: Option<i64>,
378    /// Currently querying page
379    ///
380    /// This field is **optional.
381    #[builder(setter(into), default)]
382    #[serde(rename = "current", default)]
383    pub current: Option<i64>,
384    ///
385    /// The `size` parameter.
386    ///
387    /// This field is **optional.
388    #[builder(setter(into), default)]
389    #[serde(rename = "size", default)]
390    pub size: Option<i64>,
391    /// Request validity window in milliseconds.
392    ///
393    /// This field is **optional.
394    #[builder(setter(into), default)]
395    #[serde(rename = "recvWindow", default)]
396    pub recv_window: Option<i64>,
397}
398
399impl GetOnChainYieldsLockedRedemptionRecordParams {
400    /// Create a builder for [`get_on_chain_yields_locked_redemption_record`].
401    ///
402    #[must_use]
403    pub fn builder() -> GetOnChainYieldsLockedRedemptionRecordParamsBuilder {
404        GetOnChainYieldsLockedRedemptionRecordParamsBuilder::default()
405    }
406}
407/// Request parameters for the [`get_on_chain_yields_locked_rewards_history`] operation.
408///
409/// This struct holds all of the inputs you can pass when calling
410/// [`get_on_chain_yields_locked_rewards_history`](#method.get_on_chain_yields_locked_rewards_history).
411#[derive(Clone, Debug, Builder, Deserialize, Default)]
412#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
413pub struct GetOnChainYieldsLockedRewardsHistoryParams {
414    ///
415    /// The `position_id` parameter.
416    ///
417    /// This field is **optional.
418    #[builder(setter(into), default)]
419    #[serde(rename = "positionId", default)]
420    pub position_id: Option<String>,
421    ///
422    /// The `asset` parameter.
423    ///
424    /// This field is **optional.
425    #[builder(setter(into), default)]
426    #[serde(rename = "asset", default)]
427    pub asset: Option<String>,
428    ///
429    /// The `start_time` parameter.
430    ///
431    /// This field is **optional.
432    #[builder(setter(into), default)]
433    #[serde(rename = "startTime", default)]
434    pub start_time: Option<i64>,
435    ///
436    /// The `end_time` parameter.
437    ///
438    /// This field is **optional.
439    #[builder(setter(into), default)]
440    #[serde(rename = "endTime", default)]
441    pub end_time: Option<i64>,
442    /// Currently querying page
443    ///
444    /// This field is **optional.
445    #[builder(setter(into), default)]
446    #[serde(rename = "current", default)]
447    pub current: Option<i64>,
448    ///
449    /// The `size` parameter.
450    ///
451    /// This field is **optional.
452    #[builder(setter(into), default)]
453    #[serde(rename = "size", default)]
454    pub size: Option<i64>,
455    /// Request validity window in milliseconds.
456    ///
457    /// This field is **optional.
458    #[builder(setter(into), default)]
459    #[serde(rename = "recvWindow", default)]
460    pub recv_window: Option<i64>,
461}
462
463impl GetOnChainYieldsLockedRewardsHistoryParams {
464    /// Create a builder for [`get_on_chain_yields_locked_rewards_history`].
465    ///
466    #[must_use]
467    pub fn builder() -> GetOnChainYieldsLockedRewardsHistoryParamsBuilder {
468        GetOnChainYieldsLockedRewardsHistoryParamsBuilder::default()
469    }
470}
471/// Request parameters for the [`get_on_chain_yields_locked_subscription_preview`] operation.
472///
473/// This struct holds all of the inputs you can pass when calling
474/// [`get_on_chain_yields_locked_subscription_preview`](#method.get_on_chain_yields_locked_subscription_preview).
475#[derive(Clone, Debug, Builder, Deserialize)]
476#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
477pub struct GetOnChainYieldsLockedSubscriptionPreviewParams {
478    ///
479    /// The `project_id` parameter.
480    ///
481    /// This field is **required.
482    #[builder(setter(into))]
483    #[serde(rename = "projectId")]
484    pub project_id: String,
485    ///
486    /// The `amount` parameter.
487    ///
488    /// This field is **required.
489    #[builder(setter(into))]
490    #[serde(rename = "amount")]
491    pub amount: rust_decimal::Decimal,
492    ///
493    /// The `auto_subscribe` parameter.
494    ///
495    /// This field is **optional.
496    #[builder(setter(into), default)]
497    #[serde(rename = "autoSubscribe", default)]
498    pub auto_subscribe: Option<bool>,
499    /// Request validity window in milliseconds.
500    ///
501    /// This field is **optional.
502    #[builder(setter(into), default)]
503    #[serde(rename = "recvWindow", default)]
504    pub recv_window: Option<i64>,
505}
506
507impl GetOnChainYieldsLockedSubscriptionPreviewParams {
508    /// Create a builder for [`get_on_chain_yields_locked_subscription_preview`].
509    ///
510    /// Required parameters:
511    ///
512    /// * `project_id` — String
513    /// * `amount` — `rust_decimal::Decimal`
514    ///
515    #[must_use]
516    pub fn builder(
517        project_id: String,
518        amount: rust_decimal::Decimal,
519    ) -> GetOnChainYieldsLockedSubscriptionPreviewParamsBuilder {
520        GetOnChainYieldsLockedSubscriptionPreviewParamsBuilder::default()
521            .project_id(project_id)
522            .amount(amount)
523    }
524}
525/// Request parameters for the [`get_on_chain_yields_locked_subscription_record`] operation.
526///
527/// This struct holds all of the inputs you can pass when calling
528/// [`get_on_chain_yields_locked_subscription_record`](#method.get_on_chain_yields_locked_subscription_record).
529#[derive(Clone, Debug, Builder, Deserialize, Default)]
530#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
531pub struct GetOnChainYieldsLockedSubscriptionRecordParams {
532    ///
533    /// The `purchase_id` parameter.
534    ///
535    /// This field is **optional.
536    #[builder(setter(into), default)]
537    #[serde(rename = "purchaseId", default)]
538    pub purchase_id: Option<String>,
539    ///
540    /// The `client_id` parameter.
541    ///
542    /// This field is **optional.
543    #[builder(setter(into), default)]
544    #[serde(rename = "clientId", default)]
545    pub client_id: Option<String>,
546    ///
547    /// The `asset` parameter.
548    ///
549    /// This field is **optional.
550    #[builder(setter(into), default)]
551    #[serde(rename = "asset", default)]
552    pub asset: Option<String>,
553    ///
554    /// The `start_time` parameter.
555    ///
556    /// This field is **optional.
557    #[builder(setter(into), default)]
558    #[serde(rename = "startTime", default)]
559    pub start_time: Option<i64>,
560    ///
561    /// The `end_time` parameter.
562    ///
563    /// This field is **optional.
564    #[builder(setter(into), default)]
565    #[serde(rename = "endTime", default)]
566    pub end_time: Option<i64>,
567    /// Currently querying page
568    ///
569    /// This field is **optional.
570    #[builder(setter(into), default)]
571    #[serde(rename = "current", default)]
572    pub current: Option<i64>,
573    ///
574    /// The `size` parameter.
575    ///
576    /// This field is **optional.
577    #[builder(setter(into), default)]
578    #[serde(rename = "size", default)]
579    pub size: Option<i64>,
580    /// Request validity window in milliseconds.
581    ///
582    /// This field is **optional.
583    #[builder(setter(into), default)]
584    #[serde(rename = "recvWindow", default)]
585    pub recv_window: Option<i64>,
586}
587
588impl GetOnChainYieldsLockedSubscriptionRecordParams {
589    /// Create a builder for [`get_on_chain_yields_locked_subscription_record`].
590    ///
591    #[must_use]
592    pub fn builder() -> GetOnChainYieldsLockedSubscriptionRecordParamsBuilder {
593        GetOnChainYieldsLockedSubscriptionRecordParamsBuilder::default()
594    }
595}
596/// Request parameters for the [`on_chain_yields_account`] operation.
597///
598/// This struct holds all of the inputs you can pass when calling
599/// [`on_chain_yields_account`](#method.on_chain_yields_account).
600#[derive(Clone, Debug, Builder, Deserialize, Default)]
601#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
602pub struct OnChainYieldsAccountParams {
603    /// The value cannot be greater than `60000`
604    ///
605    /// This field is **optional.
606    #[builder(setter(into), default)]
607    #[serde(rename = "recvWindow", default)]
608    pub recv_window: Option<i64>,
609}
610
611impl OnChainYieldsAccountParams {
612    /// Create a builder for [`on_chain_yields_account`].
613    ///
614    #[must_use]
615    pub fn builder() -> OnChainYieldsAccountParamsBuilder {
616        OnChainYieldsAccountParamsBuilder::default()
617    }
618}
619/// Request parameters for the [`redeem_on_chain_yields_locked_product`] operation.
620///
621/// This struct holds all of the inputs you can pass when calling
622/// [`redeem_on_chain_yields_locked_product`](#method.redeem_on_chain_yields_locked_product).
623#[derive(Clone, Debug, Builder, Deserialize)]
624#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
625pub struct RedeemOnChainYieldsLockedProductParams {
626    /// Locked product position ID
627    ///
628    /// This field is **required.
629    #[builder(setter(into))]
630    #[serde(rename = "positionId")]
631    pub position_id: String,
632    ///
633    /// The `channel_id` parameter.
634    ///
635    /// This field is **optional.
636    #[builder(setter(into), default)]
637    #[serde(rename = "channelId", default)]
638    pub channel_id: Option<String>,
639    /// Request validity window in milliseconds.
640    ///
641    /// This field is **optional.
642    #[builder(setter(into), default)]
643    #[serde(rename = "recvWindow", default)]
644    pub recv_window: Option<i64>,
645}
646
647impl RedeemOnChainYieldsLockedProductParams {
648    /// Create a builder for [`redeem_on_chain_yields_locked_product`].
649    ///
650    /// Required parameters:
651    ///
652    /// * `position_id` — Locked product position ID
653    ///
654    #[must_use]
655    pub fn builder(position_id: String) -> RedeemOnChainYieldsLockedProductParamsBuilder {
656        RedeemOnChainYieldsLockedProductParamsBuilder::default().position_id(position_id)
657    }
658}
659/// Request parameters for the [`set_on_chain_yields_locked_auto_subscribe`] operation.
660///
661/// This struct holds all of the inputs you can pass when calling
662/// [`set_on_chain_yields_locked_auto_subscribe`](#method.set_on_chain_yields_locked_auto_subscribe).
663#[derive(Clone, Debug, Builder, Deserialize)]
664#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
665pub struct SetOnChainYieldsLockedAutoSubscribeParams {
666    ///
667    /// The `position_id` parameter.
668    ///
669    /// This field is **required.
670    #[builder(setter(into))]
671    #[serde(rename = "positionId")]
672    pub position_id: String,
673    ///
674    /// The `auto_subscribe` parameter.
675    ///
676    /// This field is **required.
677    #[builder(setter(into))]
678    #[serde(rename = "autoSubscribe")]
679    pub auto_subscribe: bool,
680    /// Request validity window in milliseconds.
681    ///
682    /// This field is **optional.
683    #[builder(setter(into), default)]
684    #[serde(rename = "recvWindow", default)]
685    pub recv_window: Option<i64>,
686}
687
688impl SetOnChainYieldsLockedAutoSubscribeParams {
689    /// Create a builder for [`set_on_chain_yields_locked_auto_subscribe`].
690    ///
691    /// Required parameters:
692    ///
693    /// * `position_id` — String
694    /// * `auto_subscribe` — bool
695    ///
696    #[must_use]
697    pub fn builder(
698        position_id: String,
699        auto_subscribe: bool,
700    ) -> SetOnChainYieldsLockedAutoSubscribeParamsBuilder {
701        SetOnChainYieldsLockedAutoSubscribeParamsBuilder::default()
702            .position_id(position_id)
703            .auto_subscribe(auto_subscribe)
704    }
705}
706/// Request parameters for the [`set_on_chain_yields_locked_product_redeem_option`] operation.
707///
708/// This struct holds all of the inputs you can pass when calling
709/// [`set_on_chain_yields_locked_product_redeem_option`](#method.set_on_chain_yields_locked_product_redeem_option).
710#[derive(Clone, Debug, Builder, Deserialize)]
711#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
712pub struct SetOnChainYieldsLockedProductRedeemOptionParams {
713    ///
714    /// The `position_id` parameter.
715    ///
716    /// This field is **required.
717    #[builder(setter(into))]
718    #[serde(rename = "positionId")]
719    pub position_id: String,
720    ///
721    /// The `redeem_to` parameter.
722    ///
723    /// This field is **required.
724    #[builder(setter(into))]
725    #[serde(rename = "redeemTo")]
726    pub redeem_to: SetOnChainYieldsLockedProductRedeemOptionRedeemToEnum,
727    /// Request validity window in milliseconds.
728    ///
729    /// This field is **optional.
730    #[builder(setter(into), default)]
731    #[serde(rename = "recvWindow", default)]
732    pub recv_window: Option<i64>,
733}
734
735impl SetOnChainYieldsLockedProductRedeemOptionParams {
736    /// Create a builder for [`set_on_chain_yields_locked_product_redeem_option`].
737    ///
738    /// Required parameters:
739    ///
740    /// * `position_id` — String
741    /// * `redeem_to` — String
742    ///
743    #[must_use]
744    pub fn builder(
745        position_id: String,
746        redeem_to: SetOnChainYieldsLockedProductRedeemOptionRedeemToEnum,
747    ) -> SetOnChainYieldsLockedProductRedeemOptionParamsBuilder {
748        SetOnChainYieldsLockedProductRedeemOptionParamsBuilder::default()
749            .position_id(position_id)
750            .redeem_to(redeem_to)
751    }
752}
753/// Request parameters for the [`subscribe_on_chain_yields_locked_product`] operation.
754///
755/// This struct holds all of the inputs you can pass when calling
756/// [`subscribe_on_chain_yields_locked_product`](#method.subscribe_on_chain_yields_locked_product).
757#[derive(Clone, Debug, Builder, Deserialize)]
758#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
759pub struct SubscribeOnChainYieldsLockedProductParams {
760    ///
761    /// The `project_id` parameter.
762    ///
763    /// This field is **required.
764    #[builder(setter(into))]
765    #[serde(rename = "projectId")]
766    pub project_id: String,
767    ///
768    /// The `amount` parameter.
769    ///
770    /// This field is **required.
771    #[builder(setter(into))]
772    #[serde(rename = "amount")]
773    pub amount: rust_decimal::Decimal,
774    ///
775    /// The `auto_subscribe` parameter.
776    ///
777    /// This field is **optional.
778    #[builder(setter(into), default)]
779    #[serde(rename = "autoSubscribe", default)]
780    pub auto_subscribe: Option<bool>,
781    ///
782    /// The `source_account` parameter.
783    ///
784    /// This field is **optional.
785    #[builder(setter(into), default)]
786    #[serde(rename = "sourceAccount", default)]
787    pub source_account: Option<SubscribeOnChainYieldsLockedProductSourceAccountEnum>,
788    /// Takes effect when Auto Subscribe is false
789    ///
790    /// This field is **optional.
791    #[builder(setter(into), default)]
792    #[serde(rename = "redeemTo", default)]
793    pub redeem_to: Option<SubscribeOnChainYieldsLockedProductRedeemToEnum>,
794    ///
795    /// The `channel_id` parameter.
796    ///
797    /// This field is **optional.
798    #[builder(setter(into), default)]
799    #[serde(rename = "channelId", default)]
800    pub channel_id: Option<String>,
801    ///
802    /// The `client_id` parameter.
803    ///
804    /// This field is **optional.
805    #[builder(setter(into), default)]
806    #[serde(rename = "clientId", default)]
807    pub client_id: Option<String>,
808    /// Request validity window in milliseconds.
809    ///
810    /// This field is **optional.
811    #[builder(setter(into), default)]
812    #[serde(rename = "recvWindow", default)]
813    pub recv_window: Option<i64>,
814}
815
816impl SubscribeOnChainYieldsLockedProductParams {
817    /// Create a builder for [`subscribe_on_chain_yields_locked_product`].
818    ///
819    /// Required parameters:
820    ///
821    /// * `project_id` — String
822    /// * `amount` — `rust_decimal::Decimal`
823    ///
824    #[must_use]
825    pub fn builder(
826        project_id: String,
827        amount: rust_decimal::Decimal,
828    ) -> SubscribeOnChainYieldsLockedProductParamsBuilder {
829        SubscribeOnChainYieldsLockedProductParamsBuilder::default()
830            .project_id(project_id)
831            .amount(amount)
832    }
833}
834
835#[async_trait]
836impl OnChainYieldsApi for OnChainYieldsApiClient {
837    async fn get_on_chain_yields_locked_personal_left_quota(
838        &self,
839        params: GetOnChainYieldsLockedPersonalLeftQuotaParams,
840    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedPersonalLeftQuotaResponse>>
841    {
842        let GetOnChainYieldsLockedPersonalLeftQuotaParams {
843            project_id,
844            recv_window,
845        } = params;
846
847        let mut query_params = BTreeMap::new();
848        let body_params = BTreeMap::new();
849
850        query_params.insert("projectId".to_string(), json!(project_id));
851
852        if let Some(rw) = recv_window {
853            query_params.insert("recvWindow".to_string(), json!(rw));
854        }
855
856        send_request::<models::GetOnChainYieldsLockedPersonalLeftQuotaResponse>(
857            &self.configuration,
858            "/sapi/v1/onchain-yields/locked/personalLeftQuota",
859            reqwest::Method::GET,
860            query_params,
861            body_params,
862            if HAS_TIME_UNIT {
863                self.configuration.time_unit
864            } else {
865                None
866            },
867            true,
868        )
869        .await
870    }
871
872    async fn get_on_chain_yields_locked_product_list(
873        &self,
874        params: GetOnChainYieldsLockedProductListParams,
875    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedProductListResponse>> {
876        let GetOnChainYieldsLockedProductListParams {
877            asset,
878            current,
879            size,
880            recv_window,
881        } = params;
882
883        let mut query_params = BTreeMap::new();
884        let body_params = BTreeMap::new();
885
886        if let Some(rw) = asset {
887            query_params.insert("asset".to_string(), json!(rw));
888        }
889
890        if let Some(rw) = current {
891            query_params.insert("current".to_string(), json!(rw));
892        }
893
894        if let Some(rw) = size {
895            query_params.insert("size".to_string(), json!(rw));
896        }
897
898        if let Some(rw) = recv_window {
899            query_params.insert("recvWindow".to_string(), json!(rw));
900        }
901
902        send_request::<models::GetOnChainYieldsLockedProductListResponse>(
903            &self.configuration,
904            "/sapi/v1/onchain-yields/locked/list",
905            reqwest::Method::GET,
906            query_params,
907            body_params,
908            if HAS_TIME_UNIT {
909                self.configuration.time_unit
910            } else {
911                None
912            },
913            true,
914        )
915        .await
916    }
917
918    async fn get_on_chain_yields_locked_product_position(
919        &self,
920        params: GetOnChainYieldsLockedProductPositionParams,
921    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedProductPositionResponse>>
922    {
923        let GetOnChainYieldsLockedProductPositionParams {
924            asset,
925            position_id,
926            project_id,
927            current,
928            size,
929            recv_window,
930        } = params;
931
932        let mut query_params = BTreeMap::new();
933        let body_params = BTreeMap::new();
934
935        if let Some(rw) = asset {
936            query_params.insert("asset".to_string(), json!(rw));
937        }
938
939        if let Some(rw) = position_id {
940            query_params.insert("positionId".to_string(), json!(rw));
941        }
942
943        if let Some(rw) = project_id {
944            query_params.insert("projectId".to_string(), json!(rw));
945        }
946
947        if let Some(rw) = current {
948            query_params.insert("current".to_string(), json!(rw));
949        }
950
951        if let Some(rw) = size {
952            query_params.insert("size".to_string(), json!(rw));
953        }
954
955        if let Some(rw) = recv_window {
956            query_params.insert("recvWindow".to_string(), json!(rw));
957        }
958
959        send_request::<models::GetOnChainYieldsLockedProductPositionResponse>(
960            &self.configuration,
961            "/sapi/v1/onchain-yields/locked/position",
962            reqwest::Method::GET,
963            query_params,
964            body_params,
965            if HAS_TIME_UNIT {
966                self.configuration.time_unit
967            } else {
968                None
969            },
970            true,
971        )
972        .await
973    }
974
975    async fn get_on_chain_yields_locked_redemption_record(
976        &self,
977        params: GetOnChainYieldsLockedRedemptionRecordParams,
978    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedRedemptionRecordResponse>>
979    {
980        let GetOnChainYieldsLockedRedemptionRecordParams {
981            position_id,
982            redeem_id,
983            asset,
984            start_time,
985            end_time,
986            current,
987            size,
988            recv_window,
989        } = params;
990
991        let mut query_params = BTreeMap::new();
992        let body_params = BTreeMap::new();
993
994        if let Some(rw) = position_id {
995            query_params.insert("positionId".to_string(), json!(rw));
996        }
997
998        if let Some(rw) = redeem_id {
999            query_params.insert("redeemId".to_string(), json!(rw));
1000        }
1001
1002        if let Some(rw) = asset {
1003            query_params.insert("asset".to_string(), json!(rw));
1004        }
1005
1006        if let Some(rw) = start_time {
1007            query_params.insert("startTime".to_string(), json!(rw));
1008        }
1009
1010        if let Some(rw) = end_time {
1011            query_params.insert("endTime".to_string(), json!(rw));
1012        }
1013
1014        if let Some(rw) = current {
1015            query_params.insert("current".to_string(), json!(rw));
1016        }
1017
1018        if let Some(rw) = size {
1019            query_params.insert("size".to_string(), json!(rw));
1020        }
1021
1022        if let Some(rw) = recv_window {
1023            query_params.insert("recvWindow".to_string(), json!(rw));
1024        }
1025
1026        send_request::<models::GetOnChainYieldsLockedRedemptionRecordResponse>(
1027            &self.configuration,
1028            "/sapi/v1/onchain-yields/locked/history/redemptionRecord",
1029            reqwest::Method::GET,
1030            query_params,
1031            body_params,
1032            if HAS_TIME_UNIT {
1033                self.configuration.time_unit
1034            } else {
1035                None
1036            },
1037            true,
1038        )
1039        .await
1040    }
1041
1042    async fn get_on_chain_yields_locked_rewards_history(
1043        &self,
1044        params: GetOnChainYieldsLockedRewardsHistoryParams,
1045    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedRewardsHistoryResponse>> {
1046        let GetOnChainYieldsLockedRewardsHistoryParams {
1047            position_id,
1048            asset,
1049            start_time,
1050            end_time,
1051            current,
1052            size,
1053            recv_window,
1054        } = params;
1055
1056        let mut query_params = BTreeMap::new();
1057        let body_params = BTreeMap::new();
1058
1059        if let Some(rw) = position_id {
1060            query_params.insert("positionId".to_string(), json!(rw));
1061        }
1062
1063        if let Some(rw) = asset {
1064            query_params.insert("asset".to_string(), json!(rw));
1065        }
1066
1067        if let Some(rw) = start_time {
1068            query_params.insert("startTime".to_string(), json!(rw));
1069        }
1070
1071        if let Some(rw) = end_time {
1072            query_params.insert("endTime".to_string(), json!(rw));
1073        }
1074
1075        if let Some(rw) = current {
1076            query_params.insert("current".to_string(), json!(rw));
1077        }
1078
1079        if let Some(rw) = size {
1080            query_params.insert("size".to_string(), json!(rw));
1081        }
1082
1083        if let Some(rw) = recv_window {
1084            query_params.insert("recvWindow".to_string(), json!(rw));
1085        }
1086
1087        send_request::<models::GetOnChainYieldsLockedRewardsHistoryResponse>(
1088            &self.configuration,
1089            "/sapi/v1/onchain-yields/locked/history/rewardsRecord",
1090            reqwest::Method::GET,
1091            query_params,
1092            body_params,
1093            if HAS_TIME_UNIT {
1094                self.configuration.time_unit
1095            } else {
1096                None
1097            },
1098            true,
1099        )
1100        .await
1101    }
1102
1103    async fn get_on_chain_yields_locked_subscription_preview(
1104        &self,
1105        params: GetOnChainYieldsLockedSubscriptionPreviewParams,
1106    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedSubscriptionPreviewResponse>>
1107    {
1108        let GetOnChainYieldsLockedSubscriptionPreviewParams {
1109            project_id,
1110            amount,
1111            auto_subscribe,
1112            recv_window,
1113        } = params;
1114
1115        let mut query_params = BTreeMap::new();
1116        let body_params = BTreeMap::new();
1117
1118        query_params.insert("projectId".to_string(), json!(project_id));
1119
1120        query_params.insert("amount".to_string(), json!(amount));
1121
1122        if let Some(rw) = auto_subscribe {
1123            query_params.insert("autoSubscribe".to_string(), json!(rw));
1124        }
1125
1126        if let Some(rw) = recv_window {
1127            query_params.insert("recvWindow".to_string(), json!(rw));
1128        }
1129
1130        send_request::<models::GetOnChainYieldsLockedSubscriptionPreviewResponse>(
1131            &self.configuration,
1132            "/sapi/v1/onchain-yields/locked/subscriptionPreview",
1133            reqwest::Method::GET,
1134            query_params,
1135            body_params,
1136            if HAS_TIME_UNIT {
1137                self.configuration.time_unit
1138            } else {
1139                None
1140            },
1141            true,
1142        )
1143        .await
1144    }
1145
1146    async fn get_on_chain_yields_locked_subscription_record(
1147        &self,
1148        params: GetOnChainYieldsLockedSubscriptionRecordParams,
1149    ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedSubscriptionRecordResponse>>
1150    {
1151        let GetOnChainYieldsLockedSubscriptionRecordParams {
1152            purchase_id,
1153            client_id,
1154            asset,
1155            start_time,
1156            end_time,
1157            current,
1158            size,
1159            recv_window,
1160        } = params;
1161
1162        let mut query_params = BTreeMap::new();
1163        let body_params = BTreeMap::new();
1164
1165        if let Some(rw) = purchase_id {
1166            query_params.insert("purchaseId".to_string(), json!(rw));
1167        }
1168
1169        if let Some(rw) = client_id {
1170            query_params.insert("clientId".to_string(), json!(rw));
1171        }
1172
1173        if let Some(rw) = asset {
1174            query_params.insert("asset".to_string(), json!(rw));
1175        }
1176
1177        if let Some(rw) = start_time {
1178            query_params.insert("startTime".to_string(), json!(rw));
1179        }
1180
1181        if let Some(rw) = end_time {
1182            query_params.insert("endTime".to_string(), json!(rw));
1183        }
1184
1185        if let Some(rw) = current {
1186            query_params.insert("current".to_string(), json!(rw));
1187        }
1188
1189        if let Some(rw) = size {
1190            query_params.insert("size".to_string(), json!(rw));
1191        }
1192
1193        if let Some(rw) = recv_window {
1194            query_params.insert("recvWindow".to_string(), json!(rw));
1195        }
1196
1197        send_request::<models::GetOnChainYieldsLockedSubscriptionRecordResponse>(
1198            &self.configuration,
1199            "/sapi/v1/onchain-yields/locked/history/subscriptionRecord",
1200            reqwest::Method::GET,
1201            query_params,
1202            body_params,
1203            if HAS_TIME_UNIT {
1204                self.configuration.time_unit
1205            } else {
1206                None
1207            },
1208            true,
1209        )
1210        .await
1211    }
1212
1213    async fn on_chain_yields_account(
1214        &self,
1215        params: OnChainYieldsAccountParams,
1216    ) -> anyhow::Result<RestApiResponse<models::OnChainYieldsAccountResponse>> {
1217        let OnChainYieldsAccountParams { recv_window } = params;
1218
1219        let mut query_params = BTreeMap::new();
1220        let body_params = BTreeMap::new();
1221
1222        if let Some(rw) = recv_window {
1223            query_params.insert("recvWindow".to_string(), json!(rw));
1224        }
1225
1226        send_request::<models::OnChainYieldsAccountResponse>(
1227            &self.configuration,
1228            "/sapi/v1/onchain-yields/account",
1229            reqwest::Method::GET,
1230            query_params,
1231            body_params,
1232            if HAS_TIME_UNIT {
1233                self.configuration.time_unit
1234            } else {
1235                None
1236            },
1237            true,
1238        )
1239        .await
1240    }
1241
1242    async fn redeem_on_chain_yields_locked_product(
1243        &self,
1244        params: RedeemOnChainYieldsLockedProductParams,
1245    ) -> anyhow::Result<RestApiResponse<models::RedeemOnChainYieldsLockedProductResponse>> {
1246        let RedeemOnChainYieldsLockedProductParams {
1247            position_id,
1248            channel_id,
1249            recv_window,
1250        } = params;
1251
1252        let mut query_params = BTreeMap::new();
1253        let body_params = BTreeMap::new();
1254
1255        query_params.insert("positionId".to_string(), json!(position_id));
1256
1257        if let Some(rw) = channel_id {
1258            query_params.insert("channelId".to_string(), json!(rw));
1259        }
1260
1261        if let Some(rw) = recv_window {
1262            query_params.insert("recvWindow".to_string(), json!(rw));
1263        }
1264
1265        send_request::<models::RedeemOnChainYieldsLockedProductResponse>(
1266            &self.configuration,
1267            "/sapi/v1/onchain-yields/locked/redeem",
1268            reqwest::Method::POST,
1269            query_params,
1270            body_params,
1271            if HAS_TIME_UNIT {
1272                self.configuration.time_unit
1273            } else {
1274                None
1275            },
1276            true,
1277        )
1278        .await
1279    }
1280
1281    async fn set_on_chain_yields_locked_auto_subscribe(
1282        &self,
1283        params: SetOnChainYieldsLockedAutoSubscribeParams,
1284    ) -> anyhow::Result<RestApiResponse<models::SetOnChainYieldsLockedAutoSubscribeResponse>> {
1285        let SetOnChainYieldsLockedAutoSubscribeParams {
1286            position_id,
1287            auto_subscribe,
1288            recv_window,
1289        } = params;
1290
1291        let mut query_params = BTreeMap::new();
1292        let body_params = BTreeMap::new();
1293
1294        query_params.insert("positionId".to_string(), json!(position_id));
1295
1296        query_params.insert("autoSubscribe".to_string(), json!(auto_subscribe));
1297
1298        if let Some(rw) = recv_window {
1299            query_params.insert("recvWindow".to_string(), json!(rw));
1300        }
1301
1302        send_request::<models::SetOnChainYieldsLockedAutoSubscribeResponse>(
1303            &self.configuration,
1304            "/sapi/v1/onchain-yields/locked/setAutoSubscribe",
1305            reqwest::Method::POST,
1306            query_params,
1307            body_params,
1308            if HAS_TIME_UNIT {
1309                self.configuration.time_unit
1310            } else {
1311                None
1312            },
1313            true,
1314        )
1315        .await
1316    }
1317
1318    async fn set_on_chain_yields_locked_product_redeem_option(
1319        &self,
1320        params: SetOnChainYieldsLockedProductRedeemOptionParams,
1321    ) -> anyhow::Result<RestApiResponse<models::SetOnChainYieldsLockedProductRedeemOptionResponse>>
1322    {
1323        let SetOnChainYieldsLockedProductRedeemOptionParams {
1324            position_id,
1325            redeem_to,
1326            recv_window,
1327        } = params;
1328
1329        let mut query_params = BTreeMap::new();
1330        let body_params = BTreeMap::new();
1331
1332        query_params.insert("positionId".to_string(), json!(position_id));
1333
1334        query_params.insert("redeemTo".to_string(), json!(redeem_to));
1335
1336        if let Some(rw) = recv_window {
1337            query_params.insert("recvWindow".to_string(), json!(rw));
1338        }
1339
1340        send_request::<models::SetOnChainYieldsLockedProductRedeemOptionResponse>(
1341            &self.configuration,
1342            "/sapi/v1/onchain-yields/locked/setRedeemOption",
1343            reqwest::Method::POST,
1344            query_params,
1345            body_params,
1346            if HAS_TIME_UNIT {
1347                self.configuration.time_unit
1348            } else {
1349                None
1350            },
1351            true,
1352        )
1353        .await
1354    }
1355
1356    async fn subscribe_on_chain_yields_locked_product(
1357        &self,
1358        params: SubscribeOnChainYieldsLockedProductParams,
1359    ) -> anyhow::Result<RestApiResponse<models::SubscribeOnChainYieldsLockedProductResponse>> {
1360        let SubscribeOnChainYieldsLockedProductParams {
1361            project_id,
1362            amount,
1363            auto_subscribe,
1364            source_account,
1365            redeem_to,
1366            channel_id,
1367            client_id,
1368            recv_window,
1369        } = params;
1370
1371        let mut query_params = BTreeMap::new();
1372        let body_params = BTreeMap::new();
1373
1374        query_params.insert("projectId".to_string(), json!(project_id));
1375
1376        query_params.insert("amount".to_string(), json!(amount));
1377
1378        if let Some(rw) = auto_subscribe {
1379            query_params.insert("autoSubscribe".to_string(), json!(rw));
1380        }
1381
1382        if let Some(rw) = source_account {
1383            query_params.insert("sourceAccount".to_string(), json!(rw));
1384        }
1385
1386        if let Some(rw) = redeem_to {
1387            query_params.insert("redeemTo".to_string(), json!(rw));
1388        }
1389
1390        if let Some(rw) = channel_id {
1391            query_params.insert("channelId".to_string(), json!(rw));
1392        }
1393
1394        if let Some(rw) = client_id {
1395            query_params.insert("clientId".to_string(), json!(rw));
1396        }
1397
1398        if let Some(rw) = recv_window {
1399            query_params.insert("recvWindow".to_string(), json!(rw));
1400        }
1401
1402        send_request::<models::SubscribeOnChainYieldsLockedProductResponse>(
1403            &self.configuration,
1404            "/sapi/v1/onchain-yields/locked/subscribe",
1405            reqwest::Method::POST,
1406            query_params,
1407            body_params,
1408            if HAS_TIME_UNIT {
1409                self.configuration.time_unit
1410            } else {
1411                None
1412            },
1413            true,
1414        )
1415        .await
1416    }
1417}
1418
1419#[cfg(all(test, feature = "staking"))]
1420mod tests {
1421    use super::*;
1422    use crate::TOKIO_SHARED_RT;
1423    use crate::{errors::ConnectorError, models::DataFuture, models::RestApiRateLimit};
1424    use async_trait::async_trait;
1425    use std::collections::HashMap;
1426
1427    struct DummyRestApiResponse<T> {
1428        inner: Box<dyn FnOnce() -> DataFuture<Result<T, ConnectorError>> + Send + Sync>,
1429        status: u16,
1430        headers: HashMap<String, String>,
1431        rate_limits: Option<Vec<RestApiRateLimit>>,
1432    }
1433
1434    impl<T> From<DummyRestApiResponse<T>> for RestApiResponse<T> {
1435        fn from(dummy: DummyRestApiResponse<T>) -> Self {
1436            Self {
1437                data_fn: dummy.inner,
1438                status: dummy.status,
1439                headers: dummy.headers,
1440                rate_limits: dummy.rate_limits,
1441            }
1442        }
1443    }
1444
1445    struct MockOnChainYieldsApiClient {
1446        force_error: bool,
1447    }
1448
1449    #[async_trait]
1450    impl OnChainYieldsApi for MockOnChainYieldsApiClient {
1451        async fn get_on_chain_yields_locked_personal_left_quota(
1452            &self,
1453            _params: GetOnChainYieldsLockedPersonalLeftQuotaParams,
1454        ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedPersonalLeftQuotaResponse>>
1455        {
1456            if self.force_error {
1457                return Err(ConnectorError::ConnectorClientError {
1458                    msg: "ResponseError".to_string(),
1459                    code: None,
1460                }
1461                .into());
1462            }
1463
1464            let resp_json: Value = serde_json::from_str(r#"{"leftPersonalQuota":"1000"}"#)
1465                .unwrap_or_else(|_| serde_json::json!({}));
1466            let dummy_response: models::GetOnChainYieldsLockedPersonalLeftQuotaResponse =
1467                serde_json::from_value(resp_json.clone()).expect(
1468                    "should parse into models::GetOnChainYieldsLockedPersonalLeftQuotaResponse",
1469                );
1470
1471            let dummy = DummyRestApiResponse {
1472                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
1473                status: 200,
1474                headers: HashMap::new(),
1475                rate_limits: None,
1476            };
1477
1478            Ok(dummy.into())
1479        }
1480
1481        async fn get_on_chain_yields_locked_product_list(
1482            &self,
1483            _params: GetOnChainYieldsLockedProductListParams,
1484        ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedProductListResponse>>
1485        {
1486            if self.force_error {
1487                return Err(ConnectorError::ConnectorClientError {
1488                    msg: "ResponseError".to_string(),
1489                    code: None,
1490                }
1491                .into());
1492            }
1493
1494            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"projectId":"Solv-60d","detail":{"asset":"BTC","rewardAsset":"SOLV","duration":60,"renewable":true,"isSoldOut":true,"apr":"0.039","status":"PREHEATING","subscriptionStartTime":1646182276000,"canRedeemToFlex":true},"quota":{"totalPersonalQuota":"2","minimum":"0.001"}}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
1495            let dummy_response: models::GetOnChainYieldsLockedProductListResponse =
1496                serde_json::from_value(resp_json.clone())
1497                    .expect("should parse into models::GetOnChainYieldsLockedProductListResponse");
1498
1499            let dummy = DummyRestApiResponse {
1500                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
1501                status: 200,
1502                headers: HashMap::new(),
1503                rate_limits: None,
1504            };
1505
1506            Ok(dummy.into())
1507        }
1508
1509        async fn get_on_chain_yields_locked_product_position(
1510            &self,
1511            _params: GetOnChainYieldsLockedProductPositionParams,
1512        ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedProductPositionResponse>>
1513        {
1514            if self.force_error {
1515                return Err(ConnectorError::ConnectorClientError {
1516                    msg: "ResponseError".to_string(),
1517                    code: None,
1518                }
1519                .into());
1520            }
1521
1522            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"positionId":"123123","projectId":"Solv-60d","asset":"BTC","amount":"122.09202928","purchaseTime":"1646182276000","duration":"60","accrualDays":"4","rewardAsset":"SOLV","APY":"0.039","rewardAmt":"5.17181528","nextPay":"1.29295383","nextPayDate":"1646697600000","payPeriod":"1","rewardsPayDate":"1646697600000","rewardsEndDate":"1651449600000","deliverDate":"1651536000000","nextSubscriptionDate":"1651536000000","redeemingAmt":"232.2323","redeemTo":"FLEXIBLE","canRedeemEarly":true,"autoSubscribe":true,"type":"AUTO","status":"HOLDING"}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
1523            let dummy_response: models::GetOnChainYieldsLockedProductPositionResponse =
1524                serde_json::from_value(resp_json.clone()).expect(
1525                    "should parse into models::GetOnChainYieldsLockedProductPositionResponse",
1526                );
1527
1528            let dummy = DummyRestApiResponse {
1529                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
1530                status: 200,
1531                headers: HashMap::new(),
1532                rate_limits: None,
1533            };
1534
1535            Ok(dummy.into())
1536        }
1537
1538        async fn get_on_chain_yields_locked_redemption_record(
1539            &self,
1540            _params: GetOnChainYieldsLockedRedemptionRecordParams,
1541        ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedRedemptionRecordResponse>>
1542        {
1543            if self.force_error {
1544                return Err(ConnectorError::ConnectorClientError {
1545                    msg: "ResponseError".to_string(),
1546                    code: None,
1547                }
1548                .into());
1549            }
1550
1551            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"positionId":"123123","redeemId":40607,"time":1575018510000,"asset":"BTC","lockPeriod":"30","amount":"21312.23223","originalAmount":"21312.23223","type":"NORMAL","deliverDate":"1575018510000","lossAmount":"0.00001232","isComplete":true,"rewardAsset":"SOLV","rewardAmt":"5.17181528","status":"PAID"}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
1552            let dummy_response: models::GetOnChainYieldsLockedRedemptionRecordResponse =
1553                serde_json::from_value(resp_json.clone()).expect(
1554                    "should parse into models::GetOnChainYieldsLockedRedemptionRecordResponse",
1555                );
1556
1557            let dummy = DummyRestApiResponse {
1558                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
1559                status: 200,
1560                headers: HashMap::new(),
1561                rate_limits: None,
1562            };
1563
1564            Ok(dummy.into())
1565        }
1566
1567        async fn get_on_chain_yields_locked_rewards_history(
1568            &self,
1569            _params: GetOnChainYieldsLockedRewardsHistoryParams,
1570        ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedRewardsHistoryResponse>>
1571        {
1572            if self.force_error {
1573                return Err(ConnectorError::ConnectorClientError {
1574                    msg: "ResponseError".to_string(),
1575                    code: None,
1576                }
1577                .into());
1578            }
1579
1580            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"positionId":"123123","time":1575018510000,"asset":"BNB","lockPeriod":"30","amount":"21312.23223"}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
1581            let dummy_response: models::GetOnChainYieldsLockedRewardsHistoryResponse =
1582                serde_json::from_value(resp_json.clone()).expect(
1583                    "should parse into models::GetOnChainYieldsLockedRewardsHistoryResponse",
1584                );
1585
1586            let dummy = DummyRestApiResponse {
1587                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
1588                status: 200,
1589                headers: HashMap::new(),
1590                rate_limits: None,
1591            };
1592
1593            Ok(dummy.into())
1594        }
1595
1596        async fn get_on_chain_yields_locked_subscription_preview(
1597            &self,
1598            _params: GetOnChainYieldsLockedSubscriptionPreviewParams,
1599        ) -> anyhow::Result<
1600            RestApiResponse<models::GetOnChainYieldsLockedSubscriptionPreviewResponse>,
1601        > {
1602            if self.force_error {
1603                return Err(ConnectorError::ConnectorClientError {
1604                    msg: "ResponseError".to_string(),
1605                    code: None,
1606                }
1607                .into());
1608            }
1609
1610            let resp_json: Value = serde_json::from_str(r#"{"rewardAsset":"SOLV","totalRewardAmt":"5.17181528","nextPay":"1.29295383","nextPayDate":"1646697600000","rewardsPayDate":"1646697600000","valueDate":"1646697600000","rewardsEndDate":"1651449600000","deliverDate":"1651536000000","nextSubscriptionDate":"1651536000000"}"#).unwrap_or_else(|_| serde_json::json!({}));
1611            let dummy_response: models::GetOnChainYieldsLockedSubscriptionPreviewResponse =
1612                serde_json::from_value(resp_json.clone()).expect(
1613                    "should parse into models::GetOnChainYieldsLockedSubscriptionPreviewResponse",
1614                );
1615
1616            let dummy = DummyRestApiResponse {
1617                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
1618                status: 200,
1619                headers: HashMap::new(),
1620                rate_limits: None,
1621            };
1622
1623            Ok(dummy.into())
1624        }
1625
1626        async fn get_on_chain_yields_locked_subscription_record(
1627            &self,
1628            _params: GetOnChainYieldsLockedSubscriptionRecordParams,
1629        ) -> anyhow::Result<RestApiResponse<models::GetOnChainYieldsLockedSubscriptionRecordResponse>>
1630        {
1631            if self.force_error {
1632                return Err(ConnectorError::ConnectorClientError {
1633                    msg: "ResponseError".to_string(),
1634                    code: None,
1635                }
1636                .into());
1637            }
1638
1639            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"positionId":"123123","purchaseId":"26055","projectId":"Solv-60d","clientId":"ABC","time":1575018510000,"asset":"BTC","amount":"21312.23223","lockPeriod":"30","type":"AUTO","sourceAccount":"SPOT","amtFromSpot":"30","amtFromFunding":"70","status":"SUCCESS"}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
1640            let dummy_response: models::GetOnChainYieldsLockedSubscriptionRecordResponse =
1641                serde_json::from_value(resp_json.clone()).expect(
1642                    "should parse into models::GetOnChainYieldsLockedSubscriptionRecordResponse",
1643                );
1644
1645            let dummy = DummyRestApiResponse {
1646                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
1647                status: 200,
1648                headers: HashMap::new(),
1649                rate_limits: None,
1650            };
1651
1652            Ok(dummy.into())
1653        }
1654
1655        async fn on_chain_yields_account(
1656            &self,
1657            _params: OnChainYieldsAccountParams,
1658        ) -> anyhow::Result<RestApiResponse<models::OnChainYieldsAccountResponse>> {
1659            if self.force_error {
1660                return Err(ConnectorError::ConnectorClientError {
1661                    msg: "ResponseError".to_string(),
1662                    code: None,
1663                }
1664                .into());
1665            }
1666
1667            let resp_json: Value = serde_json::from_str(r#"{"totalAmountInBTC":"0.01067982","totalAmountInUSDT":"77.13289230","totalFlexibleAmountInBTC":"0.00000000","totalFlexibleAmountInUSDT":"0.00000000","totalLockedInBTC":"0.01067982","totalLockedInUSDT":"77.13289230"}"#).unwrap_or_else(|_| serde_json::json!({}));
1668            let dummy_response: models::OnChainYieldsAccountResponse =
1669                serde_json::from_value(resp_json.clone())
1670                    .expect("should parse into models::OnChainYieldsAccountResponse");
1671
1672            let dummy = DummyRestApiResponse {
1673                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
1674                status: 200,
1675                headers: HashMap::new(),
1676                rate_limits: None,
1677            };
1678
1679            Ok(dummy.into())
1680        }
1681
1682        async fn redeem_on_chain_yields_locked_product(
1683            &self,
1684            _params: RedeemOnChainYieldsLockedProductParams,
1685        ) -> anyhow::Result<RestApiResponse<models::RedeemOnChainYieldsLockedProductResponse>>
1686        {
1687            if self.force_error {
1688                return Err(ConnectorError::ConnectorClientError {
1689                    msg: "ResponseError".to_string(),
1690                    code: None,
1691                }
1692                .into());
1693            }
1694
1695            let resp_json: Value = serde_json::from_str(r#"{"redeemId":40607,"success":true}"#)
1696                .unwrap_or_else(|_| serde_json::json!({}));
1697            let dummy_response: models::RedeemOnChainYieldsLockedProductResponse =
1698                serde_json::from_value(resp_json.clone())
1699                    .expect("should parse into models::RedeemOnChainYieldsLockedProductResponse");
1700
1701            let dummy = DummyRestApiResponse {
1702                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
1703                status: 200,
1704                headers: HashMap::new(),
1705                rate_limits: None,
1706            };
1707
1708            Ok(dummy.into())
1709        }
1710
1711        async fn set_on_chain_yields_locked_auto_subscribe(
1712            &self,
1713            _params: SetOnChainYieldsLockedAutoSubscribeParams,
1714        ) -> anyhow::Result<RestApiResponse<models::SetOnChainYieldsLockedAutoSubscribeResponse>>
1715        {
1716            if self.force_error {
1717                return Err(ConnectorError::ConnectorClientError {
1718                    msg: "ResponseError".to_string(),
1719                    code: None,
1720                }
1721                .into());
1722            }
1723
1724            let resp_json: Value = serde_json::from_str(r#"{"success":true}"#)
1725                .unwrap_or_else(|_| serde_json::json!({}));
1726            let dummy_response: models::SetOnChainYieldsLockedAutoSubscribeResponse =
1727                serde_json::from_value(resp_json.clone()).expect(
1728                    "should parse into models::SetOnChainYieldsLockedAutoSubscribeResponse",
1729                );
1730
1731            let dummy = DummyRestApiResponse {
1732                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
1733                status: 200,
1734                headers: HashMap::new(),
1735                rate_limits: None,
1736            };
1737
1738            Ok(dummy.into())
1739        }
1740
1741        async fn set_on_chain_yields_locked_product_redeem_option(
1742            &self,
1743            _params: SetOnChainYieldsLockedProductRedeemOptionParams,
1744        ) -> anyhow::Result<
1745            RestApiResponse<models::SetOnChainYieldsLockedProductRedeemOptionResponse>,
1746        > {
1747            if self.force_error {
1748                return Err(ConnectorError::ConnectorClientError {
1749                    msg: "ResponseError".to_string(),
1750                    code: None,
1751                }
1752                .into());
1753            }
1754
1755            let resp_json: Value = serde_json::from_str(r#"{"success":true}"#)
1756                .unwrap_or_else(|_| serde_json::json!({}));
1757            let dummy_response: models::SetOnChainYieldsLockedProductRedeemOptionResponse =
1758                serde_json::from_value(resp_json.clone()).expect(
1759                    "should parse into models::SetOnChainYieldsLockedProductRedeemOptionResponse",
1760                );
1761
1762            let dummy = DummyRestApiResponse {
1763                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
1764                status: 200,
1765                headers: HashMap::new(),
1766                rate_limits: None,
1767            };
1768
1769            Ok(dummy.into())
1770        }
1771
1772        async fn subscribe_on_chain_yields_locked_product(
1773            &self,
1774            _params: SubscribeOnChainYieldsLockedProductParams,
1775        ) -> anyhow::Result<RestApiResponse<models::SubscribeOnChainYieldsLockedProductResponse>>
1776        {
1777            if self.force_error {
1778                return Err(ConnectorError::ConnectorClientError {
1779                    msg: "ResponseError".to_string(),
1780                    code: None,
1781                }
1782                .into());
1783            }
1784
1785            let resp_json: Value = serde_json::from_str(r#"{"purchaseId":40607,"positionId":"12345","amount":"75.46000000","success":true}"#).unwrap_or_else(|_| serde_json::json!({}));
1786            let dummy_response: models::SubscribeOnChainYieldsLockedProductResponse =
1787                serde_json::from_value(resp_json.clone()).expect(
1788                    "should parse into models::SubscribeOnChainYieldsLockedProductResponse",
1789                );
1790
1791            let dummy = DummyRestApiResponse {
1792                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
1793                status: 200,
1794                headers: HashMap::new(),
1795                rate_limits: None,
1796            };
1797
1798            Ok(dummy.into())
1799        }
1800    }
1801
1802    #[test]
1803    fn get_on_chain_yields_locked_personal_left_quota_required_params_success() {
1804        TOKIO_SHARED_RT.block_on(async {
1805            let client = MockOnChainYieldsApiClient { force_error: false };
1806
1807            let params = GetOnChainYieldsLockedPersonalLeftQuotaParams::builder("1".to_string())
1808                .build()
1809                .unwrap();
1810
1811            let resp_json: Value = serde_json::from_str(r#"{"leftPersonalQuota":"1000"}"#)
1812                .unwrap_or_else(|_| serde_json::json!({}));
1813            let expected_response: models::GetOnChainYieldsLockedPersonalLeftQuotaResponse =
1814                serde_json::from_value(resp_json.clone()).expect(
1815                    "should parse into models::GetOnChainYieldsLockedPersonalLeftQuotaResponse",
1816                );
1817
1818            let resp = client
1819                .get_on_chain_yields_locked_personal_left_quota(params)
1820                .await
1821                .expect("Expected a response");
1822            let data_future = resp.data();
1823            let actual_response = data_future.await.unwrap();
1824            assert_eq!(actual_response, expected_response);
1825        });
1826    }
1827
1828    #[test]
1829    fn get_on_chain_yields_locked_personal_left_quota_optional_params_success() {
1830        TOKIO_SHARED_RT.block_on(async {
1831            let client = MockOnChainYieldsApiClient { force_error: false };
1832
1833            let params = GetOnChainYieldsLockedPersonalLeftQuotaParams::builder("1".to_string())
1834                .recv_window(5000)
1835                .build()
1836                .unwrap();
1837
1838            let resp_json: Value = serde_json::from_str(r#"{"leftPersonalQuota":"1000"}"#)
1839                .unwrap_or_else(|_| serde_json::json!({}));
1840            let expected_response: models::GetOnChainYieldsLockedPersonalLeftQuotaResponse =
1841                serde_json::from_value(resp_json.clone()).expect(
1842                    "should parse into models::GetOnChainYieldsLockedPersonalLeftQuotaResponse",
1843                );
1844
1845            let resp = client
1846                .get_on_chain_yields_locked_personal_left_quota(params)
1847                .await
1848                .expect("Expected a response");
1849            let data_future = resp.data();
1850            let actual_response = data_future.await.unwrap();
1851            assert_eq!(actual_response, expected_response);
1852        });
1853    }
1854
1855    #[test]
1856    fn get_on_chain_yields_locked_personal_left_quota_response_error() {
1857        TOKIO_SHARED_RT.block_on(async {
1858            let client = MockOnChainYieldsApiClient { force_error: true };
1859
1860            let params = GetOnChainYieldsLockedPersonalLeftQuotaParams::builder("1".to_string())
1861                .build()
1862                .unwrap();
1863
1864            match client
1865                .get_on_chain_yields_locked_personal_left_quota(params)
1866                .await
1867            {
1868                Ok(_) => panic!("Expected an error"),
1869                Err(err) => {
1870                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
1871                }
1872            }
1873        });
1874    }
1875
1876    #[test]
1877    fn get_on_chain_yields_locked_product_list_required_params_success() {
1878        TOKIO_SHARED_RT.block_on(async {
1879            let client = MockOnChainYieldsApiClient { force_error: false };
1880
1881            let params = GetOnChainYieldsLockedProductListParams::builder().build().unwrap();
1882
1883            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"projectId":"Solv-60d","detail":{"asset":"BTC","rewardAsset":"SOLV","duration":60,"renewable":true,"isSoldOut":true,"apr":"0.039","status":"PREHEATING","subscriptionStartTime":1646182276000,"canRedeemToFlex":true},"quota":{"totalPersonalQuota":"2","minimum":"0.001"}}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
1884            let expected_response : models::GetOnChainYieldsLockedProductListResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetOnChainYieldsLockedProductListResponse");
1885
1886            let resp = client.get_on_chain_yields_locked_product_list(params).await.expect("Expected a response");
1887            let data_future = resp.data();
1888            let actual_response = data_future.await.unwrap();
1889            assert_eq!(actual_response, expected_response);
1890        });
1891    }
1892
1893    #[test]
1894    fn get_on_chain_yields_locked_product_list_optional_params_success() {
1895        TOKIO_SHARED_RT.block_on(async {
1896            let client = MockOnChainYieldsApiClient { force_error: false };
1897
1898            let params = GetOnChainYieldsLockedProductListParams::builder().asset("SOL".to_string()).current(1).size(10).recv_window(5000).build().unwrap();
1899
1900            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"projectId":"Solv-60d","detail":{"asset":"BTC","rewardAsset":"SOLV","duration":60,"renewable":true,"isSoldOut":true,"apr":"0.039","status":"PREHEATING","subscriptionStartTime":1646182276000,"canRedeemToFlex":true},"quota":{"totalPersonalQuota":"2","minimum":"0.001"}}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
1901            let expected_response : models::GetOnChainYieldsLockedProductListResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetOnChainYieldsLockedProductListResponse");
1902
1903            let resp = client.get_on_chain_yields_locked_product_list(params).await.expect("Expected a response");
1904            let data_future = resp.data();
1905            let actual_response = data_future.await.unwrap();
1906            assert_eq!(actual_response, expected_response);
1907        });
1908    }
1909
1910    #[test]
1911    fn get_on_chain_yields_locked_product_list_response_error() {
1912        TOKIO_SHARED_RT.block_on(async {
1913            let client = MockOnChainYieldsApiClient { force_error: true };
1914
1915            let params = GetOnChainYieldsLockedProductListParams::builder()
1916                .build()
1917                .unwrap();
1918
1919            match client.get_on_chain_yields_locked_product_list(params).await {
1920                Ok(_) => panic!("Expected an error"),
1921                Err(err) => {
1922                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
1923                }
1924            }
1925        });
1926    }
1927
1928    #[test]
1929    fn get_on_chain_yields_locked_product_position_required_params_success() {
1930        TOKIO_SHARED_RT.block_on(async {
1931            let client = MockOnChainYieldsApiClient { force_error: false };
1932
1933            let params = GetOnChainYieldsLockedProductPositionParams::builder().build().unwrap();
1934
1935            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"positionId":"123123","projectId":"Solv-60d","asset":"BTC","amount":"122.09202928","purchaseTime":"1646182276000","duration":"60","accrualDays":"4","rewardAsset":"SOLV","APY":"0.039","rewardAmt":"5.17181528","nextPay":"1.29295383","nextPayDate":"1646697600000","payPeriod":"1","rewardsPayDate":"1646697600000","rewardsEndDate":"1651449600000","deliverDate":"1651536000000","nextSubscriptionDate":"1651536000000","redeemingAmt":"232.2323","redeemTo":"FLEXIBLE","canRedeemEarly":true,"autoSubscribe":true,"type":"AUTO","status":"HOLDING"}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
1936            let expected_response : models::GetOnChainYieldsLockedProductPositionResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetOnChainYieldsLockedProductPositionResponse");
1937
1938            let resp = client.get_on_chain_yields_locked_product_position(params).await.expect("Expected a response");
1939            let data_future = resp.data();
1940            let actual_response = data_future.await.unwrap();
1941            assert_eq!(actual_response, expected_response);
1942        });
1943    }
1944
1945    #[test]
1946    fn get_on_chain_yields_locked_product_position_optional_params_success() {
1947        TOKIO_SHARED_RT.block_on(async {
1948            let client = MockOnChainYieldsApiClient { force_error: false };
1949
1950            let params = GetOnChainYieldsLockedProductPositionParams::builder().asset("BTC".to_string()).position_id("1".to_string()).project_id("1".to_string()).current(1).size(10).recv_window(5000).build().unwrap();
1951
1952            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"positionId":"123123","projectId":"Solv-60d","asset":"BTC","amount":"122.09202928","purchaseTime":"1646182276000","duration":"60","accrualDays":"4","rewardAsset":"SOLV","APY":"0.039","rewardAmt":"5.17181528","nextPay":"1.29295383","nextPayDate":"1646697600000","payPeriod":"1","rewardsPayDate":"1646697600000","rewardsEndDate":"1651449600000","deliverDate":"1651536000000","nextSubscriptionDate":"1651536000000","redeemingAmt":"232.2323","redeemTo":"FLEXIBLE","canRedeemEarly":true,"autoSubscribe":true,"type":"AUTO","status":"HOLDING"}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
1953            let expected_response : models::GetOnChainYieldsLockedProductPositionResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetOnChainYieldsLockedProductPositionResponse");
1954
1955            let resp = client.get_on_chain_yields_locked_product_position(params).await.expect("Expected a response");
1956            let data_future = resp.data();
1957            let actual_response = data_future.await.unwrap();
1958            assert_eq!(actual_response, expected_response);
1959        });
1960    }
1961
1962    #[test]
1963    fn get_on_chain_yields_locked_product_position_response_error() {
1964        TOKIO_SHARED_RT.block_on(async {
1965            let client = MockOnChainYieldsApiClient { force_error: true };
1966
1967            let params = GetOnChainYieldsLockedProductPositionParams::builder()
1968                .build()
1969                .unwrap();
1970
1971            match client
1972                .get_on_chain_yields_locked_product_position(params)
1973                .await
1974            {
1975                Ok(_) => panic!("Expected an error"),
1976                Err(err) => {
1977                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
1978                }
1979            }
1980        });
1981    }
1982
1983    #[test]
1984    fn get_on_chain_yields_locked_redemption_record_required_params_success() {
1985        TOKIO_SHARED_RT.block_on(async {
1986            let client = MockOnChainYieldsApiClient { force_error: false };
1987
1988            let params = GetOnChainYieldsLockedRedemptionRecordParams::builder().build().unwrap();
1989
1990            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"positionId":"123123","redeemId":40607,"time":1575018510000,"asset":"BTC","lockPeriod":"30","amount":"21312.23223","originalAmount":"21312.23223","type":"NORMAL","deliverDate":"1575018510000","lossAmount":"0.00001232","isComplete":true,"rewardAsset":"SOLV","rewardAmt":"5.17181528","status":"PAID"}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
1991            let expected_response : models::GetOnChainYieldsLockedRedemptionRecordResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetOnChainYieldsLockedRedemptionRecordResponse");
1992
1993            let resp = client.get_on_chain_yields_locked_redemption_record(params).await.expect("Expected a response");
1994            let data_future = resp.data();
1995            let actual_response = data_future.await.unwrap();
1996            assert_eq!(actual_response, expected_response);
1997        });
1998    }
1999
2000    #[test]
2001    fn get_on_chain_yields_locked_redemption_record_optional_params_success() {
2002        TOKIO_SHARED_RT.block_on(async {
2003            let client = MockOnChainYieldsApiClient { force_error: false };
2004
2005            let params = GetOnChainYieldsLockedRedemptionRecordParams::builder().position_id("1".to_string()).redeem_id("1".to_string()).asset("BTC".to_string()).start_time(1623319461670).end_time(1641782889000).current(1).size(10).recv_window(5000).build().unwrap();
2006
2007            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"positionId":"123123","redeemId":40607,"time":1575018510000,"asset":"BTC","lockPeriod":"30","amount":"21312.23223","originalAmount":"21312.23223","type":"NORMAL","deliverDate":"1575018510000","lossAmount":"0.00001232","isComplete":true,"rewardAsset":"SOLV","rewardAmt":"5.17181528","status":"PAID"}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
2008            let expected_response : models::GetOnChainYieldsLockedRedemptionRecordResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetOnChainYieldsLockedRedemptionRecordResponse");
2009
2010            let resp = client.get_on_chain_yields_locked_redemption_record(params).await.expect("Expected a response");
2011            let data_future = resp.data();
2012            let actual_response = data_future.await.unwrap();
2013            assert_eq!(actual_response, expected_response);
2014        });
2015    }
2016
2017    #[test]
2018    fn get_on_chain_yields_locked_redemption_record_response_error() {
2019        TOKIO_SHARED_RT.block_on(async {
2020            let client = MockOnChainYieldsApiClient { force_error: true };
2021
2022            let params = GetOnChainYieldsLockedRedemptionRecordParams::builder()
2023                .build()
2024                .unwrap();
2025
2026            match client
2027                .get_on_chain_yields_locked_redemption_record(params)
2028                .await
2029            {
2030                Ok(_) => panic!("Expected an error"),
2031                Err(err) => {
2032                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
2033                }
2034            }
2035        });
2036    }
2037
2038    #[test]
2039    fn get_on_chain_yields_locked_rewards_history_required_params_success() {
2040        TOKIO_SHARED_RT.block_on(async {
2041            let client = MockOnChainYieldsApiClient { force_error: false };
2042
2043            let params = GetOnChainYieldsLockedRewardsHistoryParams::builder().build().unwrap();
2044
2045            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"positionId":"123123","time":1575018510000,"asset":"BNB","lockPeriod":"30","amount":"21312.23223"}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
2046            let expected_response : models::GetOnChainYieldsLockedRewardsHistoryResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetOnChainYieldsLockedRewardsHistoryResponse");
2047
2048            let resp = client.get_on_chain_yields_locked_rewards_history(params).await.expect("Expected a response");
2049            let data_future = resp.data();
2050            let actual_response = data_future.await.unwrap();
2051            assert_eq!(actual_response, expected_response);
2052        });
2053    }
2054
2055    #[test]
2056    fn get_on_chain_yields_locked_rewards_history_optional_params_success() {
2057        TOKIO_SHARED_RT.block_on(async {
2058            let client = MockOnChainYieldsApiClient { force_error: false };
2059
2060            let params = GetOnChainYieldsLockedRewardsHistoryParams::builder().position_id("1".to_string()).asset("BTC".to_string()).start_time(1623319461670).end_time(1641782889000).current(1).size(10).recv_window(5000).build().unwrap();
2061
2062            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"positionId":"123123","time":1575018510000,"asset":"BNB","lockPeriod":"30","amount":"21312.23223"}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
2063            let expected_response : models::GetOnChainYieldsLockedRewardsHistoryResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetOnChainYieldsLockedRewardsHistoryResponse");
2064
2065            let resp = client.get_on_chain_yields_locked_rewards_history(params).await.expect("Expected a response");
2066            let data_future = resp.data();
2067            let actual_response = data_future.await.unwrap();
2068            assert_eq!(actual_response, expected_response);
2069        });
2070    }
2071
2072    #[test]
2073    fn get_on_chain_yields_locked_rewards_history_response_error() {
2074        TOKIO_SHARED_RT.block_on(async {
2075            let client = MockOnChainYieldsApiClient { force_error: true };
2076
2077            let params = GetOnChainYieldsLockedRewardsHistoryParams::builder()
2078                .build()
2079                .unwrap();
2080
2081            match client
2082                .get_on_chain_yields_locked_rewards_history(params)
2083                .await
2084            {
2085                Ok(_) => panic!("Expected an error"),
2086                Err(err) => {
2087                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
2088                }
2089            }
2090        });
2091    }
2092
2093    #[test]
2094    fn get_on_chain_yields_locked_subscription_preview_required_params_success() {
2095        TOKIO_SHARED_RT.block_on(async {
2096            let client = MockOnChainYieldsApiClient { force_error: false };
2097
2098            let params = GetOnChainYieldsLockedSubscriptionPreviewParams::builder("1".to_string(),dec!(1.0),).build().unwrap();
2099
2100            let resp_json: Value = serde_json::from_str(r#"{"rewardAsset":"SOLV","totalRewardAmt":"5.17181528","nextPay":"1.29295383","nextPayDate":"1646697600000","rewardsPayDate":"1646697600000","valueDate":"1646697600000","rewardsEndDate":"1651449600000","deliverDate":"1651536000000","nextSubscriptionDate":"1651536000000"}"#).unwrap_or_else(|_| serde_json::json!({}));
2101            let expected_response : models::GetOnChainYieldsLockedSubscriptionPreviewResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetOnChainYieldsLockedSubscriptionPreviewResponse");
2102
2103            let resp = client.get_on_chain_yields_locked_subscription_preview(params).await.expect("Expected a response");
2104            let data_future = resp.data();
2105            let actual_response = data_future.await.unwrap();
2106            assert_eq!(actual_response, expected_response);
2107        });
2108    }
2109
2110    #[test]
2111    fn get_on_chain_yields_locked_subscription_preview_optional_params_success() {
2112        TOKIO_SHARED_RT.block_on(async {
2113            let client = MockOnChainYieldsApiClient { force_error: false };
2114
2115            let params = GetOnChainYieldsLockedSubscriptionPreviewParams::builder("1".to_string(),dec!(1.0),).auto_subscribe(true).recv_window(5000).build().unwrap();
2116
2117            let resp_json: Value = serde_json::from_str(r#"{"rewardAsset":"SOLV","totalRewardAmt":"5.17181528","nextPay":"1.29295383","nextPayDate":"1646697600000","rewardsPayDate":"1646697600000","valueDate":"1646697600000","rewardsEndDate":"1651449600000","deliverDate":"1651536000000","nextSubscriptionDate":"1651536000000"}"#).unwrap_or_else(|_| serde_json::json!({}));
2118            let expected_response : models::GetOnChainYieldsLockedSubscriptionPreviewResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetOnChainYieldsLockedSubscriptionPreviewResponse");
2119
2120            let resp = client.get_on_chain_yields_locked_subscription_preview(params).await.expect("Expected a response");
2121            let data_future = resp.data();
2122            let actual_response = data_future.await.unwrap();
2123            assert_eq!(actual_response, expected_response);
2124        });
2125    }
2126
2127    #[test]
2128    fn get_on_chain_yields_locked_subscription_preview_response_error() {
2129        TOKIO_SHARED_RT.block_on(async {
2130            let client = MockOnChainYieldsApiClient { force_error: true };
2131
2132            let params = GetOnChainYieldsLockedSubscriptionPreviewParams::builder(
2133                "1".to_string(),
2134                dec!(1.0),
2135            )
2136            .build()
2137            .unwrap();
2138
2139            match client
2140                .get_on_chain_yields_locked_subscription_preview(params)
2141                .await
2142            {
2143                Ok(_) => panic!("Expected an error"),
2144                Err(err) => {
2145                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
2146                }
2147            }
2148        });
2149    }
2150
2151    #[test]
2152    fn get_on_chain_yields_locked_subscription_record_required_params_success() {
2153        TOKIO_SHARED_RT.block_on(async {
2154            let client = MockOnChainYieldsApiClient { force_error: false };
2155
2156            let params = GetOnChainYieldsLockedSubscriptionRecordParams::builder().build().unwrap();
2157
2158            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"positionId":"123123","purchaseId":"26055","projectId":"Solv-60d","clientId":"ABC","time":1575018510000,"asset":"BTC","amount":"21312.23223","lockPeriod":"30","type":"AUTO","sourceAccount":"SPOT","amtFromSpot":"30","amtFromFunding":"70","status":"SUCCESS"}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
2159            let expected_response : models::GetOnChainYieldsLockedSubscriptionRecordResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetOnChainYieldsLockedSubscriptionRecordResponse");
2160
2161            let resp = client.get_on_chain_yields_locked_subscription_record(params).await.expect("Expected a response");
2162            let data_future = resp.data();
2163            let actual_response = data_future.await.unwrap();
2164            assert_eq!(actual_response, expected_response);
2165        });
2166    }
2167
2168    #[test]
2169    fn get_on_chain_yields_locked_subscription_record_optional_params_success() {
2170        TOKIO_SHARED_RT.block_on(async {
2171            let client = MockOnChainYieldsApiClient { force_error: false };
2172
2173            let params = GetOnChainYieldsLockedSubscriptionRecordParams::builder().purchase_id("1".to_string()).client_id("1".to_string()).asset("BTC".to_string()).start_time(1623319461670).end_time(1641782889000).current(1).size(10).recv_window(5000).build().unwrap();
2174
2175            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"positionId":"123123","purchaseId":"26055","projectId":"Solv-60d","clientId":"ABC","time":1575018510000,"asset":"BTC","amount":"21312.23223","lockPeriod":"30","type":"AUTO","sourceAccount":"SPOT","amtFromSpot":"30","amtFromFunding":"70","status":"SUCCESS"}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
2176            let expected_response : models::GetOnChainYieldsLockedSubscriptionRecordResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetOnChainYieldsLockedSubscriptionRecordResponse");
2177
2178            let resp = client.get_on_chain_yields_locked_subscription_record(params).await.expect("Expected a response");
2179            let data_future = resp.data();
2180            let actual_response = data_future.await.unwrap();
2181            assert_eq!(actual_response, expected_response);
2182        });
2183    }
2184
2185    #[test]
2186    fn get_on_chain_yields_locked_subscription_record_response_error() {
2187        TOKIO_SHARED_RT.block_on(async {
2188            let client = MockOnChainYieldsApiClient { force_error: true };
2189
2190            let params = GetOnChainYieldsLockedSubscriptionRecordParams::builder()
2191                .build()
2192                .unwrap();
2193
2194            match client
2195                .get_on_chain_yields_locked_subscription_record(params)
2196                .await
2197            {
2198                Ok(_) => panic!("Expected an error"),
2199                Err(err) => {
2200                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
2201                }
2202            }
2203        });
2204    }
2205
2206    #[test]
2207    fn on_chain_yields_account_required_params_success() {
2208        TOKIO_SHARED_RT.block_on(async {
2209            let client = MockOnChainYieldsApiClient { force_error: false };
2210
2211            let params = OnChainYieldsAccountParams::builder().build().unwrap();
2212
2213            let resp_json: Value = serde_json::from_str(r#"{"totalAmountInBTC":"0.01067982","totalAmountInUSDT":"77.13289230","totalFlexibleAmountInBTC":"0.00000000","totalFlexibleAmountInUSDT":"0.00000000","totalLockedInBTC":"0.01067982","totalLockedInUSDT":"77.13289230"}"#).unwrap_or_else(|_| serde_json::json!({}));
2214            let expected_response : models::OnChainYieldsAccountResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OnChainYieldsAccountResponse");
2215
2216            let resp = client.on_chain_yields_account(params).await.expect("Expected a response");
2217            let data_future = resp.data();
2218            let actual_response = data_future.await.unwrap();
2219            assert_eq!(actual_response, expected_response);
2220        });
2221    }
2222
2223    #[test]
2224    fn on_chain_yields_account_optional_params_success() {
2225        TOKIO_SHARED_RT.block_on(async {
2226            let client = MockOnChainYieldsApiClient { force_error: false };
2227
2228            let params = OnChainYieldsAccountParams::builder().recv_window(5000).build().unwrap();
2229
2230            let resp_json: Value = serde_json::from_str(r#"{"totalAmountInBTC":"0.01067982","totalAmountInUSDT":"77.13289230","totalFlexibleAmountInBTC":"0.00000000","totalFlexibleAmountInUSDT":"0.00000000","totalLockedInBTC":"0.01067982","totalLockedInUSDT":"77.13289230"}"#).unwrap_or_else(|_| serde_json::json!({}));
2231            let expected_response : models::OnChainYieldsAccountResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OnChainYieldsAccountResponse");
2232
2233            let resp = client.on_chain_yields_account(params).await.expect("Expected a response");
2234            let data_future = resp.data();
2235            let actual_response = data_future.await.unwrap();
2236            assert_eq!(actual_response, expected_response);
2237        });
2238    }
2239
2240    #[test]
2241    fn on_chain_yields_account_response_error() {
2242        TOKIO_SHARED_RT.block_on(async {
2243            let client = MockOnChainYieldsApiClient { force_error: true };
2244
2245            let params = OnChainYieldsAccountParams::builder().build().unwrap();
2246
2247            match client.on_chain_yields_account(params).await {
2248                Ok(_) => panic!("Expected an error"),
2249                Err(err) => {
2250                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
2251                }
2252            }
2253        });
2254    }
2255
2256    #[test]
2257    fn redeem_on_chain_yields_locked_product_required_params_success() {
2258        TOKIO_SHARED_RT.block_on(async {
2259            let client = MockOnChainYieldsApiClient { force_error: false };
2260
2261            let params = RedeemOnChainYieldsLockedProductParams::builder("1".to_string())
2262                .build()
2263                .unwrap();
2264
2265            let resp_json: Value = serde_json::from_str(r#"{"redeemId":40607,"success":true}"#)
2266                .unwrap_or_else(|_| serde_json::json!({}));
2267            let expected_response: models::RedeemOnChainYieldsLockedProductResponse =
2268                serde_json::from_value(resp_json.clone())
2269                    .expect("should parse into models::RedeemOnChainYieldsLockedProductResponse");
2270
2271            let resp = client
2272                .redeem_on_chain_yields_locked_product(params)
2273                .await
2274                .expect("Expected a response");
2275            let data_future = resp.data();
2276            let actual_response = data_future.await.unwrap();
2277            assert_eq!(actual_response, expected_response);
2278        });
2279    }
2280
2281    #[test]
2282    fn redeem_on_chain_yields_locked_product_optional_params_success() {
2283        TOKIO_SHARED_RT.block_on(async {
2284            let client = MockOnChainYieldsApiClient { force_error: false };
2285
2286            let params = RedeemOnChainYieldsLockedProductParams::builder("1".to_string())
2287                .channel_id("1".to_string())
2288                .recv_window(5000)
2289                .build()
2290                .unwrap();
2291
2292            let resp_json: Value = serde_json::from_str(r#"{"redeemId":40607,"success":true}"#)
2293                .unwrap_or_else(|_| serde_json::json!({}));
2294            let expected_response: models::RedeemOnChainYieldsLockedProductResponse =
2295                serde_json::from_value(resp_json.clone())
2296                    .expect("should parse into models::RedeemOnChainYieldsLockedProductResponse");
2297
2298            let resp = client
2299                .redeem_on_chain_yields_locked_product(params)
2300                .await
2301                .expect("Expected a response");
2302            let data_future = resp.data();
2303            let actual_response = data_future.await.unwrap();
2304            assert_eq!(actual_response, expected_response);
2305        });
2306    }
2307
2308    #[test]
2309    fn redeem_on_chain_yields_locked_product_response_error() {
2310        TOKIO_SHARED_RT.block_on(async {
2311            let client = MockOnChainYieldsApiClient { force_error: true };
2312
2313            let params = RedeemOnChainYieldsLockedProductParams::builder("1".to_string())
2314                .build()
2315                .unwrap();
2316
2317            match client.redeem_on_chain_yields_locked_product(params).await {
2318                Ok(_) => panic!("Expected an error"),
2319                Err(err) => {
2320                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
2321                }
2322            }
2323        });
2324    }
2325
2326    #[test]
2327    fn set_on_chain_yields_locked_auto_subscribe_required_params_success() {
2328        TOKIO_SHARED_RT.block_on(async {
2329            let client = MockOnChainYieldsApiClient { force_error: false };
2330
2331            let params = SetOnChainYieldsLockedAutoSubscribeParams::builder("1".to_string(), true)
2332                .build()
2333                .unwrap();
2334
2335            let resp_json: Value = serde_json::from_str(r#"{"success":true}"#)
2336                .unwrap_or_else(|_| serde_json::json!({}));
2337            let expected_response: models::SetOnChainYieldsLockedAutoSubscribeResponse =
2338                serde_json::from_value(resp_json.clone()).expect(
2339                    "should parse into models::SetOnChainYieldsLockedAutoSubscribeResponse",
2340                );
2341
2342            let resp = client
2343                .set_on_chain_yields_locked_auto_subscribe(params)
2344                .await
2345                .expect("Expected a response");
2346            let data_future = resp.data();
2347            let actual_response = data_future.await.unwrap();
2348            assert_eq!(actual_response, expected_response);
2349        });
2350    }
2351
2352    #[test]
2353    fn set_on_chain_yields_locked_auto_subscribe_optional_params_success() {
2354        TOKIO_SHARED_RT.block_on(async {
2355            let client = MockOnChainYieldsApiClient { force_error: false };
2356
2357            let params = SetOnChainYieldsLockedAutoSubscribeParams::builder("1".to_string(), true)
2358                .recv_window(5000)
2359                .build()
2360                .unwrap();
2361
2362            let resp_json: Value = serde_json::from_str(r#"{"success":true}"#)
2363                .unwrap_or_else(|_| serde_json::json!({}));
2364            let expected_response: models::SetOnChainYieldsLockedAutoSubscribeResponse =
2365                serde_json::from_value(resp_json.clone()).expect(
2366                    "should parse into models::SetOnChainYieldsLockedAutoSubscribeResponse",
2367                );
2368
2369            let resp = client
2370                .set_on_chain_yields_locked_auto_subscribe(params)
2371                .await
2372                .expect("Expected a response");
2373            let data_future = resp.data();
2374            let actual_response = data_future.await.unwrap();
2375            assert_eq!(actual_response, expected_response);
2376        });
2377    }
2378
2379    #[test]
2380    fn set_on_chain_yields_locked_auto_subscribe_response_error() {
2381        TOKIO_SHARED_RT.block_on(async {
2382            let client = MockOnChainYieldsApiClient { force_error: true };
2383
2384            let params = SetOnChainYieldsLockedAutoSubscribeParams::builder("1".to_string(), true)
2385                .build()
2386                .unwrap();
2387
2388            match client
2389                .set_on_chain_yields_locked_auto_subscribe(params)
2390                .await
2391            {
2392                Ok(_) => panic!("Expected an error"),
2393                Err(err) => {
2394                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
2395                }
2396            }
2397        });
2398    }
2399
2400    #[test]
2401    fn set_on_chain_yields_locked_product_redeem_option_required_params_success() {
2402        TOKIO_SHARED_RT.block_on(async {
2403            let client = MockOnChainYieldsApiClient { force_error: false };
2404
2405            let params = SetOnChainYieldsLockedProductRedeemOptionParams::builder(
2406                "1".to_string(),
2407                SetOnChainYieldsLockedProductRedeemOptionRedeemToEnum::Spot,
2408            )
2409            .build()
2410            .unwrap();
2411
2412            let resp_json: Value = serde_json::from_str(r#"{"success":true}"#)
2413                .unwrap_or_else(|_| serde_json::json!({}));
2414            let expected_response: models::SetOnChainYieldsLockedProductRedeemOptionResponse =
2415                serde_json::from_value(resp_json.clone()).expect(
2416                    "should parse into models::SetOnChainYieldsLockedProductRedeemOptionResponse",
2417                );
2418
2419            let resp = client
2420                .set_on_chain_yields_locked_product_redeem_option(params)
2421                .await
2422                .expect("Expected a response");
2423            let data_future = resp.data();
2424            let actual_response = data_future.await.unwrap();
2425            assert_eq!(actual_response, expected_response);
2426        });
2427    }
2428
2429    #[test]
2430    fn set_on_chain_yields_locked_product_redeem_option_optional_params_success() {
2431        TOKIO_SHARED_RT.block_on(async {
2432            let client = MockOnChainYieldsApiClient { force_error: false };
2433
2434            let params = SetOnChainYieldsLockedProductRedeemOptionParams::builder(
2435                "1".to_string(),
2436                SetOnChainYieldsLockedProductRedeemOptionRedeemToEnum::Spot,
2437            )
2438            .recv_window(5000)
2439            .build()
2440            .unwrap();
2441
2442            let resp_json: Value = serde_json::from_str(r#"{"success":true}"#)
2443                .unwrap_or_else(|_| serde_json::json!({}));
2444            let expected_response: models::SetOnChainYieldsLockedProductRedeemOptionResponse =
2445                serde_json::from_value(resp_json.clone()).expect(
2446                    "should parse into models::SetOnChainYieldsLockedProductRedeemOptionResponse",
2447                );
2448
2449            let resp = client
2450                .set_on_chain_yields_locked_product_redeem_option(params)
2451                .await
2452                .expect("Expected a response");
2453            let data_future = resp.data();
2454            let actual_response = data_future.await.unwrap();
2455            assert_eq!(actual_response, expected_response);
2456        });
2457    }
2458
2459    #[test]
2460    fn set_on_chain_yields_locked_product_redeem_option_response_error() {
2461        TOKIO_SHARED_RT.block_on(async {
2462            let client = MockOnChainYieldsApiClient { force_error: true };
2463
2464            let params = SetOnChainYieldsLockedProductRedeemOptionParams::builder(
2465                "1".to_string(),
2466                SetOnChainYieldsLockedProductRedeemOptionRedeemToEnum::Spot,
2467            )
2468            .build()
2469            .unwrap();
2470
2471            match client
2472                .set_on_chain_yields_locked_product_redeem_option(params)
2473                .await
2474            {
2475                Ok(_) => panic!("Expected an error"),
2476                Err(err) => {
2477                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
2478                }
2479            }
2480        });
2481    }
2482
2483    #[test]
2484    fn subscribe_on_chain_yields_locked_product_required_params_success() {
2485        TOKIO_SHARED_RT.block_on(async {
2486            let client = MockOnChainYieldsApiClient { force_error: false };
2487
2488            let params = SubscribeOnChainYieldsLockedProductParams::builder("1".to_string(),dec!(1.0),).build().unwrap();
2489
2490            let resp_json: Value = serde_json::from_str(r#"{"purchaseId":40607,"positionId":"12345","amount":"75.46000000","success":true}"#).unwrap_or_else(|_| serde_json::json!({}));
2491            let expected_response : models::SubscribeOnChainYieldsLockedProductResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::SubscribeOnChainYieldsLockedProductResponse");
2492
2493            let resp = client.subscribe_on_chain_yields_locked_product(params).await.expect("Expected a response");
2494            let data_future = resp.data();
2495            let actual_response = data_future.await.unwrap();
2496            assert_eq!(actual_response, expected_response);
2497        });
2498    }
2499
2500    #[test]
2501    fn subscribe_on_chain_yields_locked_product_optional_params_success() {
2502        TOKIO_SHARED_RT.block_on(async {
2503            let client = MockOnChainYieldsApiClient { force_error: false };
2504
2505            let params = SubscribeOnChainYieldsLockedProductParams::builder("1".to_string(),dec!(1.0),).auto_subscribe(false).source_account(SubscribeOnChainYieldsLockedProductSourceAccountEnum::Spot).redeem_to(SubscribeOnChainYieldsLockedProductRedeemToEnum::Spot).channel_id("1".to_string()).client_id("1".to_string()).recv_window(5000).build().unwrap();
2506
2507            let resp_json: Value = serde_json::from_str(r#"{"purchaseId":40607,"positionId":"12345","amount":"75.46000000","success":true}"#).unwrap_or_else(|_| serde_json::json!({}));
2508            let expected_response : models::SubscribeOnChainYieldsLockedProductResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::SubscribeOnChainYieldsLockedProductResponse");
2509
2510            let resp = client.subscribe_on_chain_yields_locked_product(params).await.expect("Expected a response");
2511            let data_future = resp.data();
2512            let actual_response = data_future.await.unwrap();
2513            assert_eq!(actual_response, expected_response);
2514        });
2515    }
2516
2517    #[test]
2518    fn subscribe_on_chain_yields_locked_product_response_error() {
2519        TOKIO_SHARED_RT.block_on(async {
2520            let client = MockOnChainYieldsApiClient { force_error: true };
2521
2522            let params =
2523                SubscribeOnChainYieldsLockedProductParams::builder("1".to_string(), dec!(1.0))
2524                    .build()
2525                    .unwrap();
2526
2527            match client
2528                .subscribe_on_chain_yields_locked_product(params)
2529                .await
2530            {
2531                Ok(_) => panic!("Expected an error"),
2532                Err(err) => {
2533                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
2534                }
2535            }
2536        });
2537    }
2538}