1use {
10 super::{configuration, Error},
11 crate::{
12 apis::{ContentType, ResponseContent},
13 models,
14 },
15 async_trait::async_trait,
16 reqwest,
17 serde::{de::Error as _, Deserialize, Serialize},
18 std::sync::Arc,
19};
20
21#[async_trait]
22pub trait TokenizationApi: Send + Sync {
23 async fn burn_collection_token(
28 &self,
29 params: BurnCollectionTokenParams,
30 ) -> Result<models::CollectionBurnResponseDto, Error<BurnCollectionTokenError>>;
31
32 async fn create_new_collection(
37 &self,
38 params: CreateNewCollectionParams,
39 ) -> Result<models::CollectionLinkDto, Error<CreateNewCollectionError>>;
40
41 async fn fetch_collection_token_details(
46 &self,
47 params: FetchCollectionTokenDetailsParams,
48 ) -> Result<models::CollectionLinkDto, Error<FetchCollectionTokenDetailsError>>;
49
50 async fn get_collection_by_id(
55 &self,
56 params: GetCollectionByIdParams,
57 ) -> Result<models::CollectionLinkDto, Error<GetCollectionByIdError>>;
58
59 async fn get_linked_collections(
64 &self,
65 params: GetLinkedCollectionsParams,
66 ) -> Result<models::GetLinkedCollectionsPaginatedResponse, Error<GetLinkedCollectionsError>>;
67
68 async fn get_linked_token(
73 &self,
74 params: GetLinkedTokenParams,
75 ) -> Result<models::TokenLinkDto, Error<GetLinkedTokenError>>;
76
77 async fn get_linked_tokens(
82 &self,
83 params: GetLinkedTokensParams,
84 ) -> Result<models::TokensPaginatedResponse, Error<GetLinkedTokensError>>;
85
86 async fn issue_new_token(
97 &self,
98 params: IssueNewTokenParams,
99 ) -> Result<models::TokenLinkDto, Error<IssueNewTokenError>>;
100
101 async fn link(&self, params: LinkParams) -> Result<models::TokenLinkDto, Error<LinkError>>;
106
107 async fn mint_collection_token(
112 &self,
113 params: MintCollectionTokenParams,
114 ) -> Result<models::CollectionMintResponseDto, Error<MintCollectionTokenError>>;
115
116 async fn unlink(&self, params: UnlinkParams) -> Result<(), Error<UnlinkError>>;
123
124 async fn unlink_collection(
129 &self,
130 params: UnlinkCollectionParams,
131 ) -> Result<(), Error<UnlinkCollectionError>>;
132}
133
134pub struct TokenizationApiClient {
135 configuration: Arc<configuration::Configuration>,
136}
137
138impl TokenizationApiClient {
139 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
140 Self { configuration }
141 }
142}
143
144#[derive(Clone, Debug)]
146#[cfg_attr(feature = "bon", derive(::bon::Builder))]
147pub struct BurnCollectionTokenParams {
148 pub id: String,
150 pub collection_burn_request_dto: models::CollectionBurnRequestDto,
151 pub idempotency_key: Option<String>,
156}
157
158#[derive(Clone, Debug)]
160#[cfg_attr(feature = "bon", derive(::bon::Builder))]
161pub struct CreateNewCollectionParams {
162 pub collection_deploy_request_dto: models::CollectionDeployRequestDto,
163 pub idempotency_key: Option<String>,
168}
169
170#[derive(Clone, Debug)]
173#[cfg_attr(feature = "bon", derive(::bon::Builder))]
174pub struct FetchCollectionTokenDetailsParams {
175 pub id: String,
177 pub token_id: String,
179}
180
181#[derive(Clone, Debug)]
183#[cfg_attr(feature = "bon", derive(::bon::Builder))]
184pub struct GetCollectionByIdParams {
185 pub id: String,
187}
188
189#[derive(Clone, Debug)]
191#[cfg_attr(feature = "bon", derive(::bon::Builder))]
192pub struct GetLinkedCollectionsParams {
193 pub page_cursor: Option<String>,
196 pub page_size: Option<f64>,
199 pub status: Option<serde_json::Value>,
201}
202
203#[derive(Clone, Debug)]
205#[cfg_attr(feature = "bon", derive(::bon::Builder))]
206pub struct GetLinkedTokenParams {
207 pub id: String,
209}
210
211#[derive(Clone, Debug)]
213#[cfg_attr(feature = "bon", derive(::bon::Builder))]
214pub struct GetLinkedTokensParams {
215 pub page_cursor: Option<String>,
217 pub page_size: Option<f64>,
219 pub status: Option<serde_json::Value>,
221}
222
223#[derive(Clone, Debug)]
225#[cfg_attr(feature = "bon", derive(::bon::Builder))]
226pub struct IssueNewTokenParams {
227 pub create_token_request_dto: models::CreateTokenRequestDto,
228 pub idempotency_key: Option<String>,
233}
234
235#[derive(Clone, Debug)]
237#[cfg_attr(feature = "bon", derive(::bon::Builder))]
238pub struct LinkParams {
239 pub token_link_request_dto: models::TokenLinkRequestDto,
240 pub idempotency_key: Option<String>,
245}
246
247#[derive(Clone, Debug)]
249#[cfg_attr(feature = "bon", derive(::bon::Builder))]
250pub struct MintCollectionTokenParams {
251 pub id: String,
253 pub collection_mint_request_dto: models::CollectionMintRequestDto,
254 pub idempotency_key: Option<String>,
259}
260
261#[derive(Clone, Debug)]
263#[cfg_attr(feature = "bon", derive(::bon::Builder))]
264pub struct UnlinkParams {
265 pub id: String,
267}
268
269#[derive(Clone, Debug)]
271#[cfg_attr(feature = "bon", derive(::bon::Builder))]
272pub struct UnlinkCollectionParams {
273 pub id: String,
275}
276
277#[async_trait]
278impl TokenizationApi for TokenizationApiClient {
279 async fn burn_collection_token(
282 &self,
283 params: BurnCollectionTokenParams,
284 ) -> Result<models::CollectionBurnResponseDto, Error<BurnCollectionTokenError>> {
285 let BurnCollectionTokenParams {
286 id,
287 collection_burn_request_dto,
288 idempotency_key,
289 } = params;
290
291 let local_var_configuration = &self.configuration;
292
293 let local_var_client = &local_var_configuration.client;
294
295 let local_var_uri_str = format!(
296 "{}/tokenization/collections/{id}/tokens/burn",
297 local_var_configuration.base_path,
298 id = crate::apis::urlencode(id)
299 );
300 let mut local_var_req_builder =
301 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
302
303 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
304 local_var_req_builder = local_var_req_builder
305 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
306 }
307 if let Some(local_var_param_value) = idempotency_key {
308 local_var_req_builder =
309 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
310 }
311 local_var_req_builder = local_var_req_builder.json(&collection_burn_request_dto);
312
313 let local_var_req = local_var_req_builder.build()?;
314 let local_var_resp = local_var_client.execute(local_var_req).await?;
315
316 let local_var_status = local_var_resp.status();
317 let local_var_content_type = local_var_resp
318 .headers()
319 .get("content-type")
320 .and_then(|v| v.to_str().ok())
321 .unwrap_or("application/octet-stream");
322 let local_var_content_type = super::ContentType::from(local_var_content_type);
323 let local_var_content = local_var_resp.text().await?;
324
325 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
326 match local_var_content_type {
327 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
328 ContentType::Text => {
329 return Err(Error::from(serde_json::Error::custom(
330 "Received `text/plain` content type response that cannot be converted to \
331 `models::CollectionBurnResponseDto`",
332 )))
333 }
334 ContentType::Unsupported(local_var_unknown_type) => {
335 return Err(Error::from(serde_json::Error::custom(format!(
336 "Received `{local_var_unknown_type}` content type response that cannot be \
337 converted to `models::CollectionBurnResponseDto`"
338 ))))
339 }
340 }
341 } else {
342 let local_var_entity: Option<BurnCollectionTokenError> =
343 serde_json::from_str(&local_var_content).ok();
344 let local_var_error = ResponseContent {
345 status: local_var_status,
346 content: local_var_content,
347 entity: local_var_entity,
348 };
349 Err(Error::ResponseError(local_var_error))
350 }
351 }
352
353 async fn create_new_collection(
356 &self,
357 params: CreateNewCollectionParams,
358 ) -> Result<models::CollectionLinkDto, Error<CreateNewCollectionError>> {
359 let CreateNewCollectionParams {
360 collection_deploy_request_dto,
361 idempotency_key,
362 } = params;
363
364 let local_var_configuration = &self.configuration;
365
366 let local_var_client = &local_var_configuration.client;
367
368 let local_var_uri_str = format!(
369 "{}/tokenization/collections",
370 local_var_configuration.base_path
371 );
372 let mut local_var_req_builder =
373 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
374
375 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
376 local_var_req_builder = local_var_req_builder
377 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
378 }
379 if let Some(local_var_param_value) = idempotency_key {
380 local_var_req_builder =
381 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
382 }
383 local_var_req_builder = local_var_req_builder.json(&collection_deploy_request_dto);
384
385 let local_var_req = local_var_req_builder.build()?;
386 let local_var_resp = local_var_client.execute(local_var_req).await?;
387
388 let local_var_status = local_var_resp.status();
389 let local_var_content_type = local_var_resp
390 .headers()
391 .get("content-type")
392 .and_then(|v| v.to_str().ok())
393 .unwrap_or("application/octet-stream");
394 let local_var_content_type = super::ContentType::from(local_var_content_type);
395 let local_var_content = local_var_resp.text().await?;
396
397 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
398 match local_var_content_type {
399 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
400 ContentType::Text => {
401 return Err(Error::from(serde_json::Error::custom(
402 "Received `text/plain` content type response that cannot be converted to \
403 `models::CollectionLinkDto`",
404 )))
405 }
406 ContentType::Unsupported(local_var_unknown_type) => {
407 return Err(Error::from(serde_json::Error::custom(format!(
408 "Received `{local_var_unknown_type}` content type response that cannot be \
409 converted to `models::CollectionLinkDto`"
410 ))))
411 }
412 }
413 } else {
414 let local_var_entity: Option<CreateNewCollectionError> =
415 serde_json::from_str(&local_var_content).ok();
416 let local_var_error = ResponseContent {
417 status: local_var_status,
418 content: local_var_content,
419 entity: local_var_entity,
420 };
421 Err(Error::ResponseError(local_var_error))
422 }
423 }
424
425 async fn fetch_collection_token_details(
428 &self,
429 params: FetchCollectionTokenDetailsParams,
430 ) -> Result<models::CollectionLinkDto, Error<FetchCollectionTokenDetailsError>> {
431 let FetchCollectionTokenDetailsParams { id, token_id } = params;
432
433 let local_var_configuration = &self.configuration;
434
435 let local_var_client = &local_var_configuration.client;
436
437 let local_var_uri_str = format!(
438 "{}/tokenization/collections/{id}/tokens/{tokenId}",
439 local_var_configuration.base_path,
440 id = crate::apis::urlencode(id),
441 tokenId = crate::apis::urlencode(token_id)
442 );
443 let mut local_var_req_builder =
444 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
445
446 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
447 local_var_req_builder = local_var_req_builder
448 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
449 }
450
451 let local_var_req = local_var_req_builder.build()?;
452 let local_var_resp = local_var_client.execute(local_var_req).await?;
453
454 let local_var_status = local_var_resp.status();
455 let local_var_content_type = local_var_resp
456 .headers()
457 .get("content-type")
458 .and_then(|v| v.to_str().ok())
459 .unwrap_or("application/octet-stream");
460 let local_var_content_type = super::ContentType::from(local_var_content_type);
461 let local_var_content = local_var_resp.text().await?;
462
463 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
464 match local_var_content_type {
465 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
466 ContentType::Text => {
467 return Err(Error::from(serde_json::Error::custom(
468 "Received `text/plain` content type response that cannot be converted to \
469 `models::CollectionLinkDto`",
470 )))
471 }
472 ContentType::Unsupported(local_var_unknown_type) => {
473 return Err(Error::from(serde_json::Error::custom(format!(
474 "Received `{local_var_unknown_type}` content type response that cannot be \
475 converted to `models::CollectionLinkDto`"
476 ))))
477 }
478 }
479 } else {
480 let local_var_entity: Option<FetchCollectionTokenDetailsError> =
481 serde_json::from_str(&local_var_content).ok();
482 let local_var_error = ResponseContent {
483 status: local_var_status,
484 content: local_var_content,
485 entity: local_var_entity,
486 };
487 Err(Error::ResponseError(local_var_error))
488 }
489 }
490
491 async fn get_collection_by_id(
494 &self,
495 params: GetCollectionByIdParams,
496 ) -> Result<models::CollectionLinkDto, Error<GetCollectionByIdError>> {
497 let GetCollectionByIdParams { id } = params;
498
499 let local_var_configuration = &self.configuration;
500
501 let local_var_client = &local_var_configuration.client;
502
503 let local_var_uri_str = format!(
504 "{}/tokenization/collections/{id}",
505 local_var_configuration.base_path,
506 id = crate::apis::urlencode(id)
507 );
508 let mut local_var_req_builder =
509 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
510
511 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
512 local_var_req_builder = local_var_req_builder
513 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
514 }
515
516 let local_var_req = local_var_req_builder.build()?;
517 let local_var_resp = local_var_client.execute(local_var_req).await?;
518
519 let local_var_status = local_var_resp.status();
520 let local_var_content_type = local_var_resp
521 .headers()
522 .get("content-type")
523 .and_then(|v| v.to_str().ok())
524 .unwrap_or("application/octet-stream");
525 let local_var_content_type = super::ContentType::from(local_var_content_type);
526 let local_var_content = local_var_resp.text().await?;
527
528 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
529 match local_var_content_type {
530 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
531 ContentType::Text => {
532 return Err(Error::from(serde_json::Error::custom(
533 "Received `text/plain` content type response that cannot be converted to \
534 `models::CollectionLinkDto`",
535 )))
536 }
537 ContentType::Unsupported(local_var_unknown_type) => {
538 return Err(Error::from(serde_json::Error::custom(format!(
539 "Received `{local_var_unknown_type}` content type response that cannot be \
540 converted to `models::CollectionLinkDto`"
541 ))))
542 }
543 }
544 } else {
545 let local_var_entity: Option<GetCollectionByIdError> =
546 serde_json::from_str(&local_var_content).ok();
547 let local_var_error = ResponseContent {
548 status: local_var_status,
549 content: local_var_content,
550 entity: local_var_entity,
551 };
552 Err(Error::ResponseError(local_var_error))
553 }
554 }
555
556 async fn get_linked_collections(
559 &self,
560 params: GetLinkedCollectionsParams,
561 ) -> Result<models::GetLinkedCollectionsPaginatedResponse, Error<GetLinkedCollectionsError>>
562 {
563 let GetLinkedCollectionsParams {
564 page_cursor,
565 page_size,
566 status,
567 } = params;
568
569 let local_var_configuration = &self.configuration;
570
571 let local_var_client = &local_var_configuration.client;
572
573 let local_var_uri_str = format!(
574 "{}/tokenization/collections",
575 local_var_configuration.base_path
576 );
577 let mut local_var_req_builder =
578 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
579
580 if let Some(ref local_var_str) = page_cursor {
581 local_var_req_builder =
582 local_var_req_builder.query(&[("pageCursor", &local_var_str.to_string())]);
583 }
584 if let Some(ref local_var_str) = page_size {
585 local_var_req_builder =
586 local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
587 }
588 if let Some(ref local_var_str) = status {
589 local_var_req_builder =
590 local_var_req_builder.query(&[("status", &local_var_str.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 => serde_json::from_str(&local_var_content).map_err(Error::from),
612 ContentType::Text => {
613 return Err(Error::from(serde_json::Error::custom(
614 "Received `text/plain` content type response that cannot be converted to \
615 `models::GetLinkedCollectionsPaginatedResponse`",
616 )))
617 }
618 ContentType::Unsupported(local_var_unknown_type) => {
619 return Err(Error::from(serde_json::Error::custom(format!(
620 "Received `{local_var_unknown_type}` content type response that cannot be \
621 converted to `models::GetLinkedCollectionsPaginatedResponse`"
622 ))))
623 }
624 }
625 } else {
626 let local_var_entity: Option<GetLinkedCollectionsError> =
627 serde_json::from_str(&local_var_content).ok();
628 let local_var_error = ResponseContent {
629 status: local_var_status,
630 content: local_var_content,
631 entity: local_var_entity,
632 };
633 Err(Error::ResponseError(local_var_error))
634 }
635 }
636
637 async fn get_linked_token(
640 &self,
641 params: GetLinkedTokenParams,
642 ) -> Result<models::TokenLinkDto, Error<GetLinkedTokenError>> {
643 let GetLinkedTokenParams { id } = params;
644
645 let local_var_configuration = &self.configuration;
646
647 let local_var_client = &local_var_configuration.client;
648
649 let local_var_uri_str = format!(
650 "{}/tokenization/tokens/{id}",
651 local_var_configuration.base_path,
652 id = crate::apis::urlencode(id)
653 );
654 let mut local_var_req_builder =
655 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
656
657 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
658 local_var_req_builder = local_var_req_builder
659 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
660 }
661
662 let local_var_req = local_var_req_builder.build()?;
663 let local_var_resp = local_var_client.execute(local_var_req).await?;
664
665 let local_var_status = local_var_resp.status();
666 let local_var_content_type = local_var_resp
667 .headers()
668 .get("content-type")
669 .and_then(|v| v.to_str().ok())
670 .unwrap_or("application/octet-stream");
671 let local_var_content_type = super::ContentType::from(local_var_content_type);
672 let local_var_content = local_var_resp.text().await?;
673
674 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
675 match local_var_content_type {
676 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
677 ContentType::Text => {
678 return Err(Error::from(serde_json::Error::custom(
679 "Received `text/plain` content type response that cannot be converted to \
680 `models::TokenLinkDto`",
681 )))
682 }
683 ContentType::Unsupported(local_var_unknown_type) => {
684 return Err(Error::from(serde_json::Error::custom(format!(
685 "Received `{local_var_unknown_type}` content type response that cannot be \
686 converted to `models::TokenLinkDto`"
687 ))))
688 }
689 }
690 } else {
691 let local_var_entity: Option<GetLinkedTokenError> =
692 serde_json::from_str(&local_var_content).ok();
693 let local_var_error = ResponseContent {
694 status: local_var_status,
695 content: local_var_content,
696 entity: local_var_entity,
697 };
698 Err(Error::ResponseError(local_var_error))
699 }
700 }
701
702 async fn get_linked_tokens(
705 &self,
706 params: GetLinkedTokensParams,
707 ) -> Result<models::TokensPaginatedResponse, Error<GetLinkedTokensError>> {
708 let GetLinkedTokensParams {
709 page_cursor,
710 page_size,
711 status,
712 } = params;
713
714 let local_var_configuration = &self.configuration;
715
716 let local_var_client = &local_var_configuration.client;
717
718 let local_var_uri_str =
719 format!("{}/tokenization/tokens", local_var_configuration.base_path);
720 let mut local_var_req_builder =
721 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
722
723 if let Some(ref local_var_str) = page_cursor {
724 local_var_req_builder =
725 local_var_req_builder.query(&[("pageCursor", &local_var_str.to_string())]);
726 }
727 if let Some(ref local_var_str) = page_size {
728 local_var_req_builder =
729 local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
730 }
731 if let Some(ref local_var_str) = status {
732 local_var_req_builder =
733 local_var_req_builder.query(&[("status", &local_var_str.to_string())]);
734 }
735 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
736 local_var_req_builder = local_var_req_builder
737 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
738 }
739
740 let local_var_req = local_var_req_builder.build()?;
741 let local_var_resp = local_var_client.execute(local_var_req).await?;
742
743 let local_var_status = local_var_resp.status();
744 let local_var_content_type = local_var_resp
745 .headers()
746 .get("content-type")
747 .and_then(|v| v.to_str().ok())
748 .unwrap_or("application/octet-stream");
749 let local_var_content_type = super::ContentType::from(local_var_content_type);
750 let local_var_content = local_var_resp.text().await?;
751
752 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
753 match local_var_content_type {
754 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
755 ContentType::Text => {
756 return Err(Error::from(serde_json::Error::custom(
757 "Received `text/plain` content type response that cannot be converted to \
758 `models::TokensPaginatedResponse`",
759 )))
760 }
761 ContentType::Unsupported(local_var_unknown_type) => {
762 return Err(Error::from(serde_json::Error::custom(format!(
763 "Received `{local_var_unknown_type}` content type response that cannot be \
764 converted to `models::TokensPaginatedResponse`"
765 ))))
766 }
767 }
768 } else {
769 let local_var_entity: Option<GetLinkedTokensError> =
770 serde_json::from_str(&local_var_content).ok();
771 let local_var_error = ResponseContent {
772 status: local_var_status,
773 content: local_var_content,
774 entity: local_var_entity,
775 };
776 Err(Error::ResponseError(local_var_error))
777 }
778 }
779
780 async fn issue_new_token(
789 &self,
790 params: IssueNewTokenParams,
791 ) -> Result<models::TokenLinkDto, Error<IssueNewTokenError>> {
792 let IssueNewTokenParams {
793 create_token_request_dto,
794 idempotency_key,
795 } = params;
796
797 let local_var_configuration = &self.configuration;
798
799 let local_var_client = &local_var_configuration.client;
800
801 let local_var_uri_str =
802 format!("{}/tokenization/tokens", local_var_configuration.base_path);
803 let mut local_var_req_builder =
804 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
805
806 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
807 local_var_req_builder = local_var_req_builder
808 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
809 }
810 if let Some(local_var_param_value) = idempotency_key {
811 local_var_req_builder =
812 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
813 }
814 local_var_req_builder = local_var_req_builder.json(&create_token_request_dto);
815
816 let local_var_req = local_var_req_builder.build()?;
817 let local_var_resp = local_var_client.execute(local_var_req).await?;
818
819 let local_var_status = local_var_resp.status();
820 let local_var_content_type = local_var_resp
821 .headers()
822 .get("content-type")
823 .and_then(|v| v.to_str().ok())
824 .unwrap_or("application/octet-stream");
825 let local_var_content_type = super::ContentType::from(local_var_content_type);
826 let local_var_content = local_var_resp.text().await?;
827
828 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
829 match local_var_content_type {
830 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
831 ContentType::Text => {
832 return Err(Error::from(serde_json::Error::custom(
833 "Received `text/plain` content type response that cannot be converted to \
834 `models::TokenLinkDto`",
835 )))
836 }
837 ContentType::Unsupported(local_var_unknown_type) => {
838 return Err(Error::from(serde_json::Error::custom(format!(
839 "Received `{local_var_unknown_type}` content type response that cannot be \
840 converted to `models::TokenLinkDto`"
841 ))))
842 }
843 }
844 } else {
845 let local_var_entity: Option<IssueNewTokenError> =
846 serde_json::from_str(&local_var_content).ok();
847 let local_var_error = ResponseContent {
848 status: local_var_status,
849 content: local_var_content,
850 entity: local_var_entity,
851 };
852 Err(Error::ResponseError(local_var_error))
853 }
854 }
855
856 async fn link(&self, params: LinkParams) -> Result<models::TokenLinkDto, Error<LinkError>> {
859 let LinkParams {
860 token_link_request_dto,
861 idempotency_key,
862 } = params;
863
864 let local_var_configuration = &self.configuration;
865
866 let local_var_client = &local_var_configuration.client;
867
868 let local_var_uri_str = format!(
869 "{}/tokenization/tokens/link",
870 local_var_configuration.base_path
871 );
872 let mut local_var_req_builder =
873 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
874
875 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
876 local_var_req_builder = local_var_req_builder
877 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
878 }
879 if let Some(local_var_param_value) = idempotency_key {
880 local_var_req_builder =
881 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
882 }
883 local_var_req_builder = local_var_req_builder.json(&token_link_request_dto);
884
885 let local_var_req = local_var_req_builder.build()?;
886 let local_var_resp = local_var_client.execute(local_var_req).await?;
887
888 let local_var_status = local_var_resp.status();
889 let local_var_content_type = local_var_resp
890 .headers()
891 .get("content-type")
892 .and_then(|v| v.to_str().ok())
893 .unwrap_or("application/octet-stream");
894 let local_var_content_type = super::ContentType::from(local_var_content_type);
895 let local_var_content = local_var_resp.text().await?;
896
897 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
898 match local_var_content_type {
899 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
900 ContentType::Text => {
901 return Err(Error::from(serde_json::Error::custom(
902 "Received `text/plain` content type response that cannot be converted to \
903 `models::TokenLinkDto`",
904 )))
905 }
906 ContentType::Unsupported(local_var_unknown_type) => {
907 return Err(Error::from(serde_json::Error::custom(format!(
908 "Received `{local_var_unknown_type}` content type response that cannot be \
909 converted to `models::TokenLinkDto`"
910 ))))
911 }
912 }
913 } else {
914 let local_var_entity: Option<LinkError> = serde_json::from_str(&local_var_content).ok();
915 let local_var_error = ResponseContent {
916 status: local_var_status,
917 content: local_var_content,
918 entity: local_var_entity,
919 };
920 Err(Error::ResponseError(local_var_error))
921 }
922 }
923
924 async fn mint_collection_token(
927 &self,
928 params: MintCollectionTokenParams,
929 ) -> Result<models::CollectionMintResponseDto, Error<MintCollectionTokenError>> {
930 let MintCollectionTokenParams {
931 id,
932 collection_mint_request_dto,
933 idempotency_key,
934 } = params;
935
936 let local_var_configuration = &self.configuration;
937
938 let local_var_client = &local_var_configuration.client;
939
940 let local_var_uri_str = format!(
941 "{}/tokenization/collections/{id}/tokens/mint",
942 local_var_configuration.base_path,
943 id = crate::apis::urlencode(id)
944 );
945 let mut local_var_req_builder =
946 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
947
948 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
949 local_var_req_builder = local_var_req_builder
950 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
951 }
952 if let Some(local_var_param_value) = idempotency_key {
953 local_var_req_builder =
954 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
955 }
956 local_var_req_builder = local_var_req_builder.json(&collection_mint_request_dto);
957
958 let local_var_req = local_var_req_builder.build()?;
959 let local_var_resp = local_var_client.execute(local_var_req).await?;
960
961 let local_var_status = local_var_resp.status();
962 let local_var_content_type = local_var_resp
963 .headers()
964 .get("content-type")
965 .and_then(|v| v.to_str().ok())
966 .unwrap_or("application/octet-stream");
967 let local_var_content_type = super::ContentType::from(local_var_content_type);
968 let local_var_content = local_var_resp.text().await?;
969
970 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
971 match local_var_content_type {
972 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
973 ContentType::Text => {
974 return Err(Error::from(serde_json::Error::custom(
975 "Received `text/plain` content type response that cannot be converted to \
976 `models::CollectionMintResponseDto`",
977 )))
978 }
979 ContentType::Unsupported(local_var_unknown_type) => {
980 return Err(Error::from(serde_json::Error::custom(format!(
981 "Received `{local_var_unknown_type}` content type response that cannot be \
982 converted to `models::CollectionMintResponseDto`"
983 ))))
984 }
985 }
986 } else {
987 let local_var_entity: Option<MintCollectionTokenError> =
988 serde_json::from_str(&local_var_content).ok();
989 let local_var_error = ResponseContent {
990 status: local_var_status,
991 content: local_var_content,
992 entity: local_var_entity,
993 };
994 Err(Error::ResponseError(local_var_error))
995 }
996 }
997
998 async fn unlink(&self, params: UnlinkParams) -> Result<(), Error<UnlinkError>> {
1003 let UnlinkParams { id } = params;
1004
1005 let local_var_configuration = &self.configuration;
1006
1007 let local_var_client = &local_var_configuration.client;
1008
1009 let local_var_uri_str = format!(
1010 "{}/tokenization/tokens/{id}",
1011 local_var_configuration.base_path,
1012 id = crate::apis::urlencode(id)
1013 );
1014 let mut local_var_req_builder =
1015 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
1016
1017 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1018 local_var_req_builder = local_var_req_builder
1019 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1020 }
1021
1022 let local_var_req = local_var_req_builder.build()?;
1023 let local_var_resp = local_var_client.execute(local_var_req).await?;
1024
1025 let local_var_status = local_var_resp.status();
1026 let local_var_content = local_var_resp.text().await?;
1027
1028 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1029 Ok(())
1030 } else {
1031 let local_var_entity: Option<UnlinkError> =
1032 serde_json::from_str(&local_var_content).ok();
1033 let local_var_error = ResponseContent {
1034 status: local_var_status,
1035 content: local_var_content,
1036 entity: local_var_entity,
1037 };
1038 Err(Error::ResponseError(local_var_error))
1039 }
1040 }
1041
1042 async fn unlink_collection(
1045 &self,
1046 params: UnlinkCollectionParams,
1047 ) -> Result<(), Error<UnlinkCollectionError>> {
1048 let UnlinkCollectionParams { id } = params;
1049
1050 let local_var_configuration = &self.configuration;
1051
1052 let local_var_client = &local_var_configuration.client;
1053
1054 let local_var_uri_str = format!(
1055 "{}/tokenization/collections/{id}",
1056 local_var_configuration.base_path,
1057 id = crate::apis::urlencode(id)
1058 );
1059 let mut local_var_req_builder =
1060 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
1061
1062 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1063 local_var_req_builder = local_var_req_builder
1064 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1065 }
1066
1067 let local_var_req = local_var_req_builder.build()?;
1068 let local_var_resp = local_var_client.execute(local_var_req).await?;
1069
1070 let local_var_status = local_var_resp.status();
1071 let local_var_content = local_var_resp.text().await?;
1072
1073 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1074 Ok(())
1075 } else {
1076 let local_var_entity: Option<UnlinkCollectionError> =
1077 serde_json::from_str(&local_var_content).ok();
1078 let local_var_error = ResponseContent {
1079 status: local_var_status,
1080 content: local_var_content,
1081 entity: local_var_entity,
1082 };
1083 Err(Error::ResponseError(local_var_error))
1084 }
1085 }
1086}
1087
1088#[derive(Debug, Clone, Serialize, Deserialize)]
1090#[serde(untagged)]
1091pub enum BurnCollectionTokenError {
1092 DefaultResponse(models::ErrorSchema),
1093 UnknownValue(serde_json::Value),
1094}
1095
1096#[derive(Debug, Clone, Serialize, Deserialize)]
1098#[serde(untagged)]
1099pub enum CreateNewCollectionError {
1100 DefaultResponse(models::ErrorSchema),
1101 UnknownValue(serde_json::Value),
1102}
1103
1104#[derive(Debug, Clone, Serialize, Deserialize)]
1106#[serde(untagged)]
1107pub enum FetchCollectionTokenDetailsError {
1108 DefaultResponse(models::ErrorSchema),
1109 UnknownValue(serde_json::Value),
1110}
1111
1112#[derive(Debug, Clone, Serialize, Deserialize)]
1114#[serde(untagged)]
1115pub enum GetCollectionByIdError {
1116 DefaultResponse(models::ErrorSchema),
1117 UnknownValue(serde_json::Value),
1118}
1119
1120#[derive(Debug, Clone, Serialize, Deserialize)]
1122#[serde(untagged)]
1123pub enum GetLinkedCollectionsError {
1124 DefaultResponse(models::ErrorSchema),
1125 UnknownValue(serde_json::Value),
1126}
1127
1128#[derive(Debug, Clone, Serialize, Deserialize)]
1130#[serde(untagged)]
1131pub enum GetLinkedTokenError {
1132 DefaultResponse(models::ErrorSchema),
1133 UnknownValue(serde_json::Value),
1134}
1135
1136#[derive(Debug, Clone, Serialize, Deserialize)]
1138#[serde(untagged)]
1139pub enum GetLinkedTokensError {
1140 DefaultResponse(models::ErrorSchema),
1141 UnknownValue(serde_json::Value),
1142}
1143
1144#[derive(Debug, Clone, Serialize, Deserialize)]
1146#[serde(untagged)]
1147pub enum IssueNewTokenError {
1148 Status409(models::AssetAlreadyExistHttpError),
1149 UnknownValue(serde_json::Value),
1150}
1151
1152#[derive(Debug, Clone, Serialize, Deserialize)]
1154#[serde(untagged)]
1155pub enum LinkError {
1156 Status404(),
1157 Status409(models::TokenLinkExistsHttpError),
1158 DefaultResponse(models::ErrorSchema),
1159 UnknownValue(serde_json::Value),
1160}
1161
1162#[derive(Debug, Clone, Serialize, Deserialize)]
1164#[serde(untagged)]
1165pub enum MintCollectionTokenError {
1166 DefaultResponse(models::ErrorSchema),
1167 UnknownValue(serde_json::Value),
1168}
1169
1170#[derive(Debug, Clone, Serialize, Deserialize)]
1172#[serde(untagged)]
1173pub enum UnlinkError {
1174 Status404(models::NotFoundException),
1175 DefaultResponse(models::ErrorSchema),
1176 UnknownValue(serde_json::Value),
1177}
1178
1179#[derive(Debug, Clone, Serialize, Deserialize)]
1181#[serde(untagged)]
1182pub enum UnlinkCollectionError {
1183 Status404(),
1184 DefaultResponse(models::ErrorSchema),
1185 UnknownValue(serde_json::Value),
1186}