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 SmartTransfersApi: Send + Sync {
23 async fn approve_dv_p_ticket_term(
28 &self,
29 params: ApproveDvPTicketTermParams,
30 ) -> Result<models::SmartTransferTicketTermResponse, Error<ApproveDvPTicketTermError>>;
31
32 async fn cancel_ticket(
37 &self,
38 params: CancelTicketParams,
39 ) -> Result<models::SmartTransferTicketResponse, Error<CancelTicketError>>;
40
41 async fn create_ticket(
45 &self,
46 params: CreateTicketParams,
47 ) -> Result<models::SmartTransferTicketResponse, Error<CreateTicketError>>;
48
49 async fn create_ticket_term(
53 &self,
54 params: CreateTicketTermParams,
55 ) -> Result<models::SmartTransferTicketTermResponse, Error<CreateTicketTermError>>;
56
57 async fn find_ticket_by_id(
62 &self,
63 params: FindTicketByIdParams,
64 ) -> Result<models::SmartTransferTicketResponse, Error<FindTicketByIdError>>;
65
66 async fn find_ticket_term_by_id(
71 &self,
72 params: FindTicketTermByIdParams,
73 ) -> Result<models::SmartTransferTicketTermResponse, Error<FindTicketTermByIdError>>;
74
75 async fn fulfill_ticket(
81 &self,
82 params: FulfillTicketParams,
83 ) -> Result<models::SmartTransferTicketResponse, Error<FulfillTicketError>>;
84
85 async fn fund_dvp_ticket(
89 &self,
90 params: FundDvpTicketParams,
91 ) -> Result<models::SmartTransferTicketResponse, Error<FundDvpTicketError>>;
92
93 async fn fund_ticket_term(
99 &self,
100 params: FundTicketTermParams,
101 ) -> Result<models::SmartTransferTicketTermResponse, Error<FundTicketTermError>>;
102
103 async fn get_smart_transfer_statistic(
107 &self,
108 ) -> Result<models::SmartTransferStatistic, Error<GetSmartTransferStatisticError>>;
109
110 async fn get_smart_transfer_user_groups(
115 &self,
116 ) -> Result<models::SmartTransferUserGroupsResponse, Error<GetSmartTransferUserGroupsError>>;
117
118 async fn manually_fund_ticket_term(
123 &self,
124 params: ManuallyFundTicketTermParams,
125 ) -> Result<models::SmartTransferTicketTermResponse, Error<ManuallyFundTicketTermError>>;
126
127 async fn remove_ticket_term(
132 &self,
133 params: RemoveTicketTermParams,
134 ) -> Result<(), Error<RemoveTicketTermError>>;
135
136 async fn search_tickets(
142 &self,
143 params: SearchTicketsParams,
144 ) -> Result<models::SmartTransferTicketFilteredResponse, Error<SearchTicketsError>>;
145
146 async fn set_external_ref_id(
151 &self,
152 params: SetExternalRefIdParams,
153 ) -> Result<models::SmartTransferTicketResponse, Error<SetExternalRefIdError>>;
154
155 async fn set_ticket_expiration(
160 &self,
161 params: SetTicketExpirationParams,
162 ) -> Result<models::SmartTransferTicketResponse, Error<SetTicketExpirationError>>;
163
164 async fn set_user_groups(
170 &self,
171 params: SetUserGroupsParams,
172 ) -> Result<models::SmartTransferUserGroupsResponse, Error<SetUserGroupsError>>;
173
174 async fn submit_ticket(
181 &self,
182 params: SubmitTicketParams,
183 ) -> Result<models::SmartTransferTicketResponse, Error<SubmitTicketError>>;
184
185 async fn update_ticket_term(
190 &self,
191 params: UpdateTicketTermParams,
192 ) -> Result<models::SmartTransferTicketTermResponse, Error<UpdateTicketTermError>>;
193}
194
195pub struct SmartTransfersApiClient {
196 configuration: Arc<configuration::Configuration>,
197}
198
199impl SmartTransfersApiClient {
200 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
201 Self { configuration }
202 }
203}
204
205#[derive(Clone, Debug)]
208#[cfg_attr(feature = "bon", derive(::bon::Builder))]
209pub struct ApproveDvPTicketTermParams {
210 pub ticket_id: String,
211 pub term_id: String,
212 pub smart_transfer_approve_term: models::SmartTransferApproveTerm,
213 pub idempotency_key: Option<String>,
218}
219
220#[derive(Clone, Debug)]
223#[cfg_attr(feature = "bon", derive(::bon::Builder))]
224pub struct CancelTicketParams {
225 pub ticket_id: String,
226 pub idempotency_key: Option<String>,
231}
232
233#[derive(Clone, Debug)]
236#[cfg_attr(feature = "bon", derive(::bon::Builder))]
237pub struct CreateTicketParams {
238 pub smart_transfer_create_ticket: models::SmartTransferCreateTicket,
239 pub idempotency_key: Option<String>,
244}
245
246#[derive(Clone, Debug)]
249#[cfg_attr(feature = "bon", derive(::bon::Builder))]
250pub struct CreateTicketTermParams {
251 pub ticket_id: String,
252 pub smart_transfer_create_ticket_term: models::SmartTransferCreateTicketTerm,
253 pub idempotency_key: Option<String>,
258}
259
260#[derive(Clone, Debug)]
263#[cfg_attr(feature = "bon", derive(::bon::Builder))]
264pub struct FindTicketByIdParams {
265 pub ticket_id: String,
266}
267
268#[derive(Clone, Debug)]
271#[cfg_attr(feature = "bon", derive(::bon::Builder))]
272pub struct FindTicketTermByIdParams {
273 pub ticket_id: String,
274 pub term_id: String,
275}
276
277#[derive(Clone, Debug)]
280#[cfg_attr(feature = "bon", derive(::bon::Builder))]
281pub struct FulfillTicketParams {
282 pub ticket_id: String,
283 pub idempotency_key: Option<String>,
288}
289
290#[derive(Clone, Debug)]
293#[cfg_attr(feature = "bon", derive(::bon::Builder))]
294pub struct FundDvpTicketParams {
295 pub ticket_id: String,
296 pub smart_transfer_fund_dvp_ticket: models::SmartTransferFundDvpTicket,
297 pub idempotency_key: Option<String>,
302}
303
304#[derive(Clone, Debug)]
307#[cfg_attr(feature = "bon", derive(::bon::Builder))]
308pub struct FundTicketTermParams {
309 pub ticket_id: String,
310 pub term_id: String,
311 pub smart_transfer_fund_term: models::SmartTransferFundTerm,
312 pub idempotency_key: Option<String>,
317}
318
319#[derive(Clone, Debug)]
322#[cfg_attr(feature = "bon", derive(::bon::Builder))]
323pub struct ManuallyFundTicketTermParams {
324 pub ticket_id: String,
325 pub term_id: String,
326 pub smart_transfer_manually_fund_term: models::SmartTransferManuallyFundTerm,
327 pub idempotency_key: Option<String>,
332}
333
334#[derive(Clone, Debug)]
337#[cfg_attr(feature = "bon", derive(::bon::Builder))]
338pub struct RemoveTicketTermParams {
339 pub ticket_id: String,
340 pub term_id: String,
341}
342
343#[derive(Clone, Debug)]
346#[cfg_attr(feature = "bon", derive(::bon::Builder))]
347pub struct SearchTicketsParams {
348 pub q: Option<String>,
350 pub statuses: Option<Vec<String>>,
352 pub network_id: Option<String>,
354 pub created_by_me: Option<bool>,
356 pub expires_after: Option<String>,
358 pub expires_before: Option<String>,
360 pub r#type: Option<String>,
363 pub external_ref_id: Option<String>,
366 pub after: Option<String>,
368 pub limit: Option<f64>,
370}
371
372#[derive(Clone, Debug)]
375#[cfg_attr(feature = "bon", derive(::bon::Builder))]
376pub struct SetExternalRefIdParams {
377 pub ticket_id: String,
378 pub smart_transfer_set_ticket_external_id: models::SmartTransferSetTicketExternalId,
379 pub idempotency_key: Option<String>,
384}
385
386#[derive(Clone, Debug)]
389#[cfg_attr(feature = "bon", derive(::bon::Builder))]
390pub struct SetTicketExpirationParams {
391 pub ticket_id: String,
392 pub smart_transfer_set_ticket_expiration: models::SmartTransferSetTicketExpiration,
393 pub idempotency_key: Option<String>,
398}
399
400#[derive(Clone, Debug)]
403#[cfg_attr(feature = "bon", derive(::bon::Builder))]
404pub struct SetUserGroupsParams {
405 pub smart_transfer_set_user_groups: models::SmartTransferSetUserGroups,
406 pub idempotency_key: Option<String>,
411}
412
413#[derive(Clone, Debug)]
416#[cfg_attr(feature = "bon", derive(::bon::Builder))]
417pub struct SubmitTicketParams {
418 pub ticket_id: String,
419 pub smart_transfer_submit_ticket: models::SmartTransferSubmitTicket,
420 pub idempotency_key: Option<String>,
425}
426
427#[derive(Clone, Debug)]
430#[cfg_attr(feature = "bon", derive(::bon::Builder))]
431pub struct UpdateTicketTermParams {
432 pub ticket_id: String,
433 pub term_id: String,
434 pub smart_transfer_update_ticket_term: models::SmartTransferUpdateTicketTerm,
435 pub idempotency_key: Option<String>,
440}
441
442#[async_trait]
443impl SmartTransfersApi for SmartTransfersApiClient {
444 async fn approve_dv_p_ticket_term(
447 &self,
448 params: ApproveDvPTicketTermParams,
449 ) -> Result<models::SmartTransferTicketTermResponse, Error<ApproveDvPTicketTermError>> {
450 let ApproveDvPTicketTermParams {
451 ticket_id,
452 term_id,
453 smart_transfer_approve_term,
454 idempotency_key,
455 } = params;
456
457 let local_var_configuration = &self.configuration;
458
459 let local_var_client = &local_var_configuration.client;
460
461 let local_var_uri_str = format!(
462 "{}/smart_transfers/{ticketId}/terms/{termId}/dvp/approve",
463 local_var_configuration.base_path,
464 ticketId = crate::apis::urlencode(ticket_id),
465 termId = crate::apis::urlencode(term_id)
466 );
467 let mut local_var_req_builder =
468 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
469
470 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
471 local_var_req_builder = local_var_req_builder
472 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
473 }
474 if let Some(local_var_param_value) = idempotency_key {
475 local_var_req_builder =
476 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
477 }
478 local_var_req_builder = local_var_req_builder.json(&smart_transfer_approve_term);
479
480 let local_var_req = local_var_req_builder.build()?;
481 let local_var_resp = local_var_client.execute(local_var_req).await?;
482
483 let local_var_status = local_var_resp.status();
484 let local_var_content_type = local_var_resp
485 .headers()
486 .get("content-type")
487 .and_then(|v| v.to_str().ok())
488 .unwrap_or("application/octet-stream");
489 let local_var_content_type = super::ContentType::from(local_var_content_type);
490 let local_var_content = local_var_resp.text().await?;
491
492 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
493 match local_var_content_type {
494 ContentType::Json => {
495 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
496 }
497 ContentType::Text => {
498 return Err(Error::from(serde_json::Error::custom(
499 "Received `text/plain` content type response that cannot be converted to \
500 `models::SmartTransferTicketTermResponse`",
501 )));
502 }
503 ContentType::Unsupported(local_var_unknown_type) => {
504 return Err(Error::from(serde_json::Error::custom(format!(
505 "Received `{local_var_unknown_type}` content type response that cannot be \
506 converted to `models::SmartTransferTicketTermResponse`"
507 ))));
508 }
509 }
510 } else {
511 let local_var_entity: Option<ApproveDvPTicketTermError> =
512 serde_json::from_str(&local_var_content).ok();
513 let local_var_error = ResponseContent {
514 status: local_var_status,
515 content: local_var_content,
516 entity: local_var_entity,
517 };
518 Err(Error::ResponseError(local_var_error))
519 }
520 }
521
522 async fn cancel_ticket(
525 &self,
526 params: CancelTicketParams,
527 ) -> Result<models::SmartTransferTicketResponse, Error<CancelTicketError>> {
528 let CancelTicketParams {
529 ticket_id,
530 idempotency_key,
531 } = params;
532
533 let local_var_configuration = &self.configuration;
534
535 let local_var_client = &local_var_configuration.client;
536
537 let local_var_uri_str = format!(
538 "{}/smart-transfers/{ticketId}/cancel",
539 local_var_configuration.base_path,
540 ticketId = crate::apis::urlencode(ticket_id)
541 );
542 let mut local_var_req_builder =
543 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
544
545 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
546 local_var_req_builder = local_var_req_builder
547 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
548 }
549 if let Some(local_var_param_value) = idempotency_key {
550 local_var_req_builder =
551 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
552 }
553
554 let local_var_req = local_var_req_builder.build()?;
555 let local_var_resp = local_var_client.execute(local_var_req).await?;
556
557 let local_var_status = local_var_resp.status();
558 let local_var_content_type = local_var_resp
559 .headers()
560 .get("content-type")
561 .and_then(|v| v.to_str().ok())
562 .unwrap_or("application/octet-stream");
563 let local_var_content_type = super::ContentType::from(local_var_content_type);
564 let local_var_content = local_var_resp.text().await?;
565
566 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
567 match local_var_content_type {
568 ContentType::Json => {
569 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
570 }
571 ContentType::Text => {
572 return Err(Error::from(serde_json::Error::custom(
573 "Received `text/plain` content type response that cannot be converted to \
574 `models::SmartTransferTicketResponse`",
575 )));
576 }
577 ContentType::Unsupported(local_var_unknown_type) => {
578 return Err(Error::from(serde_json::Error::custom(format!(
579 "Received `{local_var_unknown_type}` content type response that cannot be \
580 converted to `models::SmartTransferTicketResponse`"
581 ))));
582 }
583 }
584 } else {
585 let local_var_entity: Option<CancelTicketError> =
586 serde_json::from_str(&local_var_content).ok();
587 let local_var_error = ResponseContent {
588 status: local_var_status,
589 content: local_var_content,
590 entity: local_var_entity,
591 };
592 Err(Error::ResponseError(local_var_error))
593 }
594 }
595
596 async fn create_ticket(
598 &self,
599 params: CreateTicketParams,
600 ) -> Result<models::SmartTransferTicketResponse, Error<CreateTicketError>> {
601 let CreateTicketParams {
602 smart_transfer_create_ticket,
603 idempotency_key,
604 } = params;
605
606 let local_var_configuration = &self.configuration;
607
608 let local_var_client = &local_var_configuration.client;
609
610 let local_var_uri_str = format!("{}/smart-transfers", local_var_configuration.base_path);
611 let mut local_var_req_builder =
612 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
613
614 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
615 local_var_req_builder = local_var_req_builder
616 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
617 }
618 if let Some(local_var_param_value) = idempotency_key {
619 local_var_req_builder =
620 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
621 }
622 local_var_req_builder = local_var_req_builder.json(&smart_transfer_create_ticket);
623
624 let local_var_req = local_var_req_builder.build()?;
625 let local_var_resp = local_var_client.execute(local_var_req).await?;
626
627 let local_var_status = local_var_resp.status();
628 let local_var_content_type = local_var_resp
629 .headers()
630 .get("content-type")
631 .and_then(|v| v.to_str().ok())
632 .unwrap_or("application/octet-stream");
633 let local_var_content_type = super::ContentType::from(local_var_content_type);
634 let local_var_content = local_var_resp.text().await?;
635
636 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
637 match local_var_content_type {
638 ContentType::Json => {
639 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
640 }
641 ContentType::Text => {
642 return Err(Error::from(serde_json::Error::custom(
643 "Received `text/plain` content type response that cannot be converted to \
644 `models::SmartTransferTicketResponse`",
645 )));
646 }
647 ContentType::Unsupported(local_var_unknown_type) => {
648 return Err(Error::from(serde_json::Error::custom(format!(
649 "Received `{local_var_unknown_type}` content type response that cannot be \
650 converted to `models::SmartTransferTicketResponse`"
651 ))));
652 }
653 }
654 } else {
655 let local_var_entity: Option<CreateTicketError> =
656 serde_json::from_str(&local_var_content).ok();
657 let local_var_error = ResponseContent {
658 status: local_var_status,
659 content: local_var_content,
660 entity: local_var_entity,
661 };
662 Err(Error::ResponseError(local_var_error))
663 }
664 }
665
666 async fn create_ticket_term(
668 &self,
669 params: CreateTicketTermParams,
670 ) -> Result<models::SmartTransferTicketTermResponse, Error<CreateTicketTermError>> {
671 let CreateTicketTermParams {
672 ticket_id,
673 smart_transfer_create_ticket_term,
674 idempotency_key,
675 } = params;
676
677 let local_var_configuration = &self.configuration;
678
679 let local_var_client = &local_var_configuration.client;
680
681 let local_var_uri_str = format!(
682 "{}/smart-transfers/{ticketId}/terms",
683 local_var_configuration.base_path,
684 ticketId = crate::apis::urlencode(ticket_id)
685 );
686 let mut local_var_req_builder =
687 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
688
689 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
690 local_var_req_builder = local_var_req_builder
691 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
692 }
693 if let Some(local_var_param_value) = idempotency_key {
694 local_var_req_builder =
695 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
696 }
697 local_var_req_builder = local_var_req_builder.json(&smart_transfer_create_ticket_term);
698
699 let local_var_req = local_var_req_builder.build()?;
700 let local_var_resp = local_var_client.execute(local_var_req).await?;
701
702 let local_var_status = local_var_resp.status();
703 let local_var_content_type = local_var_resp
704 .headers()
705 .get("content-type")
706 .and_then(|v| v.to_str().ok())
707 .unwrap_or("application/octet-stream");
708 let local_var_content_type = super::ContentType::from(local_var_content_type);
709 let local_var_content = local_var_resp.text().await?;
710
711 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
712 match local_var_content_type {
713 ContentType::Json => {
714 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
715 }
716 ContentType::Text => {
717 return Err(Error::from(serde_json::Error::custom(
718 "Received `text/plain` content type response that cannot be converted to \
719 `models::SmartTransferTicketTermResponse`",
720 )));
721 }
722 ContentType::Unsupported(local_var_unknown_type) => {
723 return Err(Error::from(serde_json::Error::custom(format!(
724 "Received `{local_var_unknown_type}` content type response that cannot be \
725 converted to `models::SmartTransferTicketTermResponse`"
726 ))));
727 }
728 }
729 } else {
730 let local_var_entity: Option<CreateTicketTermError> =
731 serde_json::from_str(&local_var_content).ok();
732 let local_var_error = ResponseContent {
733 status: local_var_status,
734 content: local_var_content,
735 entity: local_var_entity,
736 };
737 Err(Error::ResponseError(local_var_error))
738 }
739 }
740
741 async fn find_ticket_by_id(
744 &self,
745 params: FindTicketByIdParams,
746 ) -> Result<models::SmartTransferTicketResponse, Error<FindTicketByIdError>> {
747 let FindTicketByIdParams { ticket_id } = params;
748
749 let local_var_configuration = &self.configuration;
750
751 let local_var_client = &local_var_configuration.client;
752
753 let local_var_uri_str = format!(
754 "{}/smart-transfers/{ticketId}",
755 local_var_configuration.base_path,
756 ticketId = crate::apis::urlencode(ticket_id)
757 );
758 let mut local_var_req_builder =
759 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
760
761 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
762 local_var_req_builder = local_var_req_builder
763 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
764 }
765
766 let local_var_req = local_var_req_builder.build()?;
767 let local_var_resp = local_var_client.execute(local_var_req).await?;
768
769 let local_var_status = local_var_resp.status();
770 let local_var_content_type = local_var_resp
771 .headers()
772 .get("content-type")
773 .and_then(|v| v.to_str().ok())
774 .unwrap_or("application/octet-stream");
775 let local_var_content_type = super::ContentType::from(local_var_content_type);
776 let local_var_content = local_var_resp.text().await?;
777
778 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
779 match local_var_content_type {
780 ContentType::Json => {
781 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
782 }
783 ContentType::Text => {
784 return Err(Error::from(serde_json::Error::custom(
785 "Received `text/plain` content type response that cannot be converted to \
786 `models::SmartTransferTicketResponse`",
787 )));
788 }
789 ContentType::Unsupported(local_var_unknown_type) => {
790 return Err(Error::from(serde_json::Error::custom(format!(
791 "Received `{local_var_unknown_type}` content type response that cannot be \
792 converted to `models::SmartTransferTicketResponse`"
793 ))));
794 }
795 }
796 } else {
797 let local_var_entity: Option<FindTicketByIdError> =
798 serde_json::from_str(&local_var_content).ok();
799 let local_var_error = ResponseContent {
800 status: local_var_status,
801 content: local_var_content,
802 entity: local_var_entity,
803 };
804 Err(Error::ResponseError(local_var_error))
805 }
806 }
807
808 async fn find_ticket_term_by_id(
811 &self,
812 params: FindTicketTermByIdParams,
813 ) -> Result<models::SmartTransferTicketTermResponse, Error<FindTicketTermByIdError>> {
814 let FindTicketTermByIdParams { ticket_id, term_id } = params;
815
816 let local_var_configuration = &self.configuration;
817
818 let local_var_client = &local_var_configuration.client;
819
820 let local_var_uri_str = format!(
821 "{}/smart-transfers/{ticketId}/terms/{termId}",
822 local_var_configuration.base_path,
823 ticketId = crate::apis::urlencode(ticket_id),
824 termId = crate::apis::urlencode(term_id)
825 );
826 let mut local_var_req_builder =
827 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
828
829 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
830 local_var_req_builder = local_var_req_builder
831 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
832 }
833
834 let local_var_req = local_var_req_builder.build()?;
835 let local_var_resp = local_var_client.execute(local_var_req).await?;
836
837 let local_var_status = local_var_resp.status();
838 let local_var_content_type = local_var_resp
839 .headers()
840 .get("content-type")
841 .and_then(|v| v.to_str().ok())
842 .unwrap_or("application/octet-stream");
843 let local_var_content_type = super::ContentType::from(local_var_content_type);
844 let local_var_content = local_var_resp.text().await?;
845
846 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
847 match local_var_content_type {
848 ContentType::Json => {
849 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
850 }
851 ContentType::Text => {
852 return Err(Error::from(serde_json::Error::custom(
853 "Received `text/plain` content type response that cannot be converted to \
854 `models::SmartTransferTicketTermResponse`",
855 )));
856 }
857 ContentType::Unsupported(local_var_unknown_type) => {
858 return Err(Error::from(serde_json::Error::custom(format!(
859 "Received `{local_var_unknown_type}` content type response that cannot be \
860 converted to `models::SmartTransferTicketTermResponse`"
861 ))));
862 }
863 }
864 } else {
865 let local_var_entity: Option<FindTicketTermByIdError> =
866 serde_json::from_str(&local_var_content).ok();
867 let local_var_error = ResponseContent {
868 status: local_var_status,
869 content: local_var_content,
870 entity: local_var_entity,
871 };
872 Err(Error::ResponseError(local_var_error))
873 }
874 }
875
876 async fn fulfill_ticket(
880 &self,
881 params: FulfillTicketParams,
882 ) -> Result<models::SmartTransferTicketResponse, Error<FulfillTicketError>> {
883 let FulfillTicketParams {
884 ticket_id,
885 idempotency_key,
886 } = params;
887
888 let local_var_configuration = &self.configuration;
889
890 let local_var_client = &local_var_configuration.client;
891
892 let local_var_uri_str = format!(
893 "{}/smart-transfers/{ticketId}/fulfill",
894 local_var_configuration.base_path,
895 ticketId = crate::apis::urlencode(ticket_id)
896 );
897 let mut local_var_req_builder =
898 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
899
900 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
901 local_var_req_builder = local_var_req_builder
902 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
903 }
904 if let Some(local_var_param_value) = idempotency_key {
905 local_var_req_builder =
906 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
907 }
908
909 let local_var_req = local_var_req_builder.build()?;
910 let local_var_resp = local_var_client.execute(local_var_req).await?;
911
912 let local_var_status = local_var_resp.status();
913 let local_var_content_type = local_var_resp
914 .headers()
915 .get("content-type")
916 .and_then(|v| v.to_str().ok())
917 .unwrap_or("application/octet-stream");
918 let local_var_content_type = super::ContentType::from(local_var_content_type);
919 let local_var_content = local_var_resp.text().await?;
920
921 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
922 match local_var_content_type {
923 ContentType::Json => {
924 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
925 }
926 ContentType::Text => {
927 return Err(Error::from(serde_json::Error::custom(
928 "Received `text/plain` content type response that cannot be converted to \
929 `models::SmartTransferTicketResponse`",
930 )));
931 }
932 ContentType::Unsupported(local_var_unknown_type) => {
933 return Err(Error::from(serde_json::Error::custom(format!(
934 "Received `{local_var_unknown_type}` content type response that cannot be \
935 converted to `models::SmartTransferTicketResponse`"
936 ))));
937 }
938 }
939 } else {
940 let local_var_entity: Option<FulfillTicketError> =
941 serde_json::from_str(&local_var_content).ok();
942 let local_var_error = ResponseContent {
943 status: local_var_status,
944 content: local_var_content,
945 entity: local_var_entity,
946 };
947 Err(Error::ResponseError(local_var_error))
948 }
949 }
950
951 async fn fund_dvp_ticket(
953 &self,
954 params: FundDvpTicketParams,
955 ) -> Result<models::SmartTransferTicketResponse, Error<FundDvpTicketError>> {
956 let FundDvpTicketParams {
957 ticket_id,
958 smart_transfer_fund_dvp_ticket,
959 idempotency_key,
960 } = params;
961
962 let local_var_configuration = &self.configuration;
963
964 let local_var_client = &local_var_configuration.client;
965
966 let local_var_uri_str = format!(
967 "{}/smart_transfers/{ticketId}/dvp/fund",
968 local_var_configuration.base_path,
969 ticketId = crate::apis::urlencode(ticket_id)
970 );
971 let mut local_var_req_builder =
972 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
973
974 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
975 local_var_req_builder = local_var_req_builder
976 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
977 }
978 if let Some(local_var_param_value) = idempotency_key {
979 local_var_req_builder =
980 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
981 }
982 local_var_req_builder = local_var_req_builder.json(&smart_transfer_fund_dvp_ticket);
983
984 let local_var_req = local_var_req_builder.build()?;
985 let local_var_resp = local_var_client.execute(local_var_req).await?;
986
987 let local_var_status = local_var_resp.status();
988 let local_var_content_type = local_var_resp
989 .headers()
990 .get("content-type")
991 .and_then(|v| v.to_str().ok())
992 .unwrap_or("application/octet-stream");
993 let local_var_content_type = super::ContentType::from(local_var_content_type);
994 let local_var_content = local_var_resp.text().await?;
995
996 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
997 match local_var_content_type {
998 ContentType::Json => {
999 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1000 }
1001 ContentType::Text => {
1002 return Err(Error::from(serde_json::Error::custom(
1003 "Received `text/plain` content type response that cannot be converted to \
1004 `models::SmartTransferTicketResponse`",
1005 )));
1006 }
1007 ContentType::Unsupported(local_var_unknown_type) => {
1008 return Err(Error::from(serde_json::Error::custom(format!(
1009 "Received `{local_var_unknown_type}` content type response that cannot be \
1010 converted to `models::SmartTransferTicketResponse`"
1011 ))));
1012 }
1013 }
1014 } else {
1015 let local_var_entity: Option<FundDvpTicketError> =
1016 serde_json::from_str(&local_var_content).ok();
1017 let local_var_error = ResponseContent {
1018 status: local_var_status,
1019 content: local_var_content,
1020 entity: local_var_entity,
1021 };
1022 Err(Error::ResponseError(local_var_error))
1023 }
1024 }
1025
1026 async fn fund_ticket_term(
1030 &self,
1031 params: FundTicketTermParams,
1032 ) -> Result<models::SmartTransferTicketTermResponse, Error<FundTicketTermError>> {
1033 let FundTicketTermParams {
1034 ticket_id,
1035 term_id,
1036 smart_transfer_fund_term,
1037 idempotency_key,
1038 } = params;
1039
1040 let local_var_configuration = &self.configuration;
1041
1042 let local_var_client = &local_var_configuration.client;
1043
1044 let local_var_uri_str = format!(
1045 "{}/smart-transfers/{ticketId}/terms/{termId}/fund",
1046 local_var_configuration.base_path,
1047 ticketId = crate::apis::urlencode(ticket_id),
1048 termId = crate::apis::urlencode(term_id)
1049 );
1050 let mut local_var_req_builder =
1051 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1052
1053 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1054 local_var_req_builder = local_var_req_builder
1055 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1056 }
1057 if let Some(local_var_param_value) = idempotency_key {
1058 local_var_req_builder =
1059 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1060 }
1061 local_var_req_builder = local_var_req_builder.json(&smart_transfer_fund_term);
1062
1063 let local_var_req = local_var_req_builder.build()?;
1064 let local_var_resp = local_var_client.execute(local_var_req).await?;
1065
1066 let local_var_status = local_var_resp.status();
1067 let local_var_content_type = local_var_resp
1068 .headers()
1069 .get("content-type")
1070 .and_then(|v| v.to_str().ok())
1071 .unwrap_or("application/octet-stream");
1072 let local_var_content_type = super::ContentType::from(local_var_content_type);
1073 let local_var_content = local_var_resp.text().await?;
1074
1075 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1076 match local_var_content_type {
1077 ContentType::Json => {
1078 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1079 }
1080 ContentType::Text => {
1081 return Err(Error::from(serde_json::Error::custom(
1082 "Received `text/plain` content type response that cannot be converted to \
1083 `models::SmartTransferTicketTermResponse`",
1084 )));
1085 }
1086 ContentType::Unsupported(local_var_unknown_type) => {
1087 return Err(Error::from(serde_json::Error::custom(format!(
1088 "Received `{local_var_unknown_type}` content type response that cannot be \
1089 converted to `models::SmartTransferTicketTermResponse`"
1090 ))));
1091 }
1092 }
1093 } else {
1094 let local_var_entity: Option<FundTicketTermError> =
1095 serde_json::from_str(&local_var_content).ok();
1096 let local_var_error = ResponseContent {
1097 status: local_var_status,
1098 content: local_var_content,
1099 entity: local_var_entity,
1100 };
1101 Err(Error::ResponseError(local_var_error))
1102 }
1103 }
1104
1105 async fn get_smart_transfer_statistic(
1107 &self,
1108 ) -> Result<models::SmartTransferStatistic, Error<GetSmartTransferStatisticError>> {
1109 let local_var_configuration = &self.configuration;
1110
1111 let local_var_client = &local_var_configuration.client;
1112
1113 let local_var_uri_str = format!(
1114 "{}/smart_transfers/statistic",
1115 local_var_configuration.base_path
1116 );
1117 let mut local_var_req_builder =
1118 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1119
1120 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1121 local_var_req_builder = local_var_req_builder
1122 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1123 }
1124
1125 let local_var_req = local_var_req_builder.build()?;
1126 let local_var_resp = local_var_client.execute(local_var_req).await?;
1127
1128 let local_var_status = local_var_resp.status();
1129 let local_var_content_type = local_var_resp
1130 .headers()
1131 .get("content-type")
1132 .and_then(|v| v.to_str().ok())
1133 .unwrap_or("application/octet-stream");
1134 let local_var_content_type = super::ContentType::from(local_var_content_type);
1135 let local_var_content = local_var_resp.text().await?;
1136
1137 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1138 match local_var_content_type {
1139 ContentType::Json => {
1140 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1141 }
1142 ContentType::Text => {
1143 return Err(Error::from(serde_json::Error::custom(
1144 "Received `text/plain` content type response that cannot be converted to \
1145 `models::SmartTransferStatistic`",
1146 )));
1147 }
1148 ContentType::Unsupported(local_var_unknown_type) => {
1149 return Err(Error::from(serde_json::Error::custom(format!(
1150 "Received `{local_var_unknown_type}` content type response that cannot be \
1151 converted to `models::SmartTransferStatistic`"
1152 ))));
1153 }
1154 }
1155 } else {
1156 let local_var_entity: Option<GetSmartTransferStatisticError> =
1157 serde_json::from_str(&local_var_content).ok();
1158 let local_var_error = ResponseContent {
1159 status: local_var_status,
1160 content: local_var_content,
1161 entity: local_var_entity,
1162 };
1163 Err(Error::ResponseError(local_var_error))
1164 }
1165 }
1166
1167 async fn get_smart_transfer_user_groups(
1170 &self,
1171 ) -> Result<models::SmartTransferUserGroupsResponse, Error<GetSmartTransferUserGroupsError>>
1172 {
1173 let local_var_configuration = &self.configuration;
1174
1175 let local_var_client = &local_var_configuration.client;
1176
1177 let local_var_uri_str = format!(
1178 "{}/smart-transfers/settings/user-groups",
1179 local_var_configuration.base_path
1180 );
1181 let mut local_var_req_builder =
1182 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1183
1184 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1185 local_var_req_builder = local_var_req_builder
1186 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1187 }
1188
1189 let local_var_req = local_var_req_builder.build()?;
1190 let local_var_resp = local_var_client.execute(local_var_req).await?;
1191
1192 let local_var_status = local_var_resp.status();
1193 let local_var_content_type = local_var_resp
1194 .headers()
1195 .get("content-type")
1196 .and_then(|v| v.to_str().ok())
1197 .unwrap_or("application/octet-stream");
1198 let local_var_content_type = super::ContentType::from(local_var_content_type);
1199 let local_var_content = local_var_resp.text().await?;
1200
1201 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1202 match local_var_content_type {
1203 ContentType::Json => {
1204 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1205 }
1206 ContentType::Text => {
1207 return Err(Error::from(serde_json::Error::custom(
1208 "Received `text/plain` content type response that cannot be converted to \
1209 `models::SmartTransferUserGroupsResponse`",
1210 )));
1211 }
1212 ContentType::Unsupported(local_var_unknown_type) => {
1213 return Err(Error::from(serde_json::Error::custom(format!(
1214 "Received `{local_var_unknown_type}` content type response that cannot be \
1215 converted to `models::SmartTransferUserGroupsResponse`"
1216 ))));
1217 }
1218 }
1219 } else {
1220 let local_var_entity: Option<GetSmartTransferUserGroupsError> =
1221 serde_json::from_str(&local_var_content).ok();
1222 let local_var_error = ResponseContent {
1223 status: local_var_status,
1224 content: local_var_content,
1225 entity: local_var_entity,
1226 };
1227 Err(Error::ResponseError(local_var_error))
1228 }
1229 }
1230
1231 async fn manually_fund_ticket_term(
1234 &self,
1235 params: ManuallyFundTicketTermParams,
1236 ) -> Result<models::SmartTransferTicketTermResponse, Error<ManuallyFundTicketTermError>> {
1237 let ManuallyFundTicketTermParams {
1238 ticket_id,
1239 term_id,
1240 smart_transfer_manually_fund_term,
1241 idempotency_key,
1242 } = params;
1243
1244 let local_var_configuration = &self.configuration;
1245
1246 let local_var_client = &local_var_configuration.client;
1247
1248 let local_var_uri_str = format!(
1249 "{}/smart-transfers/{ticketId}/terms/{termId}/manually-fund",
1250 local_var_configuration.base_path,
1251 ticketId = crate::apis::urlencode(ticket_id),
1252 termId = crate::apis::urlencode(term_id)
1253 );
1254 let mut local_var_req_builder =
1255 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1256
1257 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1258 local_var_req_builder = local_var_req_builder
1259 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1260 }
1261 if let Some(local_var_param_value) = idempotency_key {
1262 local_var_req_builder =
1263 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1264 }
1265 local_var_req_builder = local_var_req_builder.json(&smart_transfer_manually_fund_term);
1266
1267 let local_var_req = local_var_req_builder.build()?;
1268 let local_var_resp = local_var_client.execute(local_var_req).await?;
1269
1270 let local_var_status = local_var_resp.status();
1271 let local_var_content_type = local_var_resp
1272 .headers()
1273 .get("content-type")
1274 .and_then(|v| v.to_str().ok())
1275 .unwrap_or("application/octet-stream");
1276 let local_var_content_type = super::ContentType::from(local_var_content_type);
1277 let local_var_content = local_var_resp.text().await?;
1278
1279 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1280 match local_var_content_type {
1281 ContentType::Json => {
1282 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1283 }
1284 ContentType::Text => {
1285 return Err(Error::from(serde_json::Error::custom(
1286 "Received `text/plain` content type response that cannot be converted to \
1287 `models::SmartTransferTicketTermResponse`",
1288 )));
1289 }
1290 ContentType::Unsupported(local_var_unknown_type) => {
1291 return Err(Error::from(serde_json::Error::custom(format!(
1292 "Received `{local_var_unknown_type}` content type response that cannot be \
1293 converted to `models::SmartTransferTicketTermResponse`"
1294 ))));
1295 }
1296 }
1297 } else {
1298 let local_var_entity: Option<ManuallyFundTicketTermError> =
1299 serde_json::from_str(&local_var_content).ok();
1300 let local_var_error = ResponseContent {
1301 status: local_var_status,
1302 content: local_var_content,
1303 entity: local_var_entity,
1304 };
1305 Err(Error::ResponseError(local_var_error))
1306 }
1307 }
1308
1309 async fn remove_ticket_term(
1312 &self,
1313 params: RemoveTicketTermParams,
1314 ) -> Result<(), Error<RemoveTicketTermError>> {
1315 let RemoveTicketTermParams { ticket_id, term_id } = params;
1316
1317 let local_var_configuration = &self.configuration;
1318
1319 let local_var_client = &local_var_configuration.client;
1320
1321 let local_var_uri_str = format!(
1322 "{}/smart-transfers/{ticketId}/terms/{termId}",
1323 local_var_configuration.base_path,
1324 ticketId = crate::apis::urlencode(ticket_id),
1325 termId = crate::apis::urlencode(term_id)
1326 );
1327 let mut local_var_req_builder =
1328 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
1329
1330 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1331 local_var_req_builder = local_var_req_builder
1332 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1333 }
1334
1335 let local_var_req = local_var_req_builder.build()?;
1336 let local_var_resp = local_var_client.execute(local_var_req).await?;
1337
1338 let local_var_status = local_var_resp.status();
1339 let local_var_content = local_var_resp.text().await?;
1340
1341 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1342 Ok(())
1343 } else {
1344 let local_var_entity: Option<RemoveTicketTermError> =
1345 serde_json::from_str(&local_var_content).ok();
1346 let local_var_error = ResponseContent {
1347 status: local_var_status,
1348 content: local_var_content,
1349 entity: local_var_entity,
1350 };
1351 Err(Error::ResponseError(local_var_error))
1352 }
1353 }
1354
1355 async fn search_tickets(
1359 &self,
1360 params: SearchTicketsParams,
1361 ) -> Result<models::SmartTransferTicketFilteredResponse, Error<SearchTicketsError>> {
1362 let SearchTicketsParams {
1363 q,
1364 statuses,
1365 network_id,
1366 created_by_me,
1367 expires_after,
1368 expires_before,
1369 r#type,
1370 external_ref_id,
1371 after,
1372 limit,
1373 } = params;
1374
1375 let local_var_configuration = &self.configuration;
1376
1377 let local_var_client = &local_var_configuration.client;
1378
1379 let local_var_uri_str = format!("{}/smart-transfers", local_var_configuration.base_path);
1380 let mut local_var_req_builder =
1381 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1382
1383 if let Some(ref param_value) = q {
1384 local_var_req_builder = local_var_req_builder.query(&[("q", ¶m_value.to_string())]);
1385 }
1386 if let Some(ref param_value) = statuses {
1387 local_var_req_builder = match "multi" {
1388 "multi" => local_var_req_builder.query(
1389 ¶m_value
1390 .into_iter()
1391 .map(|p| ("statuses".to_owned(), p.to_string()))
1392 .collect::<Vec<(std::string::String, std::string::String)>>(),
1393 ),
1394 _ => local_var_req_builder.query(&[(
1395 "statuses",
1396 ¶m_value
1397 .into_iter()
1398 .map(|p| p.to_string())
1399 .collect::<Vec<String>>()
1400 .join(",")
1401 .to_string(),
1402 )]),
1403 };
1404 }
1405 if let Some(ref param_value) = network_id {
1406 local_var_req_builder =
1407 local_var_req_builder.query(&[("networkId", ¶m_value.to_string())]);
1408 }
1409 if let Some(ref param_value) = created_by_me {
1410 local_var_req_builder =
1411 local_var_req_builder.query(&[("createdByMe", ¶m_value.to_string())]);
1412 }
1413 if let Some(ref param_value) = expires_after {
1414 local_var_req_builder =
1415 local_var_req_builder.query(&[("expiresAfter", ¶m_value.to_string())]);
1416 }
1417 if let Some(ref param_value) = expires_before {
1418 local_var_req_builder =
1419 local_var_req_builder.query(&[("expiresBefore", ¶m_value.to_string())]);
1420 }
1421 if let Some(ref param_value) = r#type {
1422 local_var_req_builder =
1423 local_var_req_builder.query(&[("type", ¶m_value.to_string())]);
1424 }
1425 if let Some(ref param_value) = external_ref_id {
1426 local_var_req_builder =
1427 local_var_req_builder.query(&[("externalRefId", ¶m_value.to_string())]);
1428 }
1429 if let Some(ref param_value) = after {
1430 local_var_req_builder =
1431 local_var_req_builder.query(&[("after", ¶m_value.to_string())]);
1432 }
1433 if let Some(ref param_value) = limit {
1434 local_var_req_builder =
1435 local_var_req_builder.query(&[("limit", ¶m_value.to_string())]);
1436 }
1437 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1438 local_var_req_builder = local_var_req_builder
1439 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1440 }
1441
1442 let local_var_req = local_var_req_builder.build()?;
1443 let local_var_resp = local_var_client.execute(local_var_req).await?;
1444
1445 let local_var_status = local_var_resp.status();
1446 let local_var_content_type = local_var_resp
1447 .headers()
1448 .get("content-type")
1449 .and_then(|v| v.to_str().ok())
1450 .unwrap_or("application/octet-stream");
1451 let local_var_content_type = super::ContentType::from(local_var_content_type);
1452 let local_var_content = local_var_resp.text().await?;
1453
1454 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1455 match local_var_content_type {
1456 ContentType::Json => {
1457 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1458 }
1459 ContentType::Text => {
1460 return Err(Error::from(serde_json::Error::custom(
1461 "Received `text/plain` content type response that cannot be converted to \
1462 `models::SmartTransferTicketFilteredResponse`",
1463 )));
1464 }
1465 ContentType::Unsupported(local_var_unknown_type) => {
1466 return Err(Error::from(serde_json::Error::custom(format!(
1467 "Received `{local_var_unknown_type}` content type response that cannot be \
1468 converted to `models::SmartTransferTicketFilteredResponse`"
1469 ))));
1470 }
1471 }
1472 } else {
1473 let local_var_entity: Option<SearchTicketsError> =
1474 serde_json::from_str(&local_var_content).ok();
1475 let local_var_error = ResponseContent {
1476 status: local_var_status,
1477 content: local_var_content,
1478 entity: local_var_entity,
1479 };
1480 Err(Error::ResponseError(local_var_error))
1481 }
1482 }
1483
1484 async fn set_external_ref_id(
1487 &self,
1488 params: SetExternalRefIdParams,
1489 ) -> Result<models::SmartTransferTicketResponse, Error<SetExternalRefIdError>> {
1490 let SetExternalRefIdParams {
1491 ticket_id,
1492 smart_transfer_set_ticket_external_id,
1493 idempotency_key,
1494 } = params;
1495
1496 let local_var_configuration = &self.configuration;
1497
1498 let local_var_client = &local_var_configuration.client;
1499
1500 let local_var_uri_str = format!(
1501 "{}/smart-transfers/{ticketId}/external-id",
1502 local_var_configuration.base_path,
1503 ticketId = crate::apis::urlencode(ticket_id)
1504 );
1505 let mut local_var_req_builder =
1506 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1507
1508 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1509 local_var_req_builder = local_var_req_builder
1510 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1511 }
1512 if let Some(local_var_param_value) = idempotency_key {
1513 local_var_req_builder =
1514 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1515 }
1516 local_var_req_builder = local_var_req_builder.json(&smart_transfer_set_ticket_external_id);
1517
1518 let local_var_req = local_var_req_builder.build()?;
1519 let local_var_resp = local_var_client.execute(local_var_req).await?;
1520
1521 let local_var_status = local_var_resp.status();
1522 let local_var_content_type = local_var_resp
1523 .headers()
1524 .get("content-type")
1525 .and_then(|v| v.to_str().ok())
1526 .unwrap_or("application/octet-stream");
1527 let local_var_content_type = super::ContentType::from(local_var_content_type);
1528 let local_var_content = local_var_resp.text().await?;
1529
1530 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1531 match local_var_content_type {
1532 ContentType::Json => {
1533 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1534 }
1535 ContentType::Text => {
1536 return Err(Error::from(serde_json::Error::custom(
1537 "Received `text/plain` content type response that cannot be converted to \
1538 `models::SmartTransferTicketResponse`",
1539 )));
1540 }
1541 ContentType::Unsupported(local_var_unknown_type) => {
1542 return Err(Error::from(serde_json::Error::custom(format!(
1543 "Received `{local_var_unknown_type}` content type response that cannot be \
1544 converted to `models::SmartTransferTicketResponse`"
1545 ))));
1546 }
1547 }
1548 } else {
1549 let local_var_entity: Option<SetExternalRefIdError> =
1550 serde_json::from_str(&local_var_content).ok();
1551 let local_var_error = ResponseContent {
1552 status: local_var_status,
1553 content: local_var_content,
1554 entity: local_var_entity,
1555 };
1556 Err(Error::ResponseError(local_var_error))
1557 }
1558 }
1559
1560 async fn set_ticket_expiration(
1563 &self,
1564 params: SetTicketExpirationParams,
1565 ) -> Result<models::SmartTransferTicketResponse, Error<SetTicketExpirationError>> {
1566 let SetTicketExpirationParams {
1567 ticket_id,
1568 smart_transfer_set_ticket_expiration,
1569 idempotency_key,
1570 } = params;
1571
1572 let local_var_configuration = &self.configuration;
1573
1574 let local_var_client = &local_var_configuration.client;
1575
1576 let local_var_uri_str = format!(
1577 "{}/smart-transfers/{ticketId}/expires-in",
1578 local_var_configuration.base_path,
1579 ticketId = crate::apis::urlencode(ticket_id)
1580 );
1581 let mut local_var_req_builder =
1582 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1583
1584 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1585 local_var_req_builder = local_var_req_builder
1586 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1587 }
1588 if let Some(local_var_param_value) = idempotency_key {
1589 local_var_req_builder =
1590 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1591 }
1592 local_var_req_builder = local_var_req_builder.json(&smart_transfer_set_ticket_expiration);
1593
1594 let local_var_req = local_var_req_builder.build()?;
1595 let local_var_resp = local_var_client.execute(local_var_req).await?;
1596
1597 let local_var_status = local_var_resp.status();
1598 let local_var_content_type = local_var_resp
1599 .headers()
1600 .get("content-type")
1601 .and_then(|v| v.to_str().ok())
1602 .unwrap_or("application/octet-stream");
1603 let local_var_content_type = super::ContentType::from(local_var_content_type);
1604 let local_var_content = local_var_resp.text().await?;
1605
1606 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1607 match local_var_content_type {
1608 ContentType::Json => {
1609 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1610 }
1611 ContentType::Text => {
1612 return Err(Error::from(serde_json::Error::custom(
1613 "Received `text/plain` content type response that cannot be converted to \
1614 `models::SmartTransferTicketResponse`",
1615 )));
1616 }
1617 ContentType::Unsupported(local_var_unknown_type) => {
1618 return Err(Error::from(serde_json::Error::custom(format!(
1619 "Received `{local_var_unknown_type}` content type response that cannot be \
1620 converted to `models::SmartTransferTicketResponse`"
1621 ))));
1622 }
1623 }
1624 } else {
1625 let local_var_entity: Option<SetTicketExpirationError> =
1626 serde_json::from_str(&local_var_content).ok();
1627 let local_var_error = ResponseContent {
1628 status: local_var_status,
1629 content: local_var_content,
1630 entity: local_var_entity,
1631 };
1632 Err(Error::ResponseError(local_var_error))
1633 }
1634 }
1635
1636 async fn set_user_groups(
1640 &self,
1641 params: SetUserGroupsParams,
1642 ) -> Result<models::SmartTransferUserGroupsResponse, Error<SetUserGroupsError>> {
1643 let SetUserGroupsParams {
1644 smart_transfer_set_user_groups,
1645 idempotency_key,
1646 } = params;
1647
1648 let local_var_configuration = &self.configuration;
1649
1650 let local_var_client = &local_var_configuration.client;
1651
1652 let local_var_uri_str = format!(
1653 "{}/smart-transfers/settings/user-groups",
1654 local_var_configuration.base_path
1655 );
1656 let mut local_var_req_builder =
1657 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1658
1659 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1660 local_var_req_builder = local_var_req_builder
1661 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1662 }
1663 if let Some(local_var_param_value) = idempotency_key {
1664 local_var_req_builder =
1665 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1666 }
1667 local_var_req_builder = local_var_req_builder.json(&smart_transfer_set_user_groups);
1668
1669 let local_var_req = local_var_req_builder.build()?;
1670 let local_var_resp = local_var_client.execute(local_var_req).await?;
1671
1672 let local_var_status = local_var_resp.status();
1673 let local_var_content_type = local_var_resp
1674 .headers()
1675 .get("content-type")
1676 .and_then(|v| v.to_str().ok())
1677 .unwrap_or("application/octet-stream");
1678 let local_var_content_type = super::ContentType::from(local_var_content_type);
1679 let local_var_content = local_var_resp.text().await?;
1680
1681 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1682 match local_var_content_type {
1683 ContentType::Json => {
1684 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1685 }
1686 ContentType::Text => {
1687 return Err(Error::from(serde_json::Error::custom(
1688 "Received `text/plain` content type response that cannot be converted to \
1689 `models::SmartTransferUserGroupsResponse`",
1690 )));
1691 }
1692 ContentType::Unsupported(local_var_unknown_type) => {
1693 return Err(Error::from(serde_json::Error::custom(format!(
1694 "Received `{local_var_unknown_type}` content type response that cannot be \
1695 converted to `models::SmartTransferUserGroupsResponse`"
1696 ))));
1697 }
1698 }
1699 } else {
1700 let local_var_entity: Option<SetUserGroupsError> =
1701 serde_json::from_str(&local_var_content).ok();
1702 let local_var_error = ResponseContent {
1703 status: local_var_status,
1704 content: local_var_content,
1705 entity: local_var_entity,
1706 };
1707 Err(Error::ResponseError(local_var_error))
1708 }
1709 }
1710
1711 async fn submit_ticket(
1716 &self,
1717 params: SubmitTicketParams,
1718 ) -> Result<models::SmartTransferTicketResponse, Error<SubmitTicketError>> {
1719 let SubmitTicketParams {
1720 ticket_id,
1721 smart_transfer_submit_ticket,
1722 idempotency_key,
1723 } = params;
1724
1725 let local_var_configuration = &self.configuration;
1726
1727 let local_var_client = &local_var_configuration.client;
1728
1729 let local_var_uri_str = format!(
1730 "{}/smart-transfers/{ticketId}/submit",
1731 local_var_configuration.base_path,
1732 ticketId = crate::apis::urlencode(ticket_id)
1733 );
1734 let mut local_var_req_builder =
1735 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1736
1737 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1738 local_var_req_builder = local_var_req_builder
1739 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1740 }
1741 if let Some(local_var_param_value) = idempotency_key {
1742 local_var_req_builder =
1743 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1744 }
1745 local_var_req_builder = local_var_req_builder.json(&smart_transfer_submit_ticket);
1746
1747 let local_var_req = local_var_req_builder.build()?;
1748 let local_var_resp = local_var_client.execute(local_var_req).await?;
1749
1750 let local_var_status = local_var_resp.status();
1751 let local_var_content_type = local_var_resp
1752 .headers()
1753 .get("content-type")
1754 .and_then(|v| v.to_str().ok())
1755 .unwrap_or("application/octet-stream");
1756 let local_var_content_type = super::ContentType::from(local_var_content_type);
1757 let local_var_content = local_var_resp.text().await?;
1758
1759 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1760 match local_var_content_type {
1761 ContentType::Json => {
1762 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1763 }
1764 ContentType::Text => {
1765 return Err(Error::from(serde_json::Error::custom(
1766 "Received `text/plain` content type response that cannot be converted to \
1767 `models::SmartTransferTicketResponse`",
1768 )));
1769 }
1770 ContentType::Unsupported(local_var_unknown_type) => {
1771 return Err(Error::from(serde_json::Error::custom(format!(
1772 "Received `{local_var_unknown_type}` content type response that cannot be \
1773 converted to `models::SmartTransferTicketResponse`"
1774 ))));
1775 }
1776 }
1777 } else {
1778 let local_var_entity: Option<SubmitTicketError> =
1779 serde_json::from_str(&local_var_content).ok();
1780 let local_var_error = ResponseContent {
1781 status: local_var_status,
1782 content: local_var_content,
1783 entity: local_var_entity,
1784 };
1785 Err(Error::ResponseError(local_var_error))
1786 }
1787 }
1788
1789 async fn update_ticket_term(
1792 &self,
1793 params: UpdateTicketTermParams,
1794 ) -> Result<models::SmartTransferTicketTermResponse, Error<UpdateTicketTermError>> {
1795 let UpdateTicketTermParams {
1796 ticket_id,
1797 term_id,
1798 smart_transfer_update_ticket_term,
1799 idempotency_key,
1800 } = params;
1801
1802 let local_var_configuration = &self.configuration;
1803
1804 let local_var_client = &local_var_configuration.client;
1805
1806 let local_var_uri_str = format!(
1807 "{}/smart-transfers/{ticketId}/terms/{termId}",
1808 local_var_configuration.base_path,
1809 ticketId = crate::apis::urlencode(ticket_id),
1810 termId = crate::apis::urlencode(term_id)
1811 );
1812 let mut local_var_req_builder =
1813 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1814
1815 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1816 local_var_req_builder = local_var_req_builder
1817 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1818 }
1819 if let Some(local_var_param_value) = idempotency_key {
1820 local_var_req_builder =
1821 local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
1822 }
1823 local_var_req_builder = local_var_req_builder.json(&smart_transfer_update_ticket_term);
1824
1825 let local_var_req = local_var_req_builder.build()?;
1826 let local_var_resp = local_var_client.execute(local_var_req).await?;
1827
1828 let local_var_status = local_var_resp.status();
1829 let local_var_content_type = local_var_resp
1830 .headers()
1831 .get("content-type")
1832 .and_then(|v| v.to_str().ok())
1833 .unwrap_or("application/octet-stream");
1834 let local_var_content_type = super::ContentType::from(local_var_content_type);
1835 let local_var_content = local_var_resp.text().await?;
1836
1837 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1838 match local_var_content_type {
1839 ContentType::Json => {
1840 crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
1841 }
1842 ContentType::Text => {
1843 return Err(Error::from(serde_json::Error::custom(
1844 "Received `text/plain` content type response that cannot be converted to \
1845 `models::SmartTransferTicketTermResponse`",
1846 )));
1847 }
1848 ContentType::Unsupported(local_var_unknown_type) => {
1849 return Err(Error::from(serde_json::Error::custom(format!(
1850 "Received `{local_var_unknown_type}` content type response that cannot be \
1851 converted to `models::SmartTransferTicketTermResponse`"
1852 ))));
1853 }
1854 }
1855 } else {
1856 let local_var_entity: Option<UpdateTicketTermError> =
1857 serde_json::from_str(&local_var_content).ok();
1858 let local_var_error = ResponseContent {
1859 status: local_var_status,
1860 content: local_var_content,
1861 entity: local_var_entity,
1862 };
1863 Err(Error::ResponseError(local_var_error))
1864 }
1865 }
1866}
1867
1868#[derive(Debug, Clone, Serialize, Deserialize)]
1871#[serde(untagged)]
1872pub enum ApproveDvPTicketTermError {
1873 Status403(models::SmartTransferForbiddenResponse),
1874 Status404(models::SmartTransferNotFoundResponse),
1875 Status422(models::SmartTransferBadRequestResponse),
1876 UnknownValue(serde_json::Value),
1877}
1878
1879#[derive(Debug, Clone, Serialize, Deserialize)]
1881#[serde(untagged)]
1882pub enum CancelTicketError {
1883 Status403(models::SmartTransferForbiddenResponse),
1884 Status404(models::SmartTransferNotFoundResponse),
1885 Status422(models::SmartTransferBadRequestResponse),
1886 UnknownValue(serde_json::Value),
1887}
1888
1889#[derive(Debug, Clone, Serialize, Deserialize)]
1891#[serde(untagged)]
1892pub enum CreateTicketError {
1893 Status403(models::SmartTransferForbiddenResponse),
1894 Status422(models::SmartTransferBadRequestResponse),
1895 UnknownValue(serde_json::Value),
1896}
1897
1898#[derive(Debug, Clone, Serialize, Deserialize)]
1900#[serde(untagged)]
1901pub enum CreateTicketTermError {
1902 Status403(models::SmartTransferForbiddenResponse),
1903 Status422(models::SmartTransferBadRequestResponse),
1904 UnknownValue(serde_json::Value),
1905}
1906
1907#[derive(Debug, Clone, Serialize, Deserialize)]
1909#[serde(untagged)]
1910pub enum FindTicketByIdError {
1911 Status403(models::SmartTransferForbiddenResponse),
1912 Status404(models::SmartTransferNotFoundResponse),
1913 UnknownValue(serde_json::Value),
1914}
1915
1916#[derive(Debug, Clone, Serialize, Deserialize)]
1919#[serde(untagged)]
1920pub enum FindTicketTermByIdError {
1921 Status403(models::SmartTransferForbiddenResponse),
1922 Status404(models::SmartTransferNotFoundResponse),
1923 UnknownValue(serde_json::Value),
1924}
1925
1926#[derive(Debug, Clone, Serialize, Deserialize)]
1928#[serde(untagged)]
1929pub enum FulfillTicketError {
1930 Status403(models::SmartTransferForbiddenResponse),
1931 Status404(models::SmartTransferNotFoundResponse),
1932 Status422(models::SmartTransferBadRequestResponse),
1933 UnknownValue(serde_json::Value),
1934}
1935
1936#[derive(Debug, Clone, Serialize, Deserialize)]
1938#[serde(untagged)]
1939pub enum FundDvpTicketError {
1940 Status403(models::SmartTransferForbiddenResponse),
1941 Status404(models::SmartTransferNotFoundResponse),
1942 Status422(models::SmartTransferBadRequestResponse),
1943 UnknownValue(serde_json::Value),
1944}
1945
1946#[derive(Debug, Clone, Serialize, Deserialize)]
1948#[serde(untagged)]
1949pub enum FundTicketTermError {
1950 Status403(models::SmartTransferForbiddenResponse),
1951 Status404(models::SmartTransferNotFoundResponse),
1952 Status422(models::SmartTransferBadRequestResponse),
1953 UnknownValue(serde_json::Value),
1954}
1955
1956#[derive(Debug, Clone, Serialize, Deserialize)]
1959#[serde(untagged)]
1960pub enum GetSmartTransferStatisticError {
1961 Status403(models::SmartTransferForbiddenResponse),
1962 DefaultResponse(models::ErrorSchema),
1963 UnknownValue(serde_json::Value),
1964}
1965
1966#[derive(Debug, Clone, Serialize, Deserialize)]
1969#[serde(untagged)]
1970pub enum GetSmartTransferUserGroupsError {
1971 Status403(models::SmartTransferForbiddenResponse),
1972 Status422(models::SmartTransferBadRequestResponse),
1973 UnknownValue(serde_json::Value),
1974}
1975
1976#[derive(Debug, Clone, Serialize, Deserialize)]
1979#[serde(untagged)]
1980pub enum ManuallyFundTicketTermError {
1981 Status403(models::SmartTransferForbiddenResponse),
1982 Status404(models::SmartTransferNotFoundResponse),
1983 Status422(models::SmartTransferBadRequestResponse),
1984 UnknownValue(serde_json::Value),
1985}
1986
1987#[derive(Debug, Clone, Serialize, Deserialize)]
1989#[serde(untagged)]
1990pub enum RemoveTicketTermError {
1991 Status403(models::SmartTransferForbiddenResponse),
1992 Status404(models::SmartTransferNotFoundResponse),
1993 UnknownValue(serde_json::Value),
1994}
1995
1996#[derive(Debug, Clone, Serialize, Deserialize)]
1998#[serde(untagged)]
1999pub enum SearchTicketsError {
2000 Status403(models::SmartTransferForbiddenResponse),
2001 UnknownValue(serde_json::Value),
2002}
2003
2004#[derive(Debug, Clone, Serialize, Deserialize)]
2006#[serde(untagged)]
2007pub enum SetExternalRefIdError {
2008 Status403(models::SmartTransferForbiddenResponse),
2009 Status404(models::SmartTransferNotFoundResponse),
2010 Status422(models::SmartTransferBadRequestResponse),
2011 UnknownValue(serde_json::Value),
2012}
2013
2014#[derive(Debug, Clone, Serialize, Deserialize)]
2017#[serde(untagged)]
2018pub enum SetTicketExpirationError {
2019 Status403(models::SmartTransferForbiddenResponse),
2020 Status404(models::SmartTransferNotFoundResponse),
2021 Status422(models::SmartTransferBadRequestResponse),
2022 UnknownValue(serde_json::Value),
2023}
2024
2025#[derive(Debug, Clone, Serialize, Deserialize)]
2027#[serde(untagged)]
2028pub enum SetUserGroupsError {
2029 Status403(models::SmartTransferForbiddenResponse),
2030 Status422(models::SmartTransferBadRequestResponse),
2031 UnknownValue(serde_json::Value),
2032}
2033
2034#[derive(Debug, Clone, Serialize, Deserialize)]
2036#[serde(untagged)]
2037pub enum SubmitTicketError {
2038 Status403(models::SmartTransferForbiddenResponse),
2039 Status404(models::SmartTransferNotFoundResponse),
2040 Status422(models::SmartTransferBadRequestResponse),
2041 UnknownValue(serde_json::Value),
2042}
2043
2044#[derive(Debug, Clone, Serialize, Deserialize)]
2046#[serde(untagged)]
2047pub enum UpdateTicketTermError {
2048 Status403(models::SmartTransferForbiddenResponse),
2049 Status404(models::SmartTransferNotFoundResponse),
2050 UnknownValue(serde_json::Value),
2051}