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 TransactionsApi: Send + Sync {
23 async fn cancel_transaction(
30 &self,
31 params: CancelTransactionParams,
32 ) -> Result<models::CancelTransactionResponse, Error<CancelTransactionError>>;
33
34 async fn create_transaction(
38 &self,
39 params: CreateTransactionParams,
40 ) -> Result<models::CreateTransactionResponse, Error<CreateTransactionError>>;
41
42 async fn drop_transaction(
48 &self,
49 params: DropTransactionParams,
50 ) -> Result<models::DropTransactionResponse, Error<DropTransactionError>>;
51
52 async fn estimate_transaction_fee(
56 &self,
57 params: EstimateTransactionFeeParams,
58 ) -> Result<models::EstimatedTransactionFeeResponse, Error<EstimateTransactionFeeError>>;
59
60 async fn freeze_transaction(
68 &self,
69 params: FreezeTransactionParams,
70 ) -> Result<models::FreezeTransactionResponse, Error<FreezeTransactionError>>;
71
72 async fn get_transaction(
78 &self,
79 params: GetTransactionParams,
80 ) -> Result<models::TransactionResponse, Error<GetTransactionError>>;
81
82 async fn get_transaction_by_external_id(
87 &self,
88 params: GetTransactionByExternalIdParams,
89 ) -> Result<models::TransactionResponse, Error<GetTransactionByExternalIdError>>;
90
91 async fn get_transactions(
97 &self,
98 params: GetTransactionsParams,
99 ) -> Result<Vec<models::TransactionResponse>, Error<GetTransactionsError>>;
100
101 async fn set_confirmation_threshold_by_transaction_hash(
107 &self,
108 params: SetConfirmationThresholdByTransactionHashParams,
109 ) -> Result<
110 models::SetConfirmationsThresholdResponse,
111 Error<SetConfirmationThresholdByTransactionHashError>,
112 >;
113
114 async fn set_transaction_confirmation_threshold(
120 &self,
121 params: SetTransactionConfirmationThresholdParams,
122 ) -> Result<
123 models::SetConfirmationsThresholdResponse,
124 Error<SetTransactionConfirmationThresholdError>,
125 >;
126
127 async fn unfreeze_transaction(
133 &self,
134 params: UnfreezeTransactionParams,
135 ) -> Result<models::UnfreezeTransactionResponse, Error<UnfreezeTransactionError>>;
136}
137
138pub struct TransactionsApiClient {
139 configuration: Arc<configuration::Configuration>,
140}
141
142impl TransactionsApiClient {
143 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
144 Self { configuration }
145 }
146}
147
148#[derive(Clone, Debug)]
151#[cfg_attr(feature = "bon", derive(::bon::Builder))]
152pub struct CancelTransactionParams {
153 pub tx_id: String,
155 pub x_end_user_wallet_id: Option<String>,
158 pub idempotency_key: Option<String>,
163}
164
165#[derive(Clone, Debug)]
168#[cfg_attr(feature = "bon", derive(::bon::Builder))]
169pub struct CreateTransactionParams {
170 pub transaction_request: models::TransactionRequest,
171 pub x_end_user_wallet_id: Option<String>,
174 pub idempotency_key: Option<String>,
179}
180
181#[derive(Clone, Debug)]
184#[cfg_attr(feature = "bon", derive(::bon::Builder))]
185pub struct DropTransactionParams {
186 pub tx_id: String,
188 pub x_end_user_wallet_id: Option<String>,
191 pub idempotency_key: Option<String>,
196 pub drop_transaction_request: Option<models::DropTransactionRequest>,
197}
198
199#[derive(Clone, Debug)]
202#[cfg_attr(feature = "bon", derive(::bon::Builder))]
203pub struct EstimateTransactionFeeParams {
204 pub idempotency_key: Option<String>,
209 pub transaction_request: Option<models::TransactionRequest>,
210}
211
212#[derive(Clone, Debug)]
215#[cfg_attr(feature = "bon", derive(::bon::Builder))]
216pub struct FreezeTransactionParams {
217 pub tx_id: String,
219 pub x_end_user_wallet_id: Option<String>,
222 pub idempotency_key: Option<String>,
227}
228
229#[derive(Clone, Debug)]
232#[cfg_attr(feature = "bon", derive(::bon::Builder))]
233pub struct GetTransactionParams {
234 pub tx_id: String,
236}
237
238#[derive(Clone, Debug)]
241#[cfg_attr(feature = "bon", derive(::bon::Builder))]
242pub struct GetTransactionByExternalIdParams {
243 pub external_tx_id: String,
245}
246
247#[derive(Clone, Debug)]
250#[cfg_attr(feature = "bon", derive(::bon::Builder))]
251pub struct GetTransactionsParams {
252 pub before: Option<String>,
257 pub after: Option<String>,
262 pub status: Option<models::TransactionStatus>,
264 pub order_by: Option<String>,
269 pub sort: Option<String>,
271 pub limit: Option<u32>,
274 pub source_type: Option<String>,
276 pub source_id: Option<String>,
278 pub dest_type: Option<String>,
280 pub dest_id: Option<String>,
282 pub assets: Option<String>,
284 pub tx_hash: Option<String>,
286 pub source_wallet_id: Option<String>,
288 pub dest_wallet_id: Option<String>,
290}
291
292#[derive(Clone, Debug)]
295#[cfg_attr(feature = "bon", derive(::bon::Builder))]
296pub struct SetConfirmationThresholdByTransactionHashParams {
297 pub tx_hash: String,
299 pub idempotency_key: Option<String>,
304 pub set_confirmations_threshold_request: Option<models::SetConfirmationsThresholdRequest>,
305}
306
307#[derive(Clone, Debug)]
310#[cfg_attr(feature = "bon", derive(::bon::Builder))]
311pub struct SetTransactionConfirmationThresholdParams {
312 pub tx_id: String,
314 pub idempotency_key: Option<String>,
319 pub set_confirmations_threshold_request: Option<models::SetConfirmationsThresholdRequest>,
320}
321
322#[derive(Clone, Debug)]
325#[cfg_attr(feature = "bon", derive(::bon::Builder))]
326pub struct UnfreezeTransactionParams {
327 pub tx_id: String,
329 pub x_end_user_wallet_id: Option<String>,
332 pub idempotency_key: Option<String>,
337}
338
339#[async_trait]
340impl TransactionsApi for TransactionsApiClient {
341 async fn cancel_transaction(
346 &self,
347 params: CancelTransactionParams,
348 ) -> Result<models::CancelTransactionResponse, Error<CancelTransactionError>> {
349 let CancelTransactionParams {
350 tx_id,
351 x_end_user_wallet_id,
352 idempotency_key,
353 } = params;
354
355 let local_var_configuration = &self.configuration;
356
357 let local_var_client = &local_var_configuration.client;
358
359 let local_var_uri_str = format!(
360 "{}/transactions/{txId}/cancel",
361 local_var_configuration.base_path,
362 txId = crate::apis::urlencode(tx_id)
363 );
364 let mut local_var_req_builder =
365 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
366
367 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
368 local_var_req_builder = local_var_req_builder
369 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
370 }
371 if let Some(local_var_param_value) = x_end_user_wallet_id {
372 local_var_req_builder = local_var_req_builder
373 .header("X-End-User-Wallet-Id", local_var_param_value.to_string());
374 }
375 if let Some(local_var_param_value) = idempotency_key {
376 local_var_req_builder =
377 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
378 }
379
380 let local_var_req = local_var_req_builder.build()?;
381 let local_var_resp = local_var_client.execute(local_var_req).await?;
382
383 let local_var_status = local_var_resp.status();
384 let local_var_content_type = local_var_resp
385 .headers()
386 .get("content-type")
387 .and_then(|v| v.to_str().ok())
388 .unwrap_or("application/octet-stream");
389 let local_var_content_type = super::ContentType::from(local_var_content_type);
390 let local_var_content = local_var_resp.text().await?;
391
392 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
393 match local_var_content_type {
394 ContentType::Json => {
395 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
396 }
397 ContentType::Text => {
398 return Err(Error::from(serde_json::Error::custom(
399 "Received `text/plain` content type response that cannot be converted to \
400 `models::CancelTransactionResponse`",
401 )));
402 }
403 ContentType::Unsupported(local_var_unknown_type) => {
404 return Err(Error::from(serde_json::Error::custom(format!(
405 "Received `{local_var_unknown_type}` content type response that cannot be \
406 converted to `models::CancelTransactionResponse`"
407 ))));
408 }
409 }
410 } else {
411 let local_var_entity: Option<CancelTransactionError> =
412 serde_json::from_str(&local_var_content).ok();
413 let local_var_error = ResponseContent {
414 status: local_var_status,
415 content: local_var_content,
416 entity: local_var_entity,
417 };
418 Err(Error::ResponseError(local_var_error))
419 }
420 }
421
422 async fn create_transaction(
424 &self,
425 params: CreateTransactionParams,
426 ) -> Result<models::CreateTransactionResponse, Error<CreateTransactionError>> {
427 let CreateTransactionParams {
428 transaction_request,
429 x_end_user_wallet_id,
430 idempotency_key,
431 } = 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!("{}/transactions", local_var_configuration.base_path);
438 let mut local_var_req_builder =
439 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
440
441 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
442 local_var_req_builder = local_var_req_builder
443 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
444 }
445 if let Some(local_var_param_value) = x_end_user_wallet_id {
446 local_var_req_builder = local_var_req_builder
447 .header("X-End-User-Wallet-Id", local_var_param_value.to_string());
448 }
449 if let Some(local_var_param_value) = idempotency_key {
450 local_var_req_builder =
451 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
452 }
453 local_var_req_builder = local_var_req_builder.json(&transaction_request);
454
455 let local_var_req = local_var_req_builder.build()?;
456 let local_var_resp = local_var_client.execute(local_var_req).await?;
457
458 let local_var_status = local_var_resp.status();
459 let local_var_content_type = local_var_resp
460 .headers()
461 .get("content-type")
462 .and_then(|v| v.to_str().ok())
463 .unwrap_or("application/octet-stream");
464 let local_var_content_type = super::ContentType::from(local_var_content_type);
465 let local_var_content = local_var_resp.text().await?;
466
467 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
468 match local_var_content_type {
469 ContentType::Json => {
470 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
471 }
472 ContentType::Text => {
473 return Err(Error::from(serde_json::Error::custom(
474 "Received `text/plain` content type response that cannot be converted to \
475 `models::CreateTransactionResponse`",
476 )));
477 }
478 ContentType::Unsupported(local_var_unknown_type) => {
479 return Err(Error::from(serde_json::Error::custom(format!(
480 "Received `{local_var_unknown_type}` content type response that cannot be \
481 converted to `models::CreateTransactionResponse`"
482 ))));
483 }
484 }
485 } else {
486 let local_var_entity: Option<CreateTransactionError> =
487 serde_json::from_str(&local_var_content).ok();
488 let local_var_error = ResponseContent {
489 status: local_var_status,
490 content: local_var_content,
491 entity: local_var_entity,
492 };
493 Err(Error::ResponseError(local_var_error))
494 }
495 }
496
497 async fn drop_transaction(
501 &self,
502 params: DropTransactionParams,
503 ) -> Result<models::DropTransactionResponse, Error<DropTransactionError>> {
504 let DropTransactionParams {
505 tx_id,
506 x_end_user_wallet_id,
507 idempotency_key,
508 drop_transaction_request,
509 } = params;
510
511 let local_var_configuration = &self.configuration;
512
513 let local_var_client = &local_var_configuration.client;
514
515 let local_var_uri_str = format!(
516 "{}/transactions/{txId}/drop",
517 local_var_configuration.base_path,
518 txId = crate::apis::urlencode(tx_id)
519 );
520 let mut local_var_req_builder =
521 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
522
523 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
524 local_var_req_builder = local_var_req_builder
525 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
526 }
527 if let Some(local_var_param_value) = x_end_user_wallet_id {
528 local_var_req_builder = local_var_req_builder
529 .header("X-End-User-Wallet-Id", local_var_param_value.to_string());
530 }
531 if let Some(local_var_param_value) = idempotency_key {
532 local_var_req_builder =
533 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
534 }
535 local_var_req_builder = local_var_req_builder.json(&drop_transaction_request);
536
537 let local_var_req = local_var_req_builder.build()?;
538 let local_var_resp = local_var_client.execute(local_var_req).await?;
539
540 let local_var_status = local_var_resp.status();
541 let local_var_content_type = local_var_resp
542 .headers()
543 .get("content-type")
544 .and_then(|v| v.to_str().ok())
545 .unwrap_or("application/octet-stream");
546 let local_var_content_type = super::ContentType::from(local_var_content_type);
547 let local_var_content = local_var_resp.text().await?;
548
549 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
550 match local_var_content_type {
551 ContentType::Json => {
552 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
553 }
554 ContentType::Text => {
555 return Err(Error::from(serde_json::Error::custom(
556 "Received `text/plain` content type response that cannot be converted to \
557 `models::DropTransactionResponse`",
558 )));
559 }
560 ContentType::Unsupported(local_var_unknown_type) => {
561 return Err(Error::from(serde_json::Error::custom(format!(
562 "Received `{local_var_unknown_type}` content type response that cannot be \
563 converted to `models::DropTransactionResponse`"
564 ))));
565 }
566 }
567 } else {
568 let local_var_entity: Option<DropTransactionError> =
569 serde_json::from_str(&local_var_content).ok();
570 let local_var_error = ResponseContent {
571 status: local_var_status,
572 content: local_var_content,
573 entity: local_var_entity,
574 };
575 Err(Error::ResponseError(local_var_error))
576 }
577 }
578
579 async fn estimate_transaction_fee(
581 &self,
582 params: EstimateTransactionFeeParams,
583 ) -> Result<models::EstimatedTransactionFeeResponse, Error<EstimateTransactionFeeError>> {
584 let EstimateTransactionFeeParams {
585 idempotency_key,
586 transaction_request,
587 } = params;
588
589 let local_var_configuration = &self.configuration;
590
591 let local_var_client = &local_var_configuration.client;
592
593 let local_var_uri_str = format!(
594 "{}/transactions/estimate_fee",
595 local_var_configuration.base_path
596 );
597 let mut local_var_req_builder =
598 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
599
600 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
601 local_var_req_builder = local_var_req_builder
602 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
603 }
604 if let Some(local_var_param_value) = idempotency_key {
605 local_var_req_builder =
606 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
607 }
608 local_var_req_builder = local_var_req_builder.json(&transaction_request);
609
610 let local_var_req = local_var_req_builder.build()?;
611 let local_var_resp = local_var_client.execute(local_var_req).await?;
612
613 let local_var_status = local_var_resp.status();
614 let local_var_content_type = local_var_resp
615 .headers()
616 .get("content-type")
617 .and_then(|v| v.to_str().ok())
618 .unwrap_or("application/octet-stream");
619 let local_var_content_type = super::ContentType::from(local_var_content_type);
620 let local_var_content = local_var_resp.text().await?;
621
622 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
623 match local_var_content_type {
624 ContentType::Json => {
625 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
626 }
627 ContentType::Text => {
628 return Err(Error::from(serde_json::Error::custom(
629 "Received `text/plain` content type response that cannot be converted to \
630 `models::EstimatedTransactionFeeResponse`",
631 )));
632 }
633 ContentType::Unsupported(local_var_unknown_type) => {
634 return Err(Error::from(serde_json::Error::custom(format!(
635 "Received `{local_var_unknown_type}` content type response that cannot be \
636 converted to `models::EstimatedTransactionFeeResponse`"
637 ))));
638 }
639 }
640 } else {
641 let local_var_entity: Option<EstimateTransactionFeeError> =
642 serde_json::from_str(&local_var_content).ok();
643 let local_var_error = ResponseContent {
644 status: local_var_status,
645 content: local_var_content,
646 entity: local_var_entity,
647 };
648 Err(Error::ResponseError(local_var_error))
649 }
650 }
651
652 async fn freeze_transaction(
658 &self,
659 params: FreezeTransactionParams,
660 ) -> Result<models::FreezeTransactionResponse, Error<FreezeTransactionError>> {
661 let FreezeTransactionParams {
662 tx_id,
663 x_end_user_wallet_id,
664 idempotency_key,
665 } = params;
666
667 let local_var_configuration = &self.configuration;
668
669 let local_var_client = &local_var_configuration.client;
670
671 let local_var_uri_str = format!(
672 "{}/transactions/{txId}/freeze",
673 local_var_configuration.base_path,
674 txId = crate::apis::urlencode(tx_id)
675 );
676 let mut local_var_req_builder =
677 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
678
679 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
680 local_var_req_builder = local_var_req_builder
681 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
682 }
683 if let Some(local_var_param_value) = x_end_user_wallet_id {
684 local_var_req_builder = local_var_req_builder
685 .header("X-End-User-Wallet-Id", local_var_param_value.to_string());
686 }
687 if let Some(local_var_param_value) = idempotency_key {
688 local_var_req_builder =
689 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
690 }
691
692 let local_var_req = local_var_req_builder.build()?;
693 let local_var_resp = local_var_client.execute(local_var_req).await?;
694
695 let local_var_status = local_var_resp.status();
696 let local_var_content_type = local_var_resp
697 .headers()
698 .get("content-type")
699 .and_then(|v| v.to_str().ok())
700 .unwrap_or("application/octet-stream");
701 let local_var_content_type = super::ContentType::from(local_var_content_type);
702 let local_var_content = local_var_resp.text().await?;
703
704 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
705 match local_var_content_type {
706 ContentType::Json => {
707 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
708 }
709 ContentType::Text => {
710 return Err(Error::from(serde_json::Error::custom(
711 "Received `text/plain` content type response that cannot be converted to \
712 `models::FreezeTransactionResponse`",
713 )));
714 }
715 ContentType::Unsupported(local_var_unknown_type) => {
716 return Err(Error::from(serde_json::Error::custom(format!(
717 "Received `{local_var_unknown_type}` content type response that cannot be \
718 converted to `models::FreezeTransactionResponse`"
719 ))));
720 }
721 }
722 } else {
723 let local_var_entity: Option<FreezeTransactionError> =
724 serde_json::from_str(&local_var_content).ok();
725 let local_var_error = ResponseContent {
726 status: local_var_status,
727 content: local_var_content,
728 entity: local_var_entity,
729 };
730 Err(Error::ResponseError(local_var_error))
731 }
732 }
733
734 async fn get_transaction(
738 &self,
739 params: GetTransactionParams,
740 ) -> Result<models::TransactionResponse, Error<GetTransactionError>> {
741 let GetTransactionParams { tx_id } = params;
742
743 let local_var_configuration = &self.configuration;
744
745 let local_var_client = &local_var_configuration.client;
746
747 let local_var_uri_str = format!(
748 "{}/transactions/{txId}",
749 local_var_configuration.base_path,
750 txId = crate::apis::urlencode(tx_id)
751 );
752 let mut local_var_req_builder =
753 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
754
755 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
756 local_var_req_builder = local_var_req_builder
757 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
758 }
759
760 let local_var_req = local_var_req_builder.build()?;
761 let local_var_resp = local_var_client.execute(local_var_req).await?;
762
763 let local_var_status = local_var_resp.status();
764 let local_var_content_type = local_var_resp
765 .headers()
766 .get("content-type")
767 .and_then(|v| v.to_str().ok())
768 .unwrap_or("application/octet-stream");
769 let local_var_content_type = super::ContentType::from(local_var_content_type);
770 let local_var_content = local_var_resp.text().await?;
771
772 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
773 match local_var_content_type {
774 ContentType::Json => {
775 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
776 }
777 ContentType::Text => {
778 return Err(Error::from(serde_json::Error::custom(
779 "Received `text/plain` content type response that cannot be converted to \
780 `models::TransactionResponse`",
781 )));
782 }
783 ContentType::Unsupported(local_var_unknown_type) => {
784 return Err(Error::from(serde_json::Error::custom(format!(
785 "Received `{local_var_unknown_type}` content type response that cannot be \
786 converted to `models::TransactionResponse`"
787 ))));
788 }
789 }
790 } else {
791 let local_var_entity: Option<GetTransactionError> =
792 serde_json::from_str(&local_var_content).ok();
793 let local_var_error = ResponseContent {
794 status: local_var_status,
795 content: local_var_content,
796 entity: local_var_entity,
797 };
798 Err(Error::ResponseError(local_var_error))
799 }
800 }
801
802 async fn get_transaction_by_external_id(
805 &self,
806 params: GetTransactionByExternalIdParams,
807 ) -> Result<models::TransactionResponse, Error<GetTransactionByExternalIdError>> {
808 let GetTransactionByExternalIdParams { external_tx_id } = params;
809
810 let local_var_configuration = &self.configuration;
811
812 let local_var_client = &local_var_configuration.client;
813
814 let local_var_uri_str = format!(
815 "{}/transactions/external_tx_id/{externalTxId}",
816 local_var_configuration.base_path,
817 externalTxId = crate::apis::urlencode(external_tx_id)
818 );
819 let mut local_var_req_builder =
820 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
821
822 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
823 local_var_req_builder = local_var_req_builder
824 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
825 }
826
827 let local_var_req = local_var_req_builder.build()?;
828 let local_var_resp = local_var_client.execute(local_var_req).await?;
829
830 let local_var_status = local_var_resp.status();
831 let local_var_content_type = local_var_resp
832 .headers()
833 .get("content-type")
834 .and_then(|v| v.to_str().ok())
835 .unwrap_or("application/octet-stream");
836 let local_var_content_type = super::ContentType::from(local_var_content_type);
837 let local_var_content = local_var_resp.text().await?;
838
839 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
840 match local_var_content_type {
841 ContentType::Json => {
842 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
843 }
844 ContentType::Text => {
845 return Err(Error::from(serde_json::Error::custom(
846 "Received `text/plain` content type response that cannot be converted to \
847 `models::TransactionResponse`",
848 )));
849 }
850 ContentType::Unsupported(local_var_unknown_type) => {
851 return Err(Error::from(serde_json::Error::custom(format!(
852 "Received `{local_var_unknown_type}` content type response that cannot be \
853 converted to `models::TransactionResponse`"
854 ))));
855 }
856 }
857 } else {
858 let local_var_entity: Option<GetTransactionByExternalIdError> =
859 serde_json::from_str(&local_var_content).ok();
860 let local_var_error = ResponseContent {
861 status: local_var_status,
862 content: local_var_content,
863 entity: local_var_entity,
864 };
865 Err(Error::ResponseError(local_var_error))
866 }
867 }
868
869 async fn get_transactions(
873 &self,
874 params: GetTransactionsParams,
875 ) -> Result<Vec<models::TransactionResponse>, Error<GetTransactionsError>> {
876 let GetTransactionsParams {
877 before,
878 after,
879 status,
880 order_by,
881 sort,
882 limit,
883 source_type,
884 source_id,
885 dest_type,
886 dest_id,
887 assets,
888 tx_hash,
889 source_wallet_id,
890 dest_wallet_id,
891 } = params;
892
893 let local_var_configuration = &self.configuration;
894
895 let local_var_client = &local_var_configuration.client;
896
897 let local_var_uri_str = format!("{}/transactions", local_var_configuration.base_path);
898 let mut local_var_req_builder =
899 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
900
901 if let Some(ref param_value) = before {
902 local_var_req_builder =
903 local_var_req_builder.query(&[("before", ¶m_value.to_string())]);
904 }
905 if let Some(ref param_value) = after {
906 local_var_req_builder =
907 local_var_req_builder.query(&[("after", ¶m_value.to_string())]);
908 }
909 if let Some(ref param_value) = status {
910 local_var_req_builder =
911 local_var_req_builder.query(&[("status", ¶m_value.to_string())]);
912 }
913 if let Some(ref param_value) = order_by {
914 local_var_req_builder =
915 local_var_req_builder.query(&[("orderBy", ¶m_value.to_string())]);
916 }
917 if let Some(ref param_value) = sort {
918 local_var_req_builder =
919 local_var_req_builder.query(&[("sort", ¶m_value.to_string())]);
920 }
921 if let Some(ref param_value) = limit {
922 local_var_req_builder =
923 local_var_req_builder.query(&[("limit", ¶m_value.to_string())]);
924 }
925 if let Some(ref param_value) = source_type {
926 local_var_req_builder =
927 local_var_req_builder.query(&[("sourceType", ¶m_value.to_string())]);
928 }
929 if let Some(ref param_value) = source_id {
930 local_var_req_builder =
931 local_var_req_builder.query(&[("sourceId", ¶m_value.to_string())]);
932 }
933 if let Some(ref param_value) = dest_type {
934 local_var_req_builder =
935 local_var_req_builder.query(&[("destType", ¶m_value.to_string())]);
936 }
937 if let Some(ref param_value) = dest_id {
938 local_var_req_builder =
939 local_var_req_builder.query(&[("destId", ¶m_value.to_string())]);
940 }
941 if let Some(ref param_value) = assets {
942 local_var_req_builder =
943 local_var_req_builder.query(&[("assets", ¶m_value.to_string())]);
944 }
945 if let Some(ref param_value) = tx_hash {
946 local_var_req_builder =
947 local_var_req_builder.query(&[("txHash", ¶m_value.to_string())]);
948 }
949 if let Some(ref param_value) = source_wallet_id {
950 local_var_req_builder =
951 local_var_req_builder.query(&[("sourceWalletId", ¶m_value.to_string())]);
952 }
953 if let Some(ref param_value) = dest_wallet_id {
954 local_var_req_builder =
955 local_var_req_builder.query(&[("destWalletId", ¶m_value.to_string())]);
956 }
957 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
958 local_var_req_builder = local_var_req_builder
959 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
960 }
961
962 let local_var_req = local_var_req_builder.build()?;
963 let local_var_resp = local_var_client.execute(local_var_req).await?;
964
965 let local_var_status = local_var_resp.status();
966 let local_var_content_type = local_var_resp
967 .headers()
968 .get("content-type")
969 .and_then(|v| v.to_str().ok())
970 .unwrap_or("application/octet-stream");
971 let local_var_content_type = super::ContentType::from(local_var_content_type);
972 let local_var_content = local_var_resp.text().await?;
973
974 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
975 match local_var_content_type {
976 ContentType::Json => {
977 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
978 }
979 ContentType::Text => {
980 return Err(Error::from(serde_json::Error::custom(
981 "Received `text/plain` content type response that cannot be converted to \
982 `Vec<models::TransactionResponse>`",
983 )));
984 }
985 ContentType::Unsupported(local_var_unknown_type) => {
986 return Err(Error::from(serde_json::Error::custom(format!(
987 "Received `{local_var_unknown_type}` content type response that cannot be \
988 converted to `Vec<models::TransactionResponse>`"
989 ))));
990 }
991 }
992 } else {
993 let local_var_entity: Option<GetTransactionsError> =
994 serde_json::from_str(&local_var_content).ok();
995 let local_var_error = ResponseContent {
996 status: local_var_status,
997 content: local_var_content,
998 entity: local_var_entity,
999 };
1000 Err(Error::ResponseError(local_var_error))
1001 }
1002 }
1003
1004 async fn set_confirmation_threshold_by_transaction_hash(
1008 &self,
1009 params: SetConfirmationThresholdByTransactionHashParams,
1010 ) -> Result<
1011 models::SetConfirmationsThresholdResponse,
1012 Error<SetConfirmationThresholdByTransactionHashError>,
1013 > {
1014 let SetConfirmationThresholdByTransactionHashParams {
1015 tx_hash,
1016 idempotency_key,
1017 set_confirmations_threshold_request,
1018 } = params;
1019
1020 let local_var_configuration = &self.configuration;
1021
1022 let local_var_client = &local_var_configuration.client;
1023
1024 let local_var_uri_str = format!(
1025 "{}/txHash/{txHash}/set_confirmation_threshold",
1026 local_var_configuration.base_path,
1027 txHash = crate::apis::urlencode(tx_hash)
1028 );
1029 let mut local_var_req_builder =
1030 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1031
1032 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1033 local_var_req_builder = local_var_req_builder
1034 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1035 }
1036 if let Some(local_var_param_value) = idempotency_key {
1037 local_var_req_builder =
1038 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1039 }
1040 local_var_req_builder = local_var_req_builder.json(&set_confirmations_threshold_request);
1041
1042 let local_var_req = local_var_req_builder.build()?;
1043 let local_var_resp = local_var_client.execute(local_var_req).await?;
1044
1045 let local_var_status = local_var_resp.status();
1046 let local_var_content_type = local_var_resp
1047 .headers()
1048 .get("content-type")
1049 .and_then(|v| v.to_str().ok())
1050 .unwrap_or("application/octet-stream");
1051 let local_var_content_type = super::ContentType::from(local_var_content_type);
1052 let local_var_content = local_var_resp.text().await?;
1053
1054 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1055 match local_var_content_type {
1056 ContentType::Json => {
1057 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1058 }
1059 ContentType::Text => {
1060 return Err(Error::from(serde_json::Error::custom(
1061 "Received `text/plain` content type response that cannot be converted to \
1062 `models::SetConfirmationsThresholdResponse`",
1063 )));
1064 }
1065 ContentType::Unsupported(local_var_unknown_type) => {
1066 return Err(Error::from(serde_json::Error::custom(format!(
1067 "Received `{local_var_unknown_type}` content type response that cannot be \
1068 converted to `models::SetConfirmationsThresholdResponse`"
1069 ))));
1070 }
1071 }
1072 } else {
1073 let local_var_entity: Option<SetConfirmationThresholdByTransactionHashError> =
1074 serde_json::from_str(&local_var_content).ok();
1075 let local_var_error = ResponseContent {
1076 status: local_var_status,
1077 content: local_var_content,
1078 entity: local_var_entity,
1079 };
1080 Err(Error::ResponseError(local_var_error))
1081 }
1082 }
1083
1084 async fn set_transaction_confirmation_threshold(
1088 &self,
1089 params: SetTransactionConfirmationThresholdParams,
1090 ) -> Result<
1091 models::SetConfirmationsThresholdResponse,
1092 Error<SetTransactionConfirmationThresholdError>,
1093 > {
1094 let SetTransactionConfirmationThresholdParams {
1095 tx_id,
1096 idempotency_key,
1097 set_confirmations_threshold_request,
1098 } = params;
1099
1100 let local_var_configuration = &self.configuration;
1101
1102 let local_var_client = &local_var_configuration.client;
1103
1104 let local_var_uri_str = format!(
1105 "{}/transactions/{txId}/set_confirmation_threshold",
1106 local_var_configuration.base_path,
1107 txId = crate::apis::urlencode(tx_id)
1108 );
1109 let mut local_var_req_builder =
1110 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1111
1112 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1113 local_var_req_builder = local_var_req_builder
1114 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1115 }
1116 if let Some(local_var_param_value) = idempotency_key {
1117 local_var_req_builder =
1118 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1119 }
1120 local_var_req_builder = local_var_req_builder.json(&set_confirmations_threshold_request);
1121
1122 let local_var_req = local_var_req_builder.build()?;
1123 let local_var_resp = local_var_client.execute(local_var_req).await?;
1124
1125 let local_var_status = local_var_resp.status();
1126 let local_var_content_type = local_var_resp
1127 .headers()
1128 .get("content-type")
1129 .and_then(|v| v.to_str().ok())
1130 .unwrap_or("application/octet-stream");
1131 let local_var_content_type = super::ContentType::from(local_var_content_type);
1132 let local_var_content = local_var_resp.text().await?;
1133
1134 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1135 match local_var_content_type {
1136 ContentType::Json => {
1137 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1138 }
1139 ContentType::Text => {
1140 return Err(Error::from(serde_json::Error::custom(
1141 "Received `text/plain` content type response that cannot be converted to \
1142 `models::SetConfirmationsThresholdResponse`",
1143 )));
1144 }
1145 ContentType::Unsupported(local_var_unknown_type) => {
1146 return Err(Error::from(serde_json::Error::custom(format!(
1147 "Received `{local_var_unknown_type}` content type response that cannot be \
1148 converted to `models::SetConfirmationsThresholdResponse`"
1149 ))));
1150 }
1151 }
1152 } else {
1153 let local_var_entity: Option<SetTransactionConfirmationThresholdError> =
1154 serde_json::from_str(&local_var_content).ok();
1155 let local_var_error = ResponseContent {
1156 status: local_var_status,
1157 content: local_var_content,
1158 entity: local_var_entity,
1159 };
1160 Err(Error::ResponseError(local_var_error))
1161 }
1162 }
1163
1164 async fn unfreeze_transaction(
1168 &self,
1169 params: UnfreezeTransactionParams,
1170 ) -> Result<models::UnfreezeTransactionResponse, Error<UnfreezeTransactionError>> {
1171 let UnfreezeTransactionParams {
1172 tx_id,
1173 x_end_user_wallet_id,
1174 idempotency_key,
1175 } = params;
1176
1177 let local_var_configuration = &self.configuration;
1178
1179 let local_var_client = &local_var_configuration.client;
1180
1181 let local_var_uri_str = format!(
1182 "{}/transactions/{txId}/unfreeze",
1183 local_var_configuration.base_path,
1184 txId = crate::apis::urlencode(tx_id)
1185 );
1186 let mut local_var_req_builder =
1187 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1188
1189 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1190 local_var_req_builder = local_var_req_builder
1191 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1192 }
1193 if let Some(local_var_param_value) = x_end_user_wallet_id {
1194 local_var_req_builder = local_var_req_builder
1195 .header("X-End-User-Wallet-Id", local_var_param_value.to_string());
1196 }
1197 if let Some(local_var_param_value) = idempotency_key {
1198 local_var_req_builder =
1199 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1200 }
1201
1202 let local_var_req = local_var_req_builder.build()?;
1203 let local_var_resp = local_var_client.execute(local_var_req).await?;
1204
1205 let local_var_status = local_var_resp.status();
1206 let local_var_content_type = local_var_resp
1207 .headers()
1208 .get("content-type")
1209 .and_then(|v| v.to_str().ok())
1210 .unwrap_or("application/octet-stream");
1211 let local_var_content_type = super::ContentType::from(local_var_content_type);
1212 let local_var_content = local_var_resp.text().await?;
1213
1214 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1215 match local_var_content_type {
1216 ContentType::Json => {
1217 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1218 }
1219 ContentType::Text => {
1220 return Err(Error::from(serde_json::Error::custom(
1221 "Received `text/plain` content type response that cannot be converted to \
1222 `models::UnfreezeTransactionResponse`",
1223 )));
1224 }
1225 ContentType::Unsupported(local_var_unknown_type) => {
1226 return Err(Error::from(serde_json::Error::custom(format!(
1227 "Received `{local_var_unknown_type}` content type response that cannot be \
1228 converted to `models::UnfreezeTransactionResponse`"
1229 ))));
1230 }
1231 }
1232 } else {
1233 let local_var_entity: Option<UnfreezeTransactionError> =
1234 serde_json::from_str(&local_var_content).ok();
1235 let local_var_error = ResponseContent {
1236 status: local_var_status,
1237 content: local_var_content,
1238 entity: local_var_entity,
1239 };
1240 Err(Error::ResponseError(local_var_error))
1241 }
1242 }
1243}
1244
1245#[derive(Debug, Clone, Serialize, Deserialize)]
1247#[serde(untagged)]
1248pub enum CancelTransactionError {
1249 DefaultResponse(models::ErrorSchema),
1250 UnknownValue(serde_json::Value),
1251}
1252
1253#[derive(Debug, Clone, Serialize, Deserialize)]
1255#[serde(untagged)]
1256pub enum CreateTransactionError {
1257 DefaultResponse(models::ErrorSchema),
1258 UnknownValue(serde_json::Value),
1259}
1260
1261#[derive(Debug, Clone, Serialize, Deserialize)]
1263#[serde(untagged)]
1264pub enum DropTransactionError {
1265 DefaultResponse(models::ErrorSchema),
1266 UnknownValue(serde_json::Value),
1267}
1268
1269#[derive(Debug, Clone, Serialize, Deserialize)]
1272#[serde(untagged)]
1273pub enum EstimateTransactionFeeError {
1274 DefaultResponse(models::ErrorSchema),
1275 UnknownValue(serde_json::Value),
1276}
1277
1278#[derive(Debug, Clone, Serialize, Deserialize)]
1280#[serde(untagged)]
1281pub enum FreezeTransactionError {
1282 UnknownValue(serde_json::Value),
1283}
1284
1285#[derive(Debug, Clone, Serialize, Deserialize)]
1287#[serde(untagged)]
1288pub enum GetTransactionError {
1289 Status400(models::ErrorSchema),
1290 DefaultResponse(models::ErrorSchema),
1291 UnknownValue(serde_json::Value),
1292}
1293
1294#[derive(Debug, Clone, Serialize, Deserialize)]
1297#[serde(untagged)]
1298pub enum GetTransactionByExternalIdError {
1299 DefaultResponse(models::ErrorSchema),
1300 UnknownValue(serde_json::Value),
1301}
1302
1303#[derive(Debug, Clone, Serialize, Deserialize)]
1305#[serde(untagged)]
1306pub enum GetTransactionsError {
1307 DefaultResponse(models::ErrorSchema),
1308 UnknownValue(serde_json::Value),
1309}
1310
1311#[derive(Debug, Clone, Serialize, Deserialize)]
1314#[serde(untagged)]
1315pub enum SetConfirmationThresholdByTransactionHashError {
1316 DefaultResponse(models::ErrorSchema),
1317 UnknownValue(serde_json::Value),
1318}
1319
1320#[derive(Debug, Clone, Serialize, Deserialize)]
1323#[serde(untagged)]
1324pub enum SetTransactionConfirmationThresholdError {
1325 DefaultResponse(models::ErrorSchema),
1326 UnknownValue(serde_json::Value),
1327}
1328
1329#[derive(Debug, Clone, Serialize, Deserialize)]
1331#[serde(untagged)]
1332pub enum UnfreezeTransactionError {
1333 UnknownValue(serde_json::Value),
1334}