1use {
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 async fn get_nft(
28 &self,
29 params: GetNftParams,
30 ) -> Result<models::TokenResponse, Error<GetNftError>>;
31
32 async fn get_nfts(
37 &self,
38 params: GetNftsParams,
39 ) -> Result<models::GetNftsResponse, Error<GetNftsError>>;
40
41 async fn get_ownership_tokens(
46 &self,
47 params: GetOwnershipTokensParams,
48 ) -> Result<models::GetOwnershipTokensResponse, Error<GetOwnershipTokensError>>;
49
50 async fn list_owned_collections(
55 &self,
56 params: ListOwnedCollectionsParams,
57 ) -> Result<models::ListOwnedCollectionsResponse, Error<ListOwnedCollectionsError>>;
58
59 async fn list_owned_tokens(
65 &self,
66 params: ListOwnedTokensParams,
67 ) -> Result<models::ListOwnedTokensResponse, Error<ListOwnedTokensError>>;
68
69 async fn refresh_nft_metadata(
73 &self,
74 params: RefreshNftMetadataParams,
75 ) -> Result<(), Error<RefreshNftMetadataError>>;
76
77 async fn update_ownership_tokens(
81 &self,
82 params: UpdateOwnershipTokensParams,
83 ) -> Result<(), Error<UpdateOwnershipTokensError>>;
84
85 async fn update_token_ownership_status(
91 &self,
92 params: UpdateTokenOwnershipStatusParams,
93 ) -> Result<(), Error<UpdateTokenOwnershipStatusError>>;
94
95 async fn update_tokens_ownership_spam(
101 &self,
102 params: UpdateTokensOwnershipSpamParams,
103 ) -> Result<(), Error<UpdateTokensOwnershipSpamError>>;
104
105 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#[derive(Clone, Debug)]
128#[cfg_attr(feature = "bon", derive(::bon::Builder))]
129pub struct GetNftParams {
130 pub id: String,
132}
133
134#[derive(Clone, Debug)]
136#[cfg_attr(feature = "bon", derive(::bon::Builder))]
137pub struct GetNftsParams {
138 pub ids: String,
141 pub page_cursor: Option<String>,
143 pub page_size: Option<f64>,
145 pub sort: Option<Vec<String>>,
148 pub order: Option<String>,
150}
151
152#[derive(Clone, Debug)]
155#[cfg_attr(feature = "bon", derive(::bon::Builder))]
156pub struct GetOwnershipTokensParams {
157 pub blockchain_descriptor: Option<String>,
159 pub vault_account_ids: Option<String>,
163 pub ncw_id: Option<String>,
165 pub ncw_account_ids: Option<String>,
169 pub wallet_type: Option<String>,
171 pub ids: Option<String>,
174 pub collection_ids: Option<String>,
177 pub page_cursor: Option<String>,
179 pub page_size: Option<f64>,
181 pub sort: Option<Vec<String>>,
184 pub order: Option<String>,
186 pub status: Option<String>,
188 pub search: Option<String>,
192 pub spam: Option<String>,
194}
195
196#[derive(Clone, Debug)]
199#[cfg_attr(feature = "bon", derive(::bon::Builder))]
200pub struct ListOwnedCollectionsParams {
201 pub ncw_id: Option<String>,
203 pub wallet_type: Option<String>,
205 pub search: Option<String>,
208 pub page_cursor: Option<String>,
210 pub page_size: Option<f64>,
212 pub sort: Option<Vec<String>>,
215 pub order: Option<String>,
217 pub status: Option<String>,
219}
220
221#[derive(Clone, Debug)]
223#[cfg_attr(feature = "bon", derive(::bon::Builder))]
224pub struct ListOwnedTokensParams {
225 pub ncw_id: Option<String>,
227 pub wallet_type: Option<String>,
229 pub page_cursor: Option<String>,
231 pub page_size: Option<f64>,
233 pub sort: Option<Vec<String>>,
236 pub order: Option<String>,
238 pub status: Option<String>,
240 pub search: Option<String>,
242 pub spam: Option<String>,
244}
245
246#[derive(Clone, Debug)]
249#[cfg_attr(feature = "bon", derive(::bon::Builder))]
250pub struct RefreshNftMetadataParams {
251 pub id: String,
253 pub idempotency_key: Option<String>,
258}
259
260#[derive(Clone, Debug)]
263#[cfg_attr(feature = "bon", derive(::bon::Builder))]
264pub struct UpdateOwnershipTokensParams {
265 pub blockchain_descriptor: String,
267 pub vault_account_id: String,
269 pub idempotency_key: Option<String>,
274}
275
276#[derive(Clone, Debug)]
279#[cfg_attr(feature = "bon", derive(::bon::Builder))]
280pub struct UpdateTokenOwnershipStatusParams {
281 pub id: String,
283 pub update_token_ownership_status_dto: models::UpdateTokenOwnershipStatusDto,
284 pub idempotency_key: Option<String>,
289}
290
291#[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 pub idempotency_key: Option<String>,
302}
303
304#[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 pub idempotency_key: Option<String>,
315}
316
317#[async_trait]
318impl NftsApi for NftsApiClient {
319 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 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", ¶m_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", ¶m_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 ¶m_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 ¶m_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", ¶m_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 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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_value.to_string())]);
540 }
541 if let Some(ref param_value) = ids {
542 local_var_req_builder =
543 local_var_req_builder.query(&[("ids", ¶m_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", ¶m_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", ¶m_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", ¶m_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 ¶m_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 ¶m_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", ¶m_value.to_string())]);
579 }
580 if let Some(ref param_value) = status {
581 local_var_req_builder =
582 local_var_req_builder.query(&[("status", ¶m_value.to_string())]);
583 }
584 if let Some(ref param_value) = search {
585 local_var_req_builder =
586 local_var_req_builder.query(&[("search", ¶m_value.to_string())]);
587 }
588 if let Some(ref param_value) = spam {
589 local_var_req_builder =
590 local_var_req_builder.query(&[("spam", ¶m_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 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", ¶m_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", ¶m_value.to_string())]);
674 }
675 if let Some(ref param_value) = search {
676 local_var_req_builder =
677 local_var_req_builder.query(&[("search", ¶m_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", ¶m_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", ¶m_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 ¶m_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 ¶m_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", ¶m_value.to_string())]);
709 }
710 if let Some(ref param_value) = status {
711 local_var_req_builder =
712 local_var_req_builder.query(&[("status", ¶m_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 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", ¶m_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", ¶m_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", ¶m_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", ¶m_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 ¶m_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 ¶m_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", ¶m_value.to_string())]);
829 }
830 if let Some(ref param_value) = status {
831 local_var_req_builder =
832 local_var_req_builder.query(&[("status", ¶m_value.to_string())]);
833 }
834 if let Some(ref param_value) = search {
835 local_var_req_builder =
836 local_var_req_builder.query(&[("search", ¶m_value.to_string())]);
837 }
838 if let Some(ref param_value) = spam {
839 local_var_req_builder =
840 local_var_req_builder.query(&[("spam", ¶m_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 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 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 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 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 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#[derive(Debug, Clone, Serialize, Deserialize)]
1159#[serde(untagged)]
1160pub enum GetNftError {
1161 UnknownValue(serde_json::Value),
1162}
1163
1164#[derive(Debug, Clone, Serialize, Deserialize)]
1166#[serde(untagged)]
1167pub enum GetNftsError {
1168 UnknownValue(serde_json::Value),
1169}
1170
1171#[derive(Debug, Clone, Serialize, Deserialize)]
1173#[serde(untagged)]
1174pub enum GetOwnershipTokensError {
1175 UnknownValue(serde_json::Value),
1176}
1177
1178#[derive(Debug, Clone, Serialize, Deserialize)]
1180#[serde(untagged)]
1181pub enum ListOwnedCollectionsError {
1182 UnknownValue(serde_json::Value),
1183}
1184
1185#[derive(Debug, Clone, Serialize, Deserialize)]
1187#[serde(untagged)]
1188pub enum ListOwnedTokensError {
1189 UnknownValue(serde_json::Value),
1190}
1191
1192#[derive(Debug, Clone, Serialize, Deserialize)]
1194#[serde(untagged)]
1195pub enum RefreshNftMetadataError {
1196 UnknownValue(serde_json::Value),
1197}
1198
1199#[derive(Debug, Clone, Serialize, Deserialize)]
1201#[serde(untagged)]
1202pub enum UpdateOwnershipTokensError {
1203 UnknownValue(serde_json::Value),
1204}
1205
1206#[derive(Debug, Clone, Serialize, Deserialize)]
1208#[serde(untagged)]
1209pub enum UpdateTokenOwnershipStatusError {
1210 UnknownValue(serde_json::Value),
1211}
1212
1213#[derive(Debug, Clone, Serialize, Deserialize)]
1215#[serde(untagged)]
1216pub enum UpdateTokensOwnershipSpamError {
1217 Status400(),
1218 Status404(),
1219 UnknownValue(serde_json::Value),
1220}
1221
1222#[derive(Debug, Clone, Serialize, Deserialize)]
1225#[serde(untagged)]
1226pub enum UpdateTokensOwnershipStatusError {
1227 Status400(),
1228 Status404(),
1229 UnknownValue(serde_json::Value),
1230}