fireblocks_sdk/apis/
blockchains_assets_api.rs

1// Fireblocks API
2//
3// Fireblocks provides a suite of applications to manage digital asset operations and a complete development platform to build your business on the blockchain.  - Visit our website for more information: [Fireblocks Website](https://fireblocks.com) - Visit our developer docs: [Fireblocks DevPortal](https://developers.fireblocks.com)
4//
5// The version of the OpenAPI document: 1.8.0
6// Contact: developers@fireblocks.com
7// Generated by: https://openapi-generator.tech
8
9use {
10    super::{Error, configuration},
11    crate::{
12        apis::{ContentType, ResponseContent},
13        models,
14    },
15    async_trait::async_trait,
16    reqwest,
17    serde::{Deserialize, Serialize, de::Error as _},
18    std::sync::Arc,
19};
20
21#[async_trait]
22pub trait BlockchainsAssetsApi: Send + Sync {
23    /// GET /estimate_network_fee
24    ///
25    /// Gets the estimated required fee for an asset. Fireblocks fetches, calculates and caches the result every 30 seconds. Customers should query this API while taking the caching interval into consideration. Notes: - The `networkFee` parameter is the `gasPrice` with a given delta added, multiplied by the gasLimit plus the delta. - The estimation provided depends on the asset type.     - For UTXO-based assets, the response contains the `feePerByte` parameter     - For ETH-based and all EVM based assets, the response will contain `gasPrice` parameter. This is calculated by adding the `baseFee` to the `actualPriority` based on the latest 12 blocks. The response for ETH-based  contains the `baseFee`, `gasPrice`, and `priorityFee` parameters.     - For ADA-based assets, the response will contain the parameter `networkFee` and `feePerByte` parameters.     - For XRP and XLM, the response will contain the transaction fee.     - For other assets, the response will contain the `networkFee` parameter.  Learn more about Fireblocks Fee Management in the following [guide](https://developers.fireblocks.com/reference/estimate-transaction-fee). </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver, Editor.
26    async fn estimate_network_fee(
27        &self,
28        params: EstimateNetworkFeeParams,
29    ) -> Result<models::EstimatedNetworkFeeResponse, Error<EstimateNetworkFeeError>>;
30
31    /// GET /assets/{id}
32    ///
33    /// Returns an asset by ID or legacyID.</br>   **Note**: - We will continue
34    /// displaying and supporting the legacy ID (API ID).  Since not all
35    /// Fireblocks services fully support the new Assets UUID, please use only
36    /// the legacy ID until further notice.
37    async fn get_asset(
38        &self,
39        params: GetAssetParams,
40    ) -> Result<models::Asset, Error<GetAssetError>>;
41
42    /// GET /blockchains/{id}
43    ///
44    /// Returns a blockchain by ID or legacyID.
45    async fn get_blockchain(
46        &self,
47        params: GetBlockchainParams,
48    ) -> Result<models::BlockchainResponse, Error<GetBlockchainError>>;
49
50    /// GET /supported_assets
51    ///
52    /// **This legacy endpoint has not been deprecated but it should not be used in your operations. Instead, use the new [List assets](https://developers.fireblocks.com/reference/listassets) endpoint for better performance and to retrieve more detailed asset information.**  Retrieves all assets supported by Fireblocks in your workspace.  **Endpoint Permissions:** Admin, Non-Signing Admin, Signer, Approver, Editor.
53    async fn get_supported_assets(
54        &self,
55    ) -> Result<Vec<models::AssetTypeResponse>, Error<GetSupportedAssetsError>>;
56
57    /// GET /assets
58    ///
59    /// Retrieves a paginated list of all assets supported by Fireblocks in your
60    /// workspace.  **Note:** We will continue to support and display the legacy
61    /// ID (API ID). Since not all Fireblocks services fully support the new
62    /// Assets UUID, please use only the legacy ID until further notice.
63    async fn list_assets(
64        &self,
65        params: ListAssetsParams,
66    ) -> Result<models::ListAssetsResponse, Error<ListAssetsError>>;
67
68    /// GET /blockchains
69    ///
70    /// Returns all blockchains supported by Fireblocks.</br>
71    async fn list_blockchains(
72        &self,
73        params: ListBlockchainsParams,
74    ) -> Result<models::ListBlockchainsResponse, Error<ListBlockchainsError>>;
75
76    /// POST /assets
77    ///
78    /// Register a new asset to a workspace and return the newly created asset's details. Currently supported chains are:    - EVM based chains   - Stellar   - Algorand   - TRON   - Solana  Learn more about Supporting Additional Assets in Fireblocks  in the following [guide](https://developers.fireblocks.com/docs/add-your-tokens-1). </br>Endpoint Permission: Owner, Admin, Non-Signing Admin, NCW Admin, Editor, and Signer.
79    async fn register_new_asset(
80        &self,
81        params: RegisterNewAssetParams,
82    ) -> Result<models::AssetResponse, Error<RegisterNewAssetError>>;
83
84    /// POST /assets/prices/{id}
85    ///
86    /// Set asset price for the given asset id. Returns the asset price
87    /// response.
88    async fn set_asset_price(
89        &self,
90        params: SetAssetPriceParams,
91    ) -> Result<models::AssetPriceResponse, Error<SetAssetPriceError>>;
92
93    /// PATCH /assets/{id}
94    ///
95    /// Update the user’s metadata for an asset.  **Endpoint Permissions:**
96    /// Owner, Admin, Non-Signing Admin, NCW Admin, Signer, Editor.
97    async fn update_asset_user_metadata(
98        &self,
99        params: UpdateAssetUserMetadataParams,
100    ) -> Result<models::Asset, Error<UpdateAssetUserMetadataError>>;
101
102    /// GET /transactions/validate_address/{assetId}/{address}
103    ///
104    /// Checks if an address is valid and active (for XRP, DOT, XLM, and EOS).
105    /// </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver,
106    /// Editor.
107    async fn validate_address(
108        &self,
109        params: ValidateAddressParams,
110    ) -> Result<models::ValidateAddressResponse, Error<ValidateAddressError>>;
111}
112
113pub struct BlockchainsAssetsApiClient {
114    configuration: Arc<configuration::Configuration>,
115}
116
117impl BlockchainsAssetsApiClient {
118    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
119        Self { configuration }
120    }
121}
122
123/// struct for passing parameters to the method
124/// [`BlockchainsAssetsApi::estimate_network_fee`]
125#[derive(Clone, Debug)]
126#[cfg_attr(feature = "bon", derive(::bon::Builder))]
127pub struct EstimateNetworkFeeParams {
128    /// The asset for which to estimate the fee
129    pub asset_id: String,
130}
131
132/// struct for passing parameters to the method
133/// [`BlockchainsAssetsApi::get_asset`]
134#[derive(Clone, Debug)]
135#[cfg_attr(feature = "bon", derive(::bon::Builder))]
136pub struct GetAssetParams {
137    /// The ID or legacyId of the asset
138    pub id: String,
139    /// A unique identifier for the request. If the request is sent multiple
140    /// times with the same idempotency key, the server will return the same
141    /// response as the first request. The idempotency key is valid for 24
142    /// hours.
143    pub idempotency_key: Option<String>,
144}
145
146/// struct for passing parameters to the method
147/// [`BlockchainsAssetsApi::get_blockchain`]
148#[derive(Clone, Debug)]
149#[cfg_attr(feature = "bon", derive(::bon::Builder))]
150pub struct GetBlockchainParams {
151    /// The ID or legacyId of the blockchain
152    pub id: String,
153}
154
155/// struct for passing parameters to the method
156/// [`BlockchainsAssetsApi::list_assets`]
157#[derive(Clone, Debug)]
158#[cfg_attr(feature = "bon", derive(::bon::Builder))]
159pub struct ListAssetsParams {
160    /// Blockchain id of the assets
161    pub blockchain_id: Option<String>,
162    /// Assets class
163    pub asset_class: Option<models::AssetClass>,
164    /// Assets onchain symbol
165    pub symbol: Option<String>,
166    /// Scope of the assets
167    pub scope: Option<models::AssetScope>,
168    /// Are assets deprecated
169    pub deprecated: Option<bool>,
170    /// A list of asset IDs (max 100)
171    pub ids: Option<Vec<String>>,
172    /// Next page cursor to fetch
173    pub page_cursor: Option<String>,
174    /// Items per page
175    pub page_size: Option<f64>,
176    /// A unique identifier for the request. If the request is sent multiple
177    /// times with the same idempotency key, the server will return the same
178    /// response as the first request. The idempotency key is valid for 24
179    /// hours.
180    pub idempotency_key: Option<String>,
181}
182
183/// struct for passing parameters to the method
184/// [`BlockchainsAssetsApi::list_blockchains`]
185#[derive(Clone, Debug)]
186#[cfg_attr(feature = "bon", derive(::bon::Builder))]
187pub struct ListBlockchainsParams {
188    /// Blockchain protocol
189    pub protocol: Option<String>,
190    /// Is blockchain deprecated
191    pub deprecated: Option<bool>,
192    /// Is test blockchain
193    pub test: Option<bool>,
194    /// A list of blockchain IDs (max 100)
195    pub ids: Option<Vec<String>>,
196    /// Page cursor to fetch
197    pub page_cursor: Option<String>,
198    /// Items per page (max 500)
199    pub page_size: Option<f64>,
200}
201
202/// struct for passing parameters to the method
203/// [`BlockchainsAssetsApi::register_new_asset`]
204#[derive(Clone, Debug)]
205#[cfg_attr(feature = "bon", derive(::bon::Builder))]
206pub struct RegisterNewAssetParams {
207    /// A unique identifier for the request. If the request is sent multiple
208    /// times with the same idempotency key, the server will return the same
209    /// response as the first request. The idempotency key is valid for 24
210    /// hours.
211    pub idempotency_key: Option<String>,
212    pub register_new_asset_request: Option<models::RegisterNewAssetRequest>,
213}
214
215/// struct for passing parameters to the method
216/// [`BlockchainsAssetsApi::set_asset_price`]
217#[derive(Clone, Debug)]
218#[cfg_attr(feature = "bon", derive(::bon::Builder))]
219pub struct SetAssetPriceParams {
220    /// The ID of the asset
221    pub id: String,
222    /// A unique identifier for the request. If the request is sent multiple
223    /// times with the same idempotency key, the server will return the same
224    /// response as the first request. The idempotency key is valid for 24
225    /// hours.
226    pub idempotency_key: Option<String>,
227    pub set_asset_price_request: Option<models::SetAssetPriceRequest>,
228}
229
230/// struct for passing parameters to the method
231/// [`BlockchainsAssetsApi::update_asset_user_metadata`]
232#[derive(Clone, Debug)]
233#[cfg_attr(feature = "bon", derive(::bon::Builder))]
234pub struct UpdateAssetUserMetadataParams {
235    /// The ID or legacyId of the asset
236    pub id: String,
237    /// A unique identifier for the request. If the request is sent multiple
238    /// times with the same idempotency key, the server will return the same
239    /// response as the first request. The idempotency key is valid for 24
240    /// hours.
241    pub idempotency_key: Option<String>,
242    pub update_asset_user_metadata_request: Option<models::UpdateAssetUserMetadataRequest>,
243}
244
245/// struct for passing parameters to the method
246/// [`BlockchainsAssetsApi::validate_address`]
247#[derive(Clone, Debug)]
248#[cfg_attr(feature = "bon", derive(::bon::Builder))]
249pub struct ValidateAddressParams {
250    /// The asset of the address
251    pub asset_id: String,
252    /// The address to validate
253    pub address: String,
254}
255
256#[async_trait]
257impl BlockchainsAssetsApi for BlockchainsAssetsApiClient {
258    /// Gets the estimated required fee for an asset. Fireblocks fetches, calculates and caches the result every 30 seconds. Customers should query this API while taking the caching interval into consideration. Notes: - The `networkFee` parameter is the `gasPrice` with a given delta added, multiplied by the gasLimit plus the delta. - The estimation provided depends on the asset type.     - For UTXO-based assets, the response contains the `feePerByte` parameter     - For ETH-based and all EVM based assets, the response will contain `gasPrice` parameter. This is calculated by adding the `baseFee` to the `actualPriority` based on the latest 12 blocks. The response for ETH-based  contains the `baseFee`, `gasPrice`, and `priorityFee` parameters.     - For ADA-based assets, the response will contain the parameter `networkFee` and `feePerByte` parameters.     - For XRP and XLM, the response will contain the transaction fee.     - For other assets, the response will contain the `networkFee` parameter.  Learn more about Fireblocks Fee Management in the following [guide](https://developers.fireblocks.com/reference/estimate-transaction-fee). </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver, Editor.
259    async fn estimate_network_fee(
260        &self,
261        params: EstimateNetworkFeeParams,
262    ) -> Result<models::EstimatedNetworkFeeResponse, Error<EstimateNetworkFeeError>> {
263        let EstimateNetworkFeeParams { asset_id } = params;
264
265        let local_var_configuration = &self.configuration;
266
267        let local_var_client = &local_var_configuration.client;
268
269        let local_var_uri_str =
270            format!("{}/estimate_network_fee", local_var_configuration.base_path);
271        let mut local_var_req_builder =
272            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
273
274        local_var_req_builder = local_var_req_builder.query(&[("assetId", &asset_id.to_string())]);
275        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
276            local_var_req_builder = local_var_req_builder
277                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
278        }
279
280        let local_var_req = local_var_req_builder.build()?;
281        let local_var_resp = local_var_client.execute(local_var_req).await?;
282
283        let local_var_status = local_var_resp.status();
284        let local_var_content_type = local_var_resp
285            .headers()
286            .get("content-type")
287            .and_then(|v| v.to_str().ok())
288            .unwrap_or("application/octet-stream");
289        let local_var_content_type = super::ContentType::from(local_var_content_type);
290        let local_var_content = local_var_resp.text().await?;
291
292        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
293            match local_var_content_type {
294                ContentType::Json => {
295                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
296                }
297                ContentType::Text => {
298                    return Err(Error::from(serde_json::Error::custom(
299                        "Received `text/plain` content type response that cannot be converted to \
300                         `models::EstimatedNetworkFeeResponse`",
301                    )));
302                }
303                ContentType::Unsupported(local_var_unknown_type) => {
304                    return Err(Error::from(serde_json::Error::custom(format!(
305                        "Received `{local_var_unknown_type}` content type response that cannot be \
306                         converted to `models::EstimatedNetworkFeeResponse`"
307                    ))));
308                }
309            }
310        } else {
311            let local_var_entity: Option<EstimateNetworkFeeError> =
312                serde_json::from_str(&local_var_content).ok();
313            let local_var_error = ResponseContent {
314                status: local_var_status,
315                content: local_var_content,
316                entity: local_var_entity,
317            };
318            Err(Error::ResponseError(local_var_error))
319        }
320    }
321
322    /// Returns an asset by ID or legacyID.</br>   **Note**: - We will continue
323    /// displaying and supporting the legacy ID (API ID).  Since not all
324    /// Fireblocks services fully support the new Assets UUID, please use only
325    /// the legacy ID until further notice.
326    async fn get_asset(
327        &self,
328        params: GetAssetParams,
329    ) -> Result<models::Asset, Error<GetAssetError>> {
330        let GetAssetParams {
331            id,
332            idempotency_key,
333        } = params;
334
335        let local_var_configuration = &self.configuration;
336
337        let local_var_client = &local_var_configuration.client;
338
339        let local_var_uri_str = format!(
340            "{}/assets/{id}",
341            local_var_configuration.base_path,
342            id = crate::apis::urlencode(id)
343        );
344        let mut local_var_req_builder =
345            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
346
347        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
348            local_var_req_builder = local_var_req_builder
349                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
350        }
351        if let Some(local_var_param_value) = idempotency_key {
352            local_var_req_builder =
353                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
354        }
355
356        let local_var_req = local_var_req_builder.build()?;
357        let local_var_resp = local_var_client.execute(local_var_req).await?;
358
359        let local_var_status = local_var_resp.status();
360        let local_var_content_type = local_var_resp
361            .headers()
362            .get("content-type")
363            .and_then(|v| v.to_str().ok())
364            .unwrap_or("application/octet-stream");
365        let local_var_content_type = super::ContentType::from(local_var_content_type);
366        let local_var_content = local_var_resp.text().await?;
367
368        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
369            match local_var_content_type {
370                ContentType::Json => {
371                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
372                }
373                ContentType::Text => {
374                    return Err(Error::from(serde_json::Error::custom(
375                        "Received `text/plain` content type response that cannot be converted to \
376                         `models::Asset`",
377                    )));
378                }
379                ContentType::Unsupported(local_var_unknown_type) => {
380                    return Err(Error::from(serde_json::Error::custom(format!(
381                        "Received `{local_var_unknown_type}` content type response that cannot be \
382                         converted to `models::Asset`"
383                    ))));
384                }
385            }
386        } else {
387            let local_var_entity: Option<GetAssetError> =
388                serde_json::from_str(&local_var_content).ok();
389            let local_var_error = ResponseContent {
390                status: local_var_status,
391                content: local_var_content,
392                entity: local_var_entity,
393            };
394            Err(Error::ResponseError(local_var_error))
395        }
396    }
397
398    /// Returns a blockchain by ID or legacyID.
399    async fn get_blockchain(
400        &self,
401        params: GetBlockchainParams,
402    ) -> Result<models::BlockchainResponse, Error<GetBlockchainError>> {
403        let GetBlockchainParams { id } = params;
404
405        let local_var_configuration = &self.configuration;
406
407        let local_var_client = &local_var_configuration.client;
408
409        let local_var_uri_str = format!(
410            "{}/blockchains/{id}",
411            local_var_configuration.base_path,
412            id = crate::apis::urlencode(id)
413        );
414        let mut local_var_req_builder =
415            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
416
417        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
418            local_var_req_builder = local_var_req_builder
419                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
420        }
421
422        let local_var_req = local_var_req_builder.build()?;
423        let local_var_resp = local_var_client.execute(local_var_req).await?;
424
425        let local_var_status = local_var_resp.status();
426        let local_var_content_type = local_var_resp
427            .headers()
428            .get("content-type")
429            .and_then(|v| v.to_str().ok())
430            .unwrap_or("application/octet-stream");
431        let local_var_content_type = super::ContentType::from(local_var_content_type);
432        let local_var_content = local_var_resp.text().await?;
433
434        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
435            match local_var_content_type {
436                ContentType::Json => {
437                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
438                }
439                ContentType::Text => {
440                    return Err(Error::from(serde_json::Error::custom(
441                        "Received `text/plain` content type response that cannot be converted to \
442                         `models::BlockchainResponse`",
443                    )));
444                }
445                ContentType::Unsupported(local_var_unknown_type) => {
446                    return Err(Error::from(serde_json::Error::custom(format!(
447                        "Received `{local_var_unknown_type}` content type response that cannot be \
448                         converted to `models::BlockchainResponse`"
449                    ))));
450                }
451            }
452        } else {
453            let local_var_entity: Option<GetBlockchainError> =
454                serde_json::from_str(&local_var_content).ok();
455            let local_var_error = ResponseContent {
456                status: local_var_status,
457                content: local_var_content,
458                entity: local_var_entity,
459            };
460            Err(Error::ResponseError(local_var_error))
461        }
462    }
463
464    /// **This legacy endpoint has not been deprecated but it should not be used in your operations. Instead, use the new [List assets](https://developers.fireblocks.com/reference/listassets) endpoint for better performance and to retrieve more detailed asset information.**  Retrieves all assets supported by Fireblocks in your workspace.  **Endpoint Permissions:** Admin, Non-Signing Admin, Signer, Approver, Editor.
465    async fn get_supported_assets(
466        &self,
467    ) -> Result<Vec<models::AssetTypeResponse>, Error<GetSupportedAssetsError>> {
468        let local_var_configuration = &self.configuration;
469
470        let local_var_client = &local_var_configuration.client;
471
472        let local_var_uri_str = format!("{}/supported_assets", local_var_configuration.base_path);
473        let mut local_var_req_builder =
474            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
475
476        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
477            local_var_req_builder = local_var_req_builder
478                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
479        }
480
481        let local_var_req = local_var_req_builder.build()?;
482        let local_var_resp = local_var_client.execute(local_var_req).await?;
483
484        let local_var_status = local_var_resp.status();
485        let local_var_content_type = local_var_resp
486            .headers()
487            .get("content-type")
488            .and_then(|v| v.to_str().ok())
489            .unwrap_or("application/octet-stream");
490        let local_var_content_type = super::ContentType::from(local_var_content_type);
491        let local_var_content = local_var_resp.text().await?;
492
493        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
494            match local_var_content_type {
495                ContentType::Json => {
496                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
497                }
498                ContentType::Text => {
499                    return Err(Error::from(serde_json::Error::custom(
500                        "Received `text/plain` content type response that cannot be converted to \
501                         `Vec&lt;models::AssetTypeResponse&gt;`",
502                    )));
503                }
504                ContentType::Unsupported(local_var_unknown_type) => {
505                    return Err(Error::from(serde_json::Error::custom(format!(
506                        "Received `{local_var_unknown_type}` content type response that cannot be \
507                         converted to `Vec&lt;models::AssetTypeResponse&gt;`"
508                    ))));
509                }
510            }
511        } else {
512            let local_var_entity: Option<GetSupportedAssetsError> =
513                serde_json::from_str(&local_var_content).ok();
514            let local_var_error = ResponseContent {
515                status: local_var_status,
516                content: local_var_content,
517                entity: local_var_entity,
518            };
519            Err(Error::ResponseError(local_var_error))
520        }
521    }
522
523    /// Retrieves a paginated list of all assets supported by Fireblocks in your
524    /// workspace.  **Note:** We will continue to support and display the legacy
525    /// ID (API ID). Since not all Fireblocks services fully support the new
526    /// Assets UUID, please use only the legacy ID until further notice.
527    async fn list_assets(
528        &self,
529        params: ListAssetsParams,
530    ) -> Result<models::ListAssetsResponse, Error<ListAssetsError>> {
531        let ListAssetsParams {
532            blockchain_id,
533            asset_class,
534            symbol,
535            scope,
536            deprecated,
537            ids,
538            page_cursor,
539            page_size,
540            idempotency_key,
541        } = params;
542
543        let local_var_configuration = &self.configuration;
544
545        let local_var_client = &local_var_configuration.client;
546
547        let local_var_uri_str = format!("{}/assets", local_var_configuration.base_path);
548        let mut local_var_req_builder =
549            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
550
551        if let Some(ref param_value) = blockchain_id {
552            local_var_req_builder =
553                local_var_req_builder.query(&[("blockchainId", &param_value.to_string())]);
554        }
555        if let Some(ref param_value) = asset_class {
556            local_var_req_builder =
557                local_var_req_builder.query(&[("assetClass", &param_value.to_string())]);
558        }
559        if let Some(ref param_value) = symbol {
560            local_var_req_builder =
561                local_var_req_builder.query(&[("symbol", &param_value.to_string())]);
562        }
563        if let Some(ref param_value) = scope {
564            local_var_req_builder =
565                local_var_req_builder.query(&[("scope", &param_value.to_string())]);
566        }
567        if let Some(ref param_value) = deprecated {
568            local_var_req_builder =
569                local_var_req_builder.query(&[("deprecated", &param_value.to_string())]);
570        }
571        if let Some(ref param_value) = ids {
572            local_var_req_builder = match "multi" {
573                "multi" => local_var_req_builder.query(
574                    &param_value
575                        .into_iter()
576                        .map(|p| ("ids".to_owned(), p.to_string()))
577                        .collect::<Vec<(std::string::String, std::string::String)>>(),
578                ),
579                _ => local_var_req_builder.query(&[(
580                    "ids",
581                    &param_value
582                        .into_iter()
583                        .map(|p| p.to_string())
584                        .collect::<Vec<String>>()
585                        .join(",")
586                        .to_string(),
587                )]),
588            };
589        }
590        if let Some(ref param_value) = page_cursor {
591            local_var_req_builder =
592                local_var_req_builder.query(&[("pageCursor", &param_value.to_string())]);
593        }
594        if let Some(ref param_value) = page_size {
595            local_var_req_builder =
596                local_var_req_builder.query(&[("pageSize", &param_value.to_string())]);
597        }
598        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
599            local_var_req_builder = local_var_req_builder
600                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
601        }
602        if let Some(local_var_param_value) = idempotency_key {
603            local_var_req_builder =
604                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
605        }
606
607        let local_var_req = local_var_req_builder.build()?;
608        let local_var_resp = local_var_client.execute(local_var_req).await?;
609
610        let local_var_status = local_var_resp.status();
611        let local_var_content_type = local_var_resp
612            .headers()
613            .get("content-type")
614            .and_then(|v| v.to_str().ok())
615            .unwrap_or("application/octet-stream");
616        let local_var_content_type = super::ContentType::from(local_var_content_type);
617        let local_var_content = local_var_resp.text().await?;
618
619        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
620            match local_var_content_type {
621                ContentType::Json => {
622                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
623                }
624                ContentType::Text => {
625                    return Err(Error::from(serde_json::Error::custom(
626                        "Received `text/plain` content type response that cannot be converted to \
627                         `models::ListAssetsResponse`",
628                    )));
629                }
630                ContentType::Unsupported(local_var_unknown_type) => {
631                    return Err(Error::from(serde_json::Error::custom(format!(
632                        "Received `{local_var_unknown_type}` content type response that cannot be \
633                         converted to `models::ListAssetsResponse`"
634                    ))));
635                }
636            }
637        } else {
638            let local_var_entity: Option<ListAssetsError> =
639                serde_json::from_str(&local_var_content).ok();
640            let local_var_error = ResponseContent {
641                status: local_var_status,
642                content: local_var_content,
643                entity: local_var_entity,
644            };
645            Err(Error::ResponseError(local_var_error))
646        }
647    }
648
649    /// Returns all blockchains supported by Fireblocks.</br>
650    async fn list_blockchains(
651        &self,
652        params: ListBlockchainsParams,
653    ) -> Result<models::ListBlockchainsResponse, Error<ListBlockchainsError>> {
654        let ListBlockchainsParams {
655            protocol,
656            deprecated,
657            test,
658            ids,
659            page_cursor,
660            page_size,
661        } = params;
662
663        let local_var_configuration = &self.configuration;
664
665        let local_var_client = &local_var_configuration.client;
666
667        let local_var_uri_str = format!("{}/blockchains", local_var_configuration.base_path);
668        let mut local_var_req_builder =
669            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
670
671        if let Some(ref param_value) = protocol {
672            local_var_req_builder =
673                local_var_req_builder.query(&[("protocol", &param_value.to_string())]);
674        }
675        if let Some(ref param_value) = deprecated {
676            local_var_req_builder =
677                local_var_req_builder.query(&[("deprecated", &param_value.to_string())]);
678        }
679        if let Some(ref param_value) = test {
680            local_var_req_builder =
681                local_var_req_builder.query(&[("test", &param_value.to_string())]);
682        }
683        if let Some(ref param_value) = ids {
684            local_var_req_builder = match "multi" {
685                "multi" => local_var_req_builder.query(
686                    &param_value
687                        .into_iter()
688                        .map(|p| ("ids".to_owned(), p.to_string()))
689                        .collect::<Vec<(std::string::String, std::string::String)>>(),
690                ),
691                _ => local_var_req_builder.query(&[(
692                    "ids",
693                    &param_value
694                        .into_iter()
695                        .map(|p| p.to_string())
696                        .collect::<Vec<String>>()
697                        .join(",")
698                        .to_string(),
699                )]),
700            };
701        }
702        if let Some(ref param_value) = page_cursor {
703            local_var_req_builder =
704                local_var_req_builder.query(&[("pageCursor", &param_value.to_string())]);
705        }
706        if let Some(ref param_value) = page_size {
707            local_var_req_builder =
708                local_var_req_builder.query(&[("pageSize", &param_value.to_string())]);
709        }
710        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
711            local_var_req_builder = local_var_req_builder
712                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
713        }
714
715        let local_var_req = local_var_req_builder.build()?;
716        let local_var_resp = local_var_client.execute(local_var_req).await?;
717
718        let local_var_status = local_var_resp.status();
719        let local_var_content_type = local_var_resp
720            .headers()
721            .get("content-type")
722            .and_then(|v| v.to_str().ok())
723            .unwrap_or("application/octet-stream");
724        let local_var_content_type = super::ContentType::from(local_var_content_type);
725        let local_var_content = local_var_resp.text().await?;
726
727        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
728            match local_var_content_type {
729                ContentType::Json => {
730                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
731                }
732                ContentType::Text => {
733                    return Err(Error::from(serde_json::Error::custom(
734                        "Received `text/plain` content type response that cannot be converted to \
735                         `models::ListBlockchainsResponse`",
736                    )));
737                }
738                ContentType::Unsupported(local_var_unknown_type) => {
739                    return Err(Error::from(serde_json::Error::custom(format!(
740                        "Received `{local_var_unknown_type}` content type response that cannot be \
741                         converted to `models::ListBlockchainsResponse`"
742                    ))));
743                }
744            }
745        } else {
746            let local_var_entity: Option<ListBlockchainsError> =
747                serde_json::from_str(&local_var_content).ok();
748            let local_var_error = ResponseContent {
749                status: local_var_status,
750                content: local_var_content,
751                entity: local_var_entity,
752            };
753            Err(Error::ResponseError(local_var_error))
754        }
755    }
756
757    /// Register a new asset to a workspace and return the newly created asset's details. Currently supported chains are:    - EVM based chains   - Stellar   - Algorand   - TRON   - Solana  Learn more about Supporting Additional Assets in Fireblocks  in the following [guide](https://developers.fireblocks.com/docs/add-your-tokens-1). </br>Endpoint Permission: Owner, Admin, Non-Signing Admin, NCW Admin, Editor, and Signer.
758    async fn register_new_asset(
759        &self,
760        params: RegisterNewAssetParams,
761    ) -> Result<models::AssetResponse, Error<RegisterNewAssetError>> {
762        let RegisterNewAssetParams {
763            idempotency_key,
764            register_new_asset_request,
765        } = params;
766
767        let local_var_configuration = &self.configuration;
768
769        let local_var_client = &local_var_configuration.client;
770
771        let local_var_uri_str = format!("{}/assets", local_var_configuration.base_path);
772        let mut local_var_req_builder =
773            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
774
775        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
776            local_var_req_builder = local_var_req_builder
777                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
778        }
779        if let Some(local_var_param_value) = idempotency_key {
780            local_var_req_builder =
781                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
782        }
783        local_var_req_builder = local_var_req_builder.json(&register_new_asset_request);
784
785        let local_var_req = local_var_req_builder.build()?;
786        let local_var_resp = local_var_client.execute(local_var_req).await?;
787
788        let local_var_status = local_var_resp.status();
789        let local_var_content_type = local_var_resp
790            .headers()
791            .get("content-type")
792            .and_then(|v| v.to_str().ok())
793            .unwrap_or("application/octet-stream");
794        let local_var_content_type = super::ContentType::from(local_var_content_type);
795        let local_var_content = local_var_resp.text().await?;
796
797        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
798            match local_var_content_type {
799                ContentType::Json => {
800                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
801                }
802                ContentType::Text => {
803                    return Err(Error::from(serde_json::Error::custom(
804                        "Received `text/plain` content type response that cannot be converted to \
805                         `models::AssetResponse`",
806                    )));
807                }
808                ContentType::Unsupported(local_var_unknown_type) => {
809                    return Err(Error::from(serde_json::Error::custom(format!(
810                        "Received `{local_var_unknown_type}` content type response that cannot be \
811                         converted to `models::AssetResponse`"
812                    ))));
813                }
814            }
815        } else {
816            let local_var_entity: Option<RegisterNewAssetError> =
817                serde_json::from_str(&local_var_content).ok();
818            let local_var_error = ResponseContent {
819                status: local_var_status,
820                content: local_var_content,
821                entity: local_var_entity,
822            };
823            Err(Error::ResponseError(local_var_error))
824        }
825    }
826
827    /// Set asset price for the given asset id. Returns the asset price
828    /// response.
829    async fn set_asset_price(
830        &self,
831        params: SetAssetPriceParams,
832    ) -> Result<models::AssetPriceResponse, Error<SetAssetPriceError>> {
833        let SetAssetPriceParams {
834            id,
835            idempotency_key,
836            set_asset_price_request,
837        } = params;
838
839        let local_var_configuration = &self.configuration;
840
841        let local_var_client = &local_var_configuration.client;
842
843        let local_var_uri_str = format!(
844            "{}/assets/prices/{id}",
845            local_var_configuration.base_path,
846            id = crate::apis::urlencode(id)
847        );
848        let mut local_var_req_builder =
849            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
850
851        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
852            local_var_req_builder = local_var_req_builder
853                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
854        }
855        if let Some(local_var_param_value) = idempotency_key {
856            local_var_req_builder =
857                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
858        }
859        local_var_req_builder = local_var_req_builder.json(&set_asset_price_request);
860
861        let local_var_req = local_var_req_builder.build()?;
862        let local_var_resp = local_var_client.execute(local_var_req).await?;
863
864        let local_var_status = local_var_resp.status();
865        let local_var_content_type = local_var_resp
866            .headers()
867            .get("content-type")
868            .and_then(|v| v.to_str().ok())
869            .unwrap_or("application/octet-stream");
870        let local_var_content_type = super::ContentType::from(local_var_content_type);
871        let local_var_content = local_var_resp.text().await?;
872
873        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
874            match local_var_content_type {
875                ContentType::Json => {
876                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
877                }
878                ContentType::Text => {
879                    return Err(Error::from(serde_json::Error::custom(
880                        "Received `text/plain` content type response that cannot be converted to \
881                         `models::AssetPriceResponse`",
882                    )));
883                }
884                ContentType::Unsupported(local_var_unknown_type) => {
885                    return Err(Error::from(serde_json::Error::custom(format!(
886                        "Received `{local_var_unknown_type}` content type response that cannot be \
887                         converted to `models::AssetPriceResponse`"
888                    ))));
889                }
890            }
891        } else {
892            let local_var_entity: Option<SetAssetPriceError> =
893                serde_json::from_str(&local_var_content).ok();
894            let local_var_error = ResponseContent {
895                status: local_var_status,
896                content: local_var_content,
897                entity: local_var_entity,
898            };
899            Err(Error::ResponseError(local_var_error))
900        }
901    }
902
903    /// Update the user’s metadata for an asset.  **Endpoint Permissions:**
904    /// Owner, Admin, Non-Signing Admin, NCW Admin, Signer, Editor.
905    async fn update_asset_user_metadata(
906        &self,
907        params: UpdateAssetUserMetadataParams,
908    ) -> Result<models::Asset, Error<UpdateAssetUserMetadataError>> {
909        let UpdateAssetUserMetadataParams {
910            id,
911            idempotency_key,
912            update_asset_user_metadata_request,
913        } = params;
914
915        let local_var_configuration = &self.configuration;
916
917        let local_var_client = &local_var_configuration.client;
918
919        let local_var_uri_str = format!(
920            "{}/assets/{id}",
921            local_var_configuration.base_path,
922            id = crate::apis::urlencode(id)
923        );
924        let mut local_var_req_builder =
925            local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
926
927        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
928            local_var_req_builder = local_var_req_builder
929                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
930        }
931        if let Some(local_var_param_value) = idempotency_key {
932            local_var_req_builder =
933                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
934        }
935        local_var_req_builder = local_var_req_builder.json(&update_asset_user_metadata_request);
936
937        let local_var_req = local_var_req_builder.build()?;
938        let local_var_resp = local_var_client.execute(local_var_req).await?;
939
940        let local_var_status = local_var_resp.status();
941        let local_var_content_type = local_var_resp
942            .headers()
943            .get("content-type")
944            .and_then(|v| v.to_str().ok())
945            .unwrap_or("application/octet-stream");
946        let local_var_content_type = super::ContentType::from(local_var_content_type);
947        let local_var_content = local_var_resp.text().await?;
948
949        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
950            match local_var_content_type {
951                ContentType::Json => {
952                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
953                }
954                ContentType::Text => {
955                    return Err(Error::from(serde_json::Error::custom(
956                        "Received `text/plain` content type response that cannot be converted to \
957                         `models::Asset`",
958                    )));
959                }
960                ContentType::Unsupported(local_var_unknown_type) => {
961                    return Err(Error::from(serde_json::Error::custom(format!(
962                        "Received `{local_var_unknown_type}` content type response that cannot be \
963                         converted to `models::Asset`"
964                    ))));
965                }
966            }
967        } else {
968            let local_var_entity: Option<UpdateAssetUserMetadataError> =
969                serde_json::from_str(&local_var_content).ok();
970            let local_var_error = ResponseContent {
971                status: local_var_status,
972                content: local_var_content,
973                entity: local_var_entity,
974            };
975            Err(Error::ResponseError(local_var_error))
976        }
977    }
978
979    /// Checks if an address is valid and active (for XRP, DOT, XLM, and EOS).
980    /// </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver,
981    /// Editor.
982    async fn validate_address(
983        &self,
984        params: ValidateAddressParams,
985    ) -> Result<models::ValidateAddressResponse, Error<ValidateAddressError>> {
986        let ValidateAddressParams { asset_id, address } = params;
987
988        let local_var_configuration = &self.configuration;
989
990        let local_var_client = &local_var_configuration.client;
991
992        let local_var_uri_str = format!(
993            "{}/transactions/validate_address/{assetId}/{address}",
994            local_var_configuration.base_path,
995            assetId = crate::apis::urlencode(asset_id),
996            address = crate::apis::urlencode(address)
997        );
998        let mut local_var_req_builder =
999            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1000
1001        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1002            local_var_req_builder = local_var_req_builder
1003                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1004        }
1005
1006        let local_var_req = local_var_req_builder.build()?;
1007        let local_var_resp = local_var_client.execute(local_var_req).await?;
1008
1009        let local_var_status = local_var_resp.status();
1010        let local_var_content_type = local_var_resp
1011            .headers()
1012            .get("content-type")
1013            .and_then(|v| v.to_str().ok())
1014            .unwrap_or("application/octet-stream");
1015        let local_var_content_type = super::ContentType::from(local_var_content_type);
1016        let local_var_content = local_var_resp.text().await?;
1017
1018        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1019            match local_var_content_type {
1020                ContentType::Json => {
1021                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1022                }
1023                ContentType::Text => {
1024                    return Err(Error::from(serde_json::Error::custom(
1025                        "Received `text/plain` content type response that cannot be converted to \
1026                         `models::ValidateAddressResponse`",
1027                    )));
1028                }
1029                ContentType::Unsupported(local_var_unknown_type) => {
1030                    return Err(Error::from(serde_json::Error::custom(format!(
1031                        "Received `{local_var_unknown_type}` content type response that cannot be \
1032                         converted to `models::ValidateAddressResponse`"
1033                    ))));
1034                }
1035            }
1036        } else {
1037            let local_var_entity: Option<ValidateAddressError> =
1038                serde_json::from_str(&local_var_content).ok();
1039            let local_var_error = ResponseContent {
1040                status: local_var_status,
1041                content: local_var_content,
1042                entity: local_var_entity,
1043            };
1044            Err(Error::ResponseError(local_var_error))
1045        }
1046    }
1047}
1048
1049/// struct for typed errors of method
1050/// [`BlockchainsAssetsApi::estimate_network_fee`]
1051#[derive(Debug, Clone, Serialize, Deserialize)]
1052#[serde(untagged)]
1053pub enum EstimateNetworkFeeError {
1054    DefaultResponse(models::ErrorSchema),
1055    UnknownValue(serde_json::Value),
1056}
1057
1058/// struct for typed errors of method [`BlockchainsAssetsApi::get_asset`]
1059#[derive(Debug, Clone, Serialize, Deserialize)]
1060#[serde(untagged)]
1061pub enum GetAssetError {
1062    Status404(models::AssetNotFoundErrorResponse),
1063    Status500(models::AssetInternalServerErrorResponse),
1064    DefaultResponse(models::ErrorSchema),
1065    UnknownValue(serde_json::Value),
1066}
1067
1068/// struct for typed errors of method [`BlockchainsAssetsApi::get_blockchain`]
1069#[derive(Debug, Clone, Serialize, Deserialize)]
1070#[serde(untagged)]
1071pub enum GetBlockchainError {
1072    Status404(models::BlockchainNotFoundErrorResponse),
1073    Status500(models::AssetInternalServerErrorResponse),
1074    DefaultResponse(models::ErrorSchema),
1075    UnknownValue(serde_json::Value),
1076}
1077
1078/// struct for typed errors of method
1079/// [`BlockchainsAssetsApi::get_supported_assets`]
1080#[derive(Debug, Clone, Serialize, Deserialize)]
1081#[serde(untagged)]
1082pub enum GetSupportedAssetsError {
1083    DefaultResponse(models::ErrorSchema),
1084    UnknownValue(serde_json::Value),
1085}
1086
1087/// struct for typed errors of method [`BlockchainsAssetsApi::list_assets`]
1088#[derive(Debug, Clone, Serialize, Deserialize)]
1089#[serde(untagged)]
1090pub enum ListAssetsError {
1091    Status500(models::AssetInternalServerErrorResponse),
1092    DefaultResponse(models::ErrorSchema),
1093    UnknownValue(serde_json::Value),
1094}
1095
1096/// struct for typed errors of method [`BlockchainsAssetsApi::list_blockchains`]
1097#[derive(Debug, Clone, Serialize, Deserialize)]
1098#[serde(untagged)]
1099pub enum ListBlockchainsError {
1100    Status500(models::AssetInternalServerErrorResponse),
1101    DefaultResponse(models::ErrorSchema),
1102    UnknownValue(serde_json::Value),
1103}
1104
1105/// struct for typed errors of method
1106/// [`BlockchainsAssetsApi::register_new_asset`]
1107#[derive(Debug, Clone, Serialize, Deserialize)]
1108#[serde(untagged)]
1109pub enum RegisterNewAssetError {
1110    Status400(models::AssetBadRequestErrorResponse),
1111    Status403(models::AssetForbiddenErrorResponse),
1112    Status404(models::TokenInfoNotFoundErrorResponse),
1113    Status409(models::AssetConflictErrorResponse),
1114    Status500(models::AssetInternalServerErrorResponse),
1115    DefaultResponse(models::ErrorSchema),
1116    UnknownValue(serde_json::Value),
1117}
1118
1119/// struct for typed errors of method [`BlockchainsAssetsApi::set_asset_price`]
1120#[derive(Debug, Clone, Serialize, Deserialize)]
1121#[serde(untagged)]
1122pub enum SetAssetPriceError {
1123    Status403(models::AssetPriceForbiddenErrorResponse),
1124    Status404(models::AssetPriceNotFoundErrorResponse),
1125    DefaultResponse(models::ErrorSchema),
1126    UnknownValue(serde_json::Value),
1127}
1128
1129/// struct for typed errors of method
1130/// [`BlockchainsAssetsApi::update_asset_user_metadata`]
1131#[derive(Debug, Clone, Serialize, Deserialize)]
1132#[serde(untagged)]
1133pub enum UpdateAssetUserMetadataError {
1134    Status404(models::AssetNotFoundErrorResponse),
1135    Status500(models::AssetInternalServerErrorResponse),
1136    DefaultResponse(models::ErrorSchema),
1137    UnknownValue(serde_json::Value),
1138}
1139
1140/// struct for typed errors of method [`BlockchainsAssetsApi::validate_address`]
1141#[derive(Debug, Clone, Serialize, Deserialize)]
1142#[serde(untagged)]
1143pub enum ValidateAddressError {
1144    DefaultResponse(models::ErrorSchema),
1145    UnknownValue(serde_json::Value),
1146}