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