fireblocks_sdk/apis/
nfts_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 NftsApi: Send + Sync {
23    /// GET /nfts/tokens/{id}
24    ///
25    /// Returns the requested token data. </br>Endpoint Permission: Admin,
26    /// Non-Signing Admin, Signer, Approver, Editor.
27    async fn get_nft(
28        &self,
29        params: GetNftParams,
30    ) -> Result<models::TokenResponse, Error<GetNftError>>;
31
32    /// GET /nfts/tokens
33    ///
34    /// Returns the requested tokens data. </br>Endpoint Permission: Admin,
35    /// Non-Signing Admin, Signer, Approver, Editor.
36    async fn get_nfts(
37        &self,
38        params: GetNftsParams,
39    ) -> Result<models::GetNftsResponse, Error<GetNftsError>>;
40
41    /// GET /nfts/ownership/tokens
42    ///
43    /// Returns all tokens and their data in your workspace.  </br>Endpoint
44    /// Permission: Admin, Non-Signing Admin, Signer, Approver, Editor.
45    async fn get_ownership_tokens(
46        &self,
47        params: GetOwnershipTokensParams,
48    ) -> Result<models::GetOwnershipTokensResponse, Error<GetOwnershipTokensError>>;
49
50    /// GET /nfts/ownership/collections
51    ///
52    /// Returns all collections in your workspace. </br>Endpoint Permission:
53    /// Admin, Non-Signing Admin, Signer, Approver, Editor.
54    async fn list_owned_collections(
55        &self,
56        params: ListOwnedCollectionsParams,
57    ) -> Result<models::ListOwnedCollectionsResponse, Error<ListOwnedCollectionsError>>;
58
59    /// GET /nfts/ownership/assets
60    ///
61    /// Returns all owned distinct tokens (for your workspace) and their data in
62    /// your workspace. </br>Endpoint Permission: Admin, Non-Signing Admin,
63    /// Signer, Approver, Editor.
64    async fn list_owned_tokens(
65        &self,
66        params: ListOwnedTokensParams,
67    ) -> Result<models::ListOwnedTokensResponse, Error<ListOwnedTokensError>>;
68
69    /// PUT /nfts/tokens/{id}
70    ///
71    /// Updates the latest token metadata. Learn more about Fireblocks NFT management in the following [guide](https://developers.fireblocks.com/reference/deploy-an-nft-collection).  </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver, Editor.
72    async fn refresh_nft_metadata(
73        &self,
74        params: RefreshNftMetadataParams,
75    ) -> Result<(), Error<RefreshNftMetadataError>>;
76
77    /// PUT /nfts/ownership/tokens
78    ///
79    /// Updates all tokens and balances per blockchain and vault account. Learn more about Fireblocks NFT management in the following [guide](https://developers.fireblocks.com/reference/deploy-an-nft-collection).  </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver, Editor.
80    async fn update_ownership_tokens(
81        &self,
82        params: UpdateOwnershipTokensParams,
83    ) -> Result<(), Error<UpdateOwnershipTokensError>>;
84
85    /// PUT /nfts/ownership/tokens/{id}/status
86    ///
87    /// Updates token status for a workspace, in all workspace vaults.
88    /// </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver,
89    /// Editor.
90    async fn update_token_ownership_status(
91        &self,
92        params: UpdateTokenOwnershipStatusParams,
93    ) -> Result<(), Error<UpdateTokenOwnershipStatusError>>;
94
95    /// PUT /nfts/ownership/tokens/spam
96    ///
97    /// Updates tokens spam property for a workspace's token ownerships, in all
98    /// vault accounts.  </br>Endpoint Permission: Admin, Non-Signing Admin,
99    /// Signer, Approver, Editor.
100    async fn update_tokens_ownership_spam(
101        &self,
102        params: UpdateTokensOwnershipSpamParams,
103    ) -> Result<(), Error<UpdateTokensOwnershipSpamError>>;
104
105    /// PUT /nfts/ownership/tokens/status
106    ///
107    /// Updates tokens status for a workspace, in all vault accounts.
108    /// </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver,
109    /// Editor.
110    async fn update_tokens_ownership_status(
111        &self,
112        params: UpdateTokensOwnershipStatusParams,
113    ) -> Result<(), Error<UpdateTokensOwnershipStatusError>>;
114}
115
116pub struct NftsApiClient {
117    configuration: Arc<configuration::Configuration>,
118}
119
120impl NftsApiClient {
121    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
122        Self { configuration }
123    }
124}
125
126/// struct for passing parameters to the method [`NftsApi::get_nft`]
127#[derive(Clone, Debug)]
128#[cfg_attr(feature = "bon", derive(::bon::Builder))]
129pub struct GetNftParams {
130    /// NFT ID
131    pub id: String,
132}
133
134/// struct for passing parameters to the method [`NftsApi::get_nfts`]
135#[derive(Clone, Debug)]
136#[cfg_attr(feature = "bon", derive(::bon::Builder))]
137pub struct GetNftsParams {
138    /// A comma separated list of NFT IDs. Up to 100 are allowed in a single
139    /// request.
140    pub ids: String,
141    /// Page cursor to fetch
142    pub page_cursor: Option<String>,
143    /// Items per page (max 100)
144    pub page_size: Option<f64>,
145    /// Sort by param, it can be one param or a list of params separated by
146    /// comma
147    pub sort: Option<Vec<String>>,
148    /// Order direction, it can be `ASC` for ascending or `DESC` for descending
149    pub order: Option<String>,
150}
151
152/// struct for passing parameters to the method
153/// [`NftsApi::get_ownership_tokens`]
154#[derive(Clone, Debug)]
155#[cfg_attr(feature = "bon", derive(::bon::Builder))]
156pub struct GetOwnershipTokensParams {
157    /// Blockchain descriptor filter
158    pub blockchain_descriptor: Option<String>,
159    /// A comma separated list of Vault Account IDs. Up to 100 are allowed in a
160    /// single request.  This field will be ignored when
161    /// walletType=END_USER_WALLET or ncwId is provided.
162    pub vault_account_ids: Option<String>,
163    /// Non-Custodial Wallet ID
164    pub ncw_id: Option<String>,
165    /// A comma separated list of Non-Custodial account IDs. Up to 100 are
166    /// allowed in a single request. This field will be ignored when
167    /// walletType=VAULT_ACCOUNT or ncwId is not provided.
168    pub ncw_account_ids: Option<String>,
169    /// Wallet type, it can be `VAULT_ACCOUNT` or `END_USER_WALLET`
170    pub wallet_type: Option<String>,
171    /// A comma separated list of NFT IDs. Up to 100 are allowed in a single
172    /// request.
173    pub ids: Option<String>,
174    /// A comma separated list of collection IDs. Up to 100 are allowed in a
175    /// single request.
176    pub collection_ids: Option<String>,
177    /// Page cursor to fetch
178    pub page_cursor: Option<String>,
179    /// Items per page (max 100)
180    pub page_size: Option<f64>,
181    /// Sort by param, it can be one param or a list of params separated by
182    /// comma
183    pub sort: Option<Vec<String>>,
184    /// Order direction, it can be `ASC` for ascending or `DESC` for descending
185    pub order: Option<String>,
186    /// Token ownership status
187    pub status: Option<String>,
188    /// Search owned tokens and their collections. Possible criteria for search:
189    /// token name and id within the contract/collection, collection name,
190    /// blockchain descriptor and name.
191    pub search: Option<String>,
192    /// Token ownership spam status.
193    pub spam: Option<String>,
194}
195
196/// struct for passing parameters to the method
197/// [`NftsApi::list_owned_collections`]
198#[derive(Clone, Debug)]
199#[cfg_attr(feature = "bon", derive(::bon::Builder))]
200pub struct ListOwnedCollectionsParams {
201    /// Tenant's Non-Custodial Wallet ID
202    pub ncw_id: Option<String>,
203    /// Wallet type, it can be `VAULT_ACCOUNT` or `END_USER_WALLET`
204    pub wallet_type: Option<String>,
205    /// Search owned collections. Possible criteria for search: collection name,
206    /// collection contract address.
207    pub search: Option<String>,
208    /// Page cursor to fetch
209    pub page_cursor: Option<String>,
210    /// Items per page (max 100)
211    pub page_size: Option<f64>,
212    /// Sort by param, it can be one param or a list of params separated by
213    /// comma
214    pub sort: Option<Vec<String>>,
215    /// Order direction, it can be `ASC` for ascending or `DESC` for descending
216    pub order: Option<String>,
217    /// Token ownership status
218    pub status: Option<String>,
219}
220
221/// struct for passing parameters to the method [`NftsApi::list_owned_tokens`]
222#[derive(Clone, Debug)]
223#[cfg_attr(feature = "bon", derive(::bon::Builder))]
224pub struct ListOwnedTokensParams {
225    /// Non-Custodial Wallet ID
226    pub ncw_id: Option<String>,
227    /// Wallet type, it can be `VAULT_ACCOUNT` or `END_USER_WALLET`
228    pub wallet_type: Option<String>,
229    /// Page cursor to fetch
230    pub page_cursor: Option<String>,
231    /// Items per page (max 100)
232    pub page_size: Option<f64>,
233    /// Sort by param, it can be one param or a list of params separated by
234    /// comma
235    pub sort: Option<Vec<String>>,
236    /// Order direction, it can be `ASC` for ascending or `DESC` for descending
237    pub order: Option<String>,
238    /// Token ownership status
239    pub status: Option<String>,
240    /// Search owned tokens by token name
241    pub search: Option<String>,
242    /// Token ownership spam status.
243    pub spam: Option<String>,
244}
245
246/// struct for passing parameters to the method
247/// [`NftsApi::refresh_nft_metadata`]
248#[derive(Clone, Debug)]
249#[cfg_attr(feature = "bon", derive(::bon::Builder))]
250pub struct RefreshNftMetadataParams {
251    /// NFT ID
252    pub id: String,
253    /// A unique identifier for the request. If the request is sent multiple
254    /// times with the same idempotency key, the server will return the same
255    /// response as the first request. The idempotency key is valid for 24
256    /// hours.
257    pub idempotency_key: Option<String>,
258}
259
260/// struct for passing parameters to the method
261/// [`NftsApi::update_ownership_tokens`]
262#[derive(Clone, Debug)]
263#[cfg_attr(feature = "bon", derive(::bon::Builder))]
264pub struct UpdateOwnershipTokensParams {
265    /// Blockchain descriptor filter
266    pub blockchain_descriptor: String,
267    /// Vault account filter
268    pub vault_account_id: String,
269    /// A unique identifier for the request. If the request is sent multiple
270    /// times with the same idempotency key, the server will return the same
271    /// response as the first request. The idempotency key is valid for 24
272    /// hours.
273    pub idempotency_key: Option<String>,
274}
275
276/// struct for passing parameters to the method
277/// [`NftsApi::update_token_ownership_status`]
278#[derive(Clone, Debug)]
279#[cfg_attr(feature = "bon", derive(::bon::Builder))]
280pub struct UpdateTokenOwnershipStatusParams {
281    /// NFT ID
282    pub id: String,
283    pub update_token_ownership_status_dto: models::UpdateTokenOwnershipStatusDto,
284    /// A unique identifier for the request. If the request is sent multiple
285    /// times with the same idempotency key, the server will return the same
286    /// response as the first request. The idempotency key is valid for 24
287    /// hours.
288    pub idempotency_key: Option<String>,
289}
290
291/// struct for passing parameters to the method
292/// [`NftsApi::update_tokens_ownership_spam`]
293#[derive(Clone, Debug)]
294#[cfg_attr(feature = "bon", derive(::bon::Builder))]
295pub struct UpdateTokensOwnershipSpamParams {
296    pub token_ownership_spam_update_payload: Vec<models::TokenOwnershipSpamUpdatePayload>,
297    /// A unique identifier for the request. If the request is sent multiple
298    /// times with the same idempotency key, the server will return the same
299    /// response as the first request. The idempotency key is valid for 24
300    /// hours.
301    pub idempotency_key: Option<String>,
302}
303
304/// struct for passing parameters to the method
305/// [`NftsApi::update_tokens_ownership_status`]
306#[derive(Clone, Debug)]
307#[cfg_attr(feature = "bon", derive(::bon::Builder))]
308pub struct UpdateTokensOwnershipStatusParams {
309    pub token_ownership_status_update_payload: Vec<models::TokenOwnershipStatusUpdatePayload>,
310    /// A unique identifier for the request. If the request is sent multiple
311    /// times with the same idempotency key, the server will return the same
312    /// response as the first request. The idempotency key is valid for 24
313    /// hours.
314    pub idempotency_key: Option<String>,
315}
316
317#[async_trait]
318impl NftsApi for NftsApiClient {
319    /// Returns the requested token data. </br>Endpoint Permission: Admin,
320    /// Non-Signing Admin, Signer, Approver, Editor.
321    async fn get_nft(
322        &self,
323        params: GetNftParams,
324    ) -> Result<models::TokenResponse, Error<GetNftError>> {
325        let GetNftParams { id } = params;
326
327        let local_var_configuration = &self.configuration;
328
329        let local_var_client = &local_var_configuration.client;
330
331        let local_var_uri_str = format!(
332            "{}/nfts/tokens/{id}",
333            local_var_configuration.base_path,
334            id = crate::apis::urlencode(id)
335        );
336        let mut local_var_req_builder =
337            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
338
339        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
340            local_var_req_builder = local_var_req_builder
341                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
342        }
343
344        let local_var_req = local_var_req_builder.build()?;
345        let local_var_resp = local_var_client.execute(local_var_req).await?;
346
347        let local_var_status = local_var_resp.status();
348        let local_var_content_type = local_var_resp
349            .headers()
350            .get("content-type")
351            .and_then(|v| v.to_str().ok())
352            .unwrap_or("application/octet-stream");
353        let local_var_content_type = super::ContentType::from(local_var_content_type);
354        let local_var_content = local_var_resp.text().await?;
355
356        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
357            match local_var_content_type {
358                ContentType::Json => {
359                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
360                }
361                ContentType::Text => {
362                    return Err(Error::from(serde_json::Error::custom(
363                        "Received `text/plain` content type response that cannot be converted to \
364                         `models::TokenResponse`",
365                    )));
366                }
367                ContentType::Unsupported(local_var_unknown_type) => {
368                    return Err(Error::from(serde_json::Error::custom(format!(
369                        "Received `{local_var_unknown_type}` content type response that cannot be \
370                         converted to `models::TokenResponse`"
371                    ))));
372                }
373            }
374        } else {
375            let local_var_entity: Option<GetNftError> =
376                serde_json::from_str(&local_var_content).ok();
377            let local_var_error = ResponseContent {
378                status: local_var_status,
379                content: local_var_content,
380                entity: local_var_entity,
381            };
382            Err(Error::ResponseError(local_var_error))
383        }
384    }
385
386    /// Returns the requested tokens data. </br>Endpoint Permission: Admin,
387    /// Non-Signing Admin, Signer, Approver, Editor.
388    async fn get_nfts(
389        &self,
390        params: GetNftsParams,
391    ) -> Result<models::GetNftsResponse, Error<GetNftsError>> {
392        let GetNftsParams {
393            ids,
394            page_cursor,
395            page_size,
396            sort,
397            order,
398        } = params;
399
400        let local_var_configuration = &self.configuration;
401
402        let local_var_client = &local_var_configuration.client;
403
404        let local_var_uri_str = format!("{}/nfts/tokens", local_var_configuration.base_path);
405        let mut local_var_req_builder =
406            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
407
408        local_var_req_builder = local_var_req_builder.query(&[("ids", &ids.to_string())]);
409        if let Some(ref param_value) = page_cursor {
410            local_var_req_builder =
411                local_var_req_builder.query(&[("pageCursor", &param_value.to_string())]);
412        }
413        if let Some(ref param_value) = page_size {
414            local_var_req_builder =
415                local_var_req_builder.query(&[("pageSize", &param_value.to_string())]);
416        }
417        if let Some(ref param_value) = sort {
418            local_var_req_builder = match "multi" {
419                "multi" => local_var_req_builder.query(
420                    &param_value
421                        .into_iter()
422                        .map(|p| ("sort".to_owned(), p.to_string()))
423                        .collect::<Vec<(std::string::String, std::string::String)>>(),
424                ),
425                _ => local_var_req_builder.query(&[(
426                    "sort",
427                    &param_value
428                        .into_iter()
429                        .map(|p| p.to_string())
430                        .collect::<Vec<String>>()
431                        .join(",")
432                        .to_string(),
433                )]),
434            };
435        }
436        if let Some(ref param_value) = order {
437            local_var_req_builder =
438                local_var_req_builder.query(&[("order", &param_value.to_string())]);
439        }
440        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
441            local_var_req_builder = local_var_req_builder
442                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
443        }
444
445        let local_var_req = local_var_req_builder.build()?;
446        let local_var_resp = local_var_client.execute(local_var_req).await?;
447
448        let local_var_status = local_var_resp.status();
449        let local_var_content_type = local_var_resp
450            .headers()
451            .get("content-type")
452            .and_then(|v| v.to_str().ok())
453            .unwrap_or("application/octet-stream");
454        let local_var_content_type = super::ContentType::from(local_var_content_type);
455        let local_var_content = local_var_resp.text().await?;
456
457        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
458            match local_var_content_type {
459                ContentType::Json => {
460                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
461                }
462                ContentType::Text => {
463                    return Err(Error::from(serde_json::Error::custom(
464                        "Received `text/plain` content type response that cannot be converted to \
465                         `models::GetNftsResponse`",
466                    )));
467                }
468                ContentType::Unsupported(local_var_unknown_type) => {
469                    return Err(Error::from(serde_json::Error::custom(format!(
470                        "Received `{local_var_unknown_type}` content type response that cannot be \
471                         converted to `models::GetNftsResponse`"
472                    ))));
473                }
474            }
475        } else {
476            let local_var_entity: Option<GetNftsError> =
477                serde_json::from_str(&local_var_content).ok();
478            let local_var_error = ResponseContent {
479                status: local_var_status,
480                content: local_var_content,
481                entity: local_var_entity,
482            };
483            Err(Error::ResponseError(local_var_error))
484        }
485    }
486
487    /// Returns all tokens and their data in your workspace.  </br>Endpoint
488    /// Permission: Admin, Non-Signing Admin, Signer, Approver, Editor.
489    async fn get_ownership_tokens(
490        &self,
491        params: GetOwnershipTokensParams,
492    ) -> Result<models::GetOwnershipTokensResponse, Error<GetOwnershipTokensError>> {
493        let GetOwnershipTokensParams {
494            blockchain_descriptor,
495            vault_account_ids,
496            ncw_id,
497            ncw_account_ids,
498            wallet_type,
499            ids,
500            collection_ids,
501            page_cursor,
502            page_size,
503            sort,
504            order,
505            status,
506            search,
507            spam,
508        } = params;
509
510        let local_var_configuration = &self.configuration;
511
512        let local_var_client = &local_var_configuration.client;
513
514        let local_var_uri_str = format!(
515            "{}/nfts/ownership/tokens",
516            local_var_configuration.base_path
517        );
518        let mut local_var_req_builder =
519            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
520
521        if let Some(ref param_value) = blockchain_descriptor {
522            local_var_req_builder =
523                local_var_req_builder.query(&[("blockchainDescriptor", &param_value.to_string())]);
524        }
525        if let Some(ref param_value) = vault_account_ids {
526            local_var_req_builder =
527                local_var_req_builder.query(&[("vaultAccountIds", &param_value.to_string())]);
528        }
529        if let Some(ref param_value) = ncw_id {
530            local_var_req_builder =
531                local_var_req_builder.query(&[("ncwId", &param_value.to_string())]);
532        }
533        if let Some(ref param_value) = ncw_account_ids {
534            local_var_req_builder =
535                local_var_req_builder.query(&[("ncwAccountIds", &param_value.to_string())]);
536        }
537        if let Some(ref param_value) = wallet_type {
538            local_var_req_builder =
539                local_var_req_builder.query(&[("walletType", &param_value.to_string())]);
540        }
541        if let Some(ref param_value) = ids {
542            local_var_req_builder =
543                local_var_req_builder.query(&[("ids", &param_value.to_string())]);
544        }
545        if let Some(ref param_value) = collection_ids {
546            local_var_req_builder =
547                local_var_req_builder.query(&[("collectionIds", &param_value.to_string())]);
548        }
549        if let Some(ref param_value) = page_cursor {
550            local_var_req_builder =
551                local_var_req_builder.query(&[("pageCursor", &param_value.to_string())]);
552        }
553        if let Some(ref param_value) = page_size {
554            local_var_req_builder =
555                local_var_req_builder.query(&[("pageSize", &param_value.to_string())]);
556        }
557        if let Some(ref param_value) = sort {
558            local_var_req_builder = match "multi" {
559                "multi" => local_var_req_builder.query(
560                    &param_value
561                        .into_iter()
562                        .map(|p| ("sort".to_owned(), p.to_string()))
563                        .collect::<Vec<(std::string::String, std::string::String)>>(),
564                ),
565                _ => local_var_req_builder.query(&[(
566                    "sort",
567                    &param_value
568                        .into_iter()
569                        .map(|p| p.to_string())
570                        .collect::<Vec<String>>()
571                        .join(",")
572                        .to_string(),
573                )]),
574            };
575        }
576        if let Some(ref param_value) = order {
577            local_var_req_builder =
578                local_var_req_builder.query(&[("order", &param_value.to_string())]);
579        }
580        if let Some(ref param_value) = status {
581            local_var_req_builder =
582                local_var_req_builder.query(&[("status", &param_value.to_string())]);
583        }
584        if let Some(ref param_value) = search {
585            local_var_req_builder =
586                local_var_req_builder.query(&[("search", &param_value.to_string())]);
587        }
588        if let Some(ref param_value) = spam {
589            local_var_req_builder =
590                local_var_req_builder.query(&[("spam", &param_value.to_string())]);
591        }
592        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
593            local_var_req_builder = local_var_req_builder
594                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
595        }
596
597        let local_var_req = local_var_req_builder.build()?;
598        let local_var_resp = local_var_client.execute(local_var_req).await?;
599
600        let local_var_status = local_var_resp.status();
601        let local_var_content_type = local_var_resp
602            .headers()
603            .get("content-type")
604            .and_then(|v| v.to_str().ok())
605            .unwrap_or("application/octet-stream");
606        let local_var_content_type = super::ContentType::from(local_var_content_type);
607        let local_var_content = local_var_resp.text().await?;
608
609        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
610            match local_var_content_type {
611                ContentType::Json => {
612                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
613                }
614                ContentType::Text => {
615                    return Err(Error::from(serde_json::Error::custom(
616                        "Received `text/plain` content type response that cannot be converted to \
617                         `models::GetOwnershipTokensResponse`",
618                    )));
619                }
620                ContentType::Unsupported(local_var_unknown_type) => {
621                    return Err(Error::from(serde_json::Error::custom(format!(
622                        "Received `{local_var_unknown_type}` content type response that cannot be \
623                         converted to `models::GetOwnershipTokensResponse`"
624                    ))));
625                }
626            }
627        } else {
628            let local_var_entity: Option<GetOwnershipTokensError> =
629                serde_json::from_str(&local_var_content).ok();
630            let local_var_error = ResponseContent {
631                status: local_var_status,
632                content: local_var_content,
633                entity: local_var_entity,
634            };
635            Err(Error::ResponseError(local_var_error))
636        }
637    }
638
639    /// Returns all collections in your workspace. </br>Endpoint Permission:
640    /// Admin, Non-Signing Admin, Signer, Approver, Editor.
641    async fn list_owned_collections(
642        &self,
643        params: ListOwnedCollectionsParams,
644    ) -> Result<models::ListOwnedCollectionsResponse, Error<ListOwnedCollectionsError>> {
645        let ListOwnedCollectionsParams {
646            ncw_id,
647            wallet_type,
648            search,
649            page_cursor,
650            page_size,
651            sort,
652            order,
653            status,
654        } = params;
655
656        let local_var_configuration = &self.configuration;
657
658        let local_var_client = &local_var_configuration.client;
659
660        let local_var_uri_str = format!(
661            "{}/nfts/ownership/collections",
662            local_var_configuration.base_path
663        );
664        let mut local_var_req_builder =
665            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
666
667        if let Some(ref param_value) = ncw_id {
668            local_var_req_builder =
669                local_var_req_builder.query(&[("ncwId", &param_value.to_string())]);
670        }
671        if let Some(ref param_value) = wallet_type {
672            local_var_req_builder =
673                local_var_req_builder.query(&[("walletType", &param_value.to_string())]);
674        }
675        if let Some(ref param_value) = search {
676            local_var_req_builder =
677                local_var_req_builder.query(&[("search", &param_value.to_string())]);
678        }
679        if let Some(ref param_value) = page_cursor {
680            local_var_req_builder =
681                local_var_req_builder.query(&[("pageCursor", &param_value.to_string())]);
682        }
683        if let Some(ref param_value) = page_size {
684            local_var_req_builder =
685                local_var_req_builder.query(&[("pageSize", &param_value.to_string())]);
686        }
687        if let Some(ref param_value) = sort {
688            local_var_req_builder = match "multi" {
689                "multi" => local_var_req_builder.query(
690                    &param_value
691                        .into_iter()
692                        .map(|p| ("sort".to_owned(), p.to_string()))
693                        .collect::<Vec<(std::string::String, std::string::String)>>(),
694                ),
695                _ => local_var_req_builder.query(&[(
696                    "sort",
697                    &param_value
698                        .into_iter()
699                        .map(|p| p.to_string())
700                        .collect::<Vec<String>>()
701                        .join(",")
702                        .to_string(),
703                )]),
704            };
705        }
706        if let Some(ref param_value) = order {
707            local_var_req_builder =
708                local_var_req_builder.query(&[("order", &param_value.to_string())]);
709        }
710        if let Some(ref param_value) = status {
711            local_var_req_builder =
712                local_var_req_builder.query(&[("status", &param_value.to_string())]);
713        }
714        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
715            local_var_req_builder = local_var_req_builder
716                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
717        }
718
719        let local_var_req = local_var_req_builder.build()?;
720        let local_var_resp = local_var_client.execute(local_var_req).await?;
721
722        let local_var_status = local_var_resp.status();
723        let local_var_content_type = local_var_resp
724            .headers()
725            .get("content-type")
726            .and_then(|v| v.to_str().ok())
727            .unwrap_or("application/octet-stream");
728        let local_var_content_type = super::ContentType::from(local_var_content_type);
729        let local_var_content = local_var_resp.text().await?;
730
731        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
732            match local_var_content_type {
733                ContentType::Json => {
734                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
735                }
736                ContentType::Text => {
737                    return Err(Error::from(serde_json::Error::custom(
738                        "Received `text/plain` content type response that cannot be converted to \
739                         `models::ListOwnedCollectionsResponse`",
740                    )));
741                }
742                ContentType::Unsupported(local_var_unknown_type) => {
743                    return Err(Error::from(serde_json::Error::custom(format!(
744                        "Received `{local_var_unknown_type}` content type response that cannot be \
745                         converted to `models::ListOwnedCollectionsResponse`"
746                    ))));
747                }
748            }
749        } else {
750            let local_var_entity: Option<ListOwnedCollectionsError> =
751                serde_json::from_str(&local_var_content).ok();
752            let local_var_error = ResponseContent {
753                status: local_var_status,
754                content: local_var_content,
755                entity: local_var_entity,
756            };
757            Err(Error::ResponseError(local_var_error))
758        }
759    }
760
761    /// Returns all owned distinct tokens (for your workspace) and their data in
762    /// your workspace. </br>Endpoint Permission: Admin, Non-Signing Admin,
763    /// Signer, Approver, Editor.
764    async fn list_owned_tokens(
765        &self,
766        params: ListOwnedTokensParams,
767    ) -> Result<models::ListOwnedTokensResponse, Error<ListOwnedTokensError>> {
768        let ListOwnedTokensParams {
769            ncw_id,
770            wallet_type,
771            page_cursor,
772            page_size,
773            sort,
774            order,
775            status,
776            search,
777            spam,
778        } = params;
779
780        let local_var_configuration = &self.configuration;
781
782        let local_var_client = &local_var_configuration.client;
783
784        let local_var_uri_str = format!(
785            "{}/nfts/ownership/assets",
786            local_var_configuration.base_path
787        );
788        let mut local_var_req_builder =
789            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
790
791        if let Some(ref param_value) = ncw_id {
792            local_var_req_builder =
793                local_var_req_builder.query(&[("ncwId", &param_value.to_string())]);
794        }
795        if let Some(ref param_value) = wallet_type {
796            local_var_req_builder =
797                local_var_req_builder.query(&[("walletType", &param_value.to_string())]);
798        }
799        if let Some(ref param_value) = page_cursor {
800            local_var_req_builder =
801                local_var_req_builder.query(&[("pageCursor", &param_value.to_string())]);
802        }
803        if let Some(ref param_value) = page_size {
804            local_var_req_builder =
805                local_var_req_builder.query(&[("pageSize", &param_value.to_string())]);
806        }
807        if let Some(ref param_value) = sort {
808            local_var_req_builder = match "multi" {
809                "multi" => local_var_req_builder.query(
810                    &param_value
811                        .into_iter()
812                        .map(|p| ("sort".to_owned(), p.to_string()))
813                        .collect::<Vec<(std::string::String, std::string::String)>>(),
814                ),
815                _ => local_var_req_builder.query(&[(
816                    "sort",
817                    &param_value
818                        .into_iter()
819                        .map(|p| p.to_string())
820                        .collect::<Vec<String>>()
821                        .join(",")
822                        .to_string(),
823                )]),
824            };
825        }
826        if let Some(ref param_value) = order {
827            local_var_req_builder =
828                local_var_req_builder.query(&[("order", &param_value.to_string())]);
829        }
830        if let Some(ref param_value) = status {
831            local_var_req_builder =
832                local_var_req_builder.query(&[("status", &param_value.to_string())]);
833        }
834        if let Some(ref param_value) = search {
835            local_var_req_builder =
836                local_var_req_builder.query(&[("search", &param_value.to_string())]);
837        }
838        if let Some(ref param_value) = spam {
839            local_var_req_builder =
840                local_var_req_builder.query(&[("spam", &param_value.to_string())]);
841        }
842        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
843            local_var_req_builder = local_var_req_builder
844                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
845        }
846
847        let local_var_req = local_var_req_builder.build()?;
848        let local_var_resp = local_var_client.execute(local_var_req).await?;
849
850        let local_var_status = local_var_resp.status();
851        let local_var_content_type = local_var_resp
852            .headers()
853            .get("content-type")
854            .and_then(|v| v.to_str().ok())
855            .unwrap_or("application/octet-stream");
856        let local_var_content_type = super::ContentType::from(local_var_content_type);
857        let local_var_content = local_var_resp.text().await?;
858
859        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
860            match local_var_content_type {
861                ContentType::Json => {
862                    crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
863                }
864                ContentType::Text => {
865                    return Err(Error::from(serde_json::Error::custom(
866                        "Received `text/plain` content type response that cannot be converted to \
867                         `models::ListOwnedTokensResponse`",
868                    )));
869                }
870                ContentType::Unsupported(local_var_unknown_type) => {
871                    return Err(Error::from(serde_json::Error::custom(format!(
872                        "Received `{local_var_unknown_type}` content type response that cannot be \
873                         converted to `models::ListOwnedTokensResponse`"
874                    ))));
875                }
876            }
877        } else {
878            let local_var_entity: Option<ListOwnedTokensError> =
879                serde_json::from_str(&local_var_content).ok();
880            let local_var_error = ResponseContent {
881                status: local_var_status,
882                content: local_var_content,
883                entity: local_var_entity,
884            };
885            Err(Error::ResponseError(local_var_error))
886        }
887    }
888
889    /// Updates the latest token metadata. Learn more about Fireblocks NFT management in the following [guide](https://developers.fireblocks.com/reference/deploy-an-nft-collection).  </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver, Editor.
890    async fn refresh_nft_metadata(
891        &self,
892        params: RefreshNftMetadataParams,
893    ) -> Result<(), Error<RefreshNftMetadataError>> {
894        let RefreshNftMetadataParams {
895            id,
896            idempotency_key,
897        } = params;
898
899        let local_var_configuration = &self.configuration;
900
901        let local_var_client = &local_var_configuration.client;
902
903        let local_var_uri_str = format!(
904            "{}/nfts/tokens/{id}",
905            local_var_configuration.base_path,
906            id = crate::apis::urlencode(id)
907        );
908        let mut local_var_req_builder =
909            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
910
911        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
912            local_var_req_builder = local_var_req_builder
913                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
914        }
915        if let Some(local_var_param_value) = idempotency_key {
916            local_var_req_builder =
917                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
918        }
919
920        let local_var_req = local_var_req_builder.build()?;
921        let local_var_resp = local_var_client.execute(local_var_req).await?;
922
923        let local_var_status = local_var_resp.status();
924        let local_var_content = local_var_resp.text().await?;
925
926        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
927            Ok(())
928        } else {
929            let local_var_entity: Option<RefreshNftMetadataError> =
930                serde_json::from_str(&local_var_content).ok();
931            let local_var_error = ResponseContent {
932                status: local_var_status,
933                content: local_var_content,
934                entity: local_var_entity,
935            };
936            Err(Error::ResponseError(local_var_error))
937        }
938    }
939
940    /// Updates all tokens and balances per blockchain and vault account. Learn more about Fireblocks NFT management in the following [guide](https://developers.fireblocks.com/reference/deploy-an-nft-collection).  </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver, Editor.
941    async fn update_ownership_tokens(
942        &self,
943        params: UpdateOwnershipTokensParams,
944    ) -> Result<(), Error<UpdateOwnershipTokensError>> {
945        let UpdateOwnershipTokensParams {
946            blockchain_descriptor,
947            vault_account_id,
948            idempotency_key,
949        } = params;
950
951        let local_var_configuration = &self.configuration;
952
953        let local_var_client = &local_var_configuration.client;
954
955        let local_var_uri_str = format!(
956            "{}/nfts/ownership/tokens",
957            local_var_configuration.base_path
958        );
959        let mut local_var_req_builder =
960            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
961
962        local_var_req_builder = local_var_req_builder
963            .query(&[("blockchainDescriptor", &blockchain_descriptor.to_string())]);
964        local_var_req_builder =
965            local_var_req_builder.query(&[("vaultAccountId", &vault_account_id.to_string())]);
966        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
967            local_var_req_builder = local_var_req_builder
968                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
969        }
970        if let Some(local_var_param_value) = idempotency_key {
971            local_var_req_builder =
972                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
973        }
974
975        let local_var_req = local_var_req_builder.build()?;
976        let local_var_resp = local_var_client.execute(local_var_req).await?;
977
978        let local_var_status = local_var_resp.status();
979        let local_var_content = local_var_resp.text().await?;
980
981        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
982            Ok(())
983        } else {
984            let local_var_entity: Option<UpdateOwnershipTokensError> =
985                serde_json::from_str(&local_var_content).ok();
986            let local_var_error = ResponseContent {
987                status: local_var_status,
988                content: local_var_content,
989                entity: local_var_entity,
990            };
991            Err(Error::ResponseError(local_var_error))
992        }
993    }
994
995    /// Updates token status for a workspace, in all workspace vaults.
996    /// </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver,
997    /// Editor.
998    async fn update_token_ownership_status(
999        &self,
1000        params: UpdateTokenOwnershipStatusParams,
1001    ) -> Result<(), Error<UpdateTokenOwnershipStatusError>> {
1002        let UpdateTokenOwnershipStatusParams {
1003            id,
1004            update_token_ownership_status_dto,
1005            idempotency_key,
1006        } = params;
1007
1008        let local_var_configuration = &self.configuration;
1009
1010        let local_var_client = &local_var_configuration.client;
1011
1012        let local_var_uri_str = format!(
1013            "{}/nfts/ownership/tokens/{id}/status",
1014            local_var_configuration.base_path,
1015            id = crate::apis::urlencode(id)
1016        );
1017        let mut local_var_req_builder =
1018            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1019
1020        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1021            local_var_req_builder = local_var_req_builder
1022                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1023        }
1024        if let Some(local_var_param_value) = idempotency_key {
1025            local_var_req_builder =
1026                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1027        }
1028        local_var_req_builder = local_var_req_builder.json(&update_token_ownership_status_dto);
1029
1030        let local_var_req = local_var_req_builder.build()?;
1031        let local_var_resp = local_var_client.execute(local_var_req).await?;
1032
1033        let local_var_status = local_var_resp.status();
1034        let local_var_content = local_var_resp.text().await?;
1035
1036        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1037            Ok(())
1038        } else {
1039            let local_var_entity: Option<UpdateTokenOwnershipStatusError> =
1040                serde_json::from_str(&local_var_content).ok();
1041            let local_var_error = ResponseContent {
1042                status: local_var_status,
1043                content: local_var_content,
1044                entity: local_var_entity,
1045            };
1046            Err(Error::ResponseError(local_var_error))
1047        }
1048    }
1049
1050    /// Updates tokens spam property for a workspace's token ownerships, in all
1051    /// vault accounts.  </br>Endpoint Permission: Admin, Non-Signing Admin,
1052    /// Signer, Approver, Editor.
1053    async fn update_tokens_ownership_spam(
1054        &self,
1055        params: UpdateTokensOwnershipSpamParams,
1056    ) -> Result<(), Error<UpdateTokensOwnershipSpamError>> {
1057        let UpdateTokensOwnershipSpamParams {
1058            token_ownership_spam_update_payload,
1059            idempotency_key,
1060        } = params;
1061
1062        let local_var_configuration = &self.configuration;
1063
1064        let local_var_client = &local_var_configuration.client;
1065
1066        let local_var_uri_str = format!(
1067            "{}/nfts/ownership/tokens/spam",
1068            local_var_configuration.base_path
1069        );
1070        let mut local_var_req_builder =
1071            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1072
1073        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1074            local_var_req_builder = local_var_req_builder
1075                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1076        }
1077        if let Some(local_var_param_value) = idempotency_key {
1078            local_var_req_builder =
1079                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1080        }
1081        local_var_req_builder = local_var_req_builder.json(&token_ownership_spam_update_payload);
1082
1083        let local_var_req = local_var_req_builder.build()?;
1084        let local_var_resp = local_var_client.execute(local_var_req).await?;
1085
1086        let local_var_status = local_var_resp.status();
1087        let local_var_content = local_var_resp.text().await?;
1088
1089        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1090            Ok(())
1091        } else {
1092            let local_var_entity: Option<UpdateTokensOwnershipSpamError> =
1093                serde_json::from_str(&local_var_content).ok();
1094            let local_var_error = ResponseContent {
1095                status: local_var_status,
1096                content: local_var_content,
1097                entity: local_var_entity,
1098            };
1099            Err(Error::ResponseError(local_var_error))
1100        }
1101    }
1102
1103    /// Updates tokens status for a workspace, in all vault accounts.
1104    /// </br>Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver,
1105    /// Editor.
1106    async fn update_tokens_ownership_status(
1107        &self,
1108        params: UpdateTokensOwnershipStatusParams,
1109    ) -> Result<(), Error<UpdateTokensOwnershipStatusError>> {
1110        let UpdateTokensOwnershipStatusParams {
1111            token_ownership_status_update_payload,
1112            idempotency_key,
1113        } = params;
1114
1115        let local_var_configuration = &self.configuration;
1116
1117        let local_var_client = &local_var_configuration.client;
1118
1119        let local_var_uri_str = format!(
1120            "{}/nfts/ownership/tokens/status",
1121            local_var_configuration.base_path
1122        );
1123        let mut local_var_req_builder =
1124            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1125
1126        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1127            local_var_req_builder = local_var_req_builder
1128                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1129        }
1130        if let Some(local_var_param_value) = idempotency_key {
1131            local_var_req_builder =
1132                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1133        }
1134        local_var_req_builder = local_var_req_builder.json(&token_ownership_status_update_payload);
1135
1136        let local_var_req = local_var_req_builder.build()?;
1137        let local_var_resp = local_var_client.execute(local_var_req).await?;
1138
1139        let local_var_status = local_var_resp.status();
1140        let local_var_content = local_var_resp.text().await?;
1141
1142        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1143            Ok(())
1144        } else {
1145            let local_var_entity: Option<UpdateTokensOwnershipStatusError> =
1146                serde_json::from_str(&local_var_content).ok();
1147            let local_var_error = ResponseContent {
1148                status: local_var_status,
1149                content: local_var_content,
1150                entity: local_var_entity,
1151            };
1152            Err(Error::ResponseError(local_var_error))
1153        }
1154    }
1155}
1156
1157/// struct for typed errors of method [`NftsApi::get_nft`]
1158#[derive(Debug, Clone, Serialize, Deserialize)]
1159#[serde(untagged)]
1160pub enum GetNftError {
1161    UnknownValue(serde_json::Value),
1162}
1163
1164/// struct for typed errors of method [`NftsApi::get_nfts`]
1165#[derive(Debug, Clone, Serialize, Deserialize)]
1166#[serde(untagged)]
1167pub enum GetNftsError {
1168    UnknownValue(serde_json::Value),
1169}
1170
1171/// struct for typed errors of method [`NftsApi::get_ownership_tokens`]
1172#[derive(Debug, Clone, Serialize, Deserialize)]
1173#[serde(untagged)]
1174pub enum GetOwnershipTokensError {
1175    UnknownValue(serde_json::Value),
1176}
1177
1178/// struct for typed errors of method [`NftsApi::list_owned_collections`]
1179#[derive(Debug, Clone, Serialize, Deserialize)]
1180#[serde(untagged)]
1181pub enum ListOwnedCollectionsError {
1182    UnknownValue(serde_json::Value),
1183}
1184
1185/// struct for typed errors of method [`NftsApi::list_owned_tokens`]
1186#[derive(Debug, Clone, Serialize, Deserialize)]
1187#[serde(untagged)]
1188pub enum ListOwnedTokensError {
1189    UnknownValue(serde_json::Value),
1190}
1191
1192/// struct for typed errors of method [`NftsApi::refresh_nft_metadata`]
1193#[derive(Debug, Clone, Serialize, Deserialize)]
1194#[serde(untagged)]
1195pub enum RefreshNftMetadataError {
1196    UnknownValue(serde_json::Value),
1197}
1198
1199/// struct for typed errors of method [`NftsApi::update_ownership_tokens`]
1200#[derive(Debug, Clone, Serialize, Deserialize)]
1201#[serde(untagged)]
1202pub enum UpdateOwnershipTokensError {
1203    UnknownValue(serde_json::Value),
1204}
1205
1206/// struct for typed errors of method [`NftsApi::update_token_ownership_status`]
1207#[derive(Debug, Clone, Serialize, Deserialize)]
1208#[serde(untagged)]
1209pub enum UpdateTokenOwnershipStatusError {
1210    UnknownValue(serde_json::Value),
1211}
1212
1213/// struct for typed errors of method [`NftsApi::update_tokens_ownership_spam`]
1214#[derive(Debug, Clone, Serialize, Deserialize)]
1215#[serde(untagged)]
1216pub enum UpdateTokensOwnershipSpamError {
1217    Status400(),
1218    Status404(),
1219    UnknownValue(serde_json::Value),
1220}
1221
1222/// struct for typed errors of method
1223/// [`NftsApi::update_tokens_ownership_status`]
1224#[derive(Debug, Clone, Serialize, Deserialize)]
1225#[serde(untagged)]
1226pub enum UpdateTokensOwnershipStatusError {
1227    Status400(),
1228    Status404(),
1229    UnknownValue(serde_json::Value),
1230}