Skip to main content

RoutexClient

Struct RoutexClient 

Source
pub struct RoutexClient<T> { /* private fields */ }

Implementations§

Source§

impl RoutexClient<Client>

Source

pub fn new() -> Self

Create a new client

Source

pub fn with_url(url: Url) -> Self

Create a new client with a custom URL

Source

pub fn from_env() -> Self

Create a new client from environment variables

Expected variables:

  • ROUTEX_URL
§Panics

Panics if one of the variables is not set or if ROUTEX_URL is not a valid URL.

Source§

impl<T> RoutexClient<T>
where T: HttpClient + Clone,

Source

pub fn with_client(http_client: T) -> Self

Create a new client

Source

pub fn with_url_and_client(url: Url, http_client: T) -> Self

Create a new client with a custom URL

Source

pub fn for_distribution( distribution: &str, version: &str, url: Url, http_client: T, ) -> Self

Create a new client for a versioned distribution and with a custom URL

Source

pub async fn settle_key<S: Service>( &self, ticket: &Authenticated<Ticket<S>>, ) -> Result<()>

Run a key settlement with the routex service, verifying the attestation report.

Stores a new random secret key and announces its public key to routex. In return, routex responds with its own public key and an attestation report. The attestation report allows verifying that routex created its corresponding secret key within the TEE and that its creation happened in response to our client public key (freshness).

§Errors

Returns an error if the key settlement request fails or the attestation report fails verification.

Source

pub async fn system_version(&self, ticket_id: Uuid) -> Option<String>

System version for the established session

Source§

impl<T> RoutexClient<T>
where T: HttpClient + Clone,

Source

pub fn trace_id(&self) -> Option<Vec<u8>>

Trace identifier returned with the last request

§Panics

Panics of the internal lock is poisoned.

Source

pub async fn trace<S: Service>( &self, ticket: &Authenticated<Ticket<S>>, trace_id: &[u8], ) -> Result<String>

Retrieve trace data

§Errors
Source§

impl<T> RoutexClient<T>
where T: HttpClient + Clone,

Source

pub fn set_redirect_uri( &mut self, redirect_uri: &str, ) -> Result<(), InvalidHeaderValue>

Set a redirect URI for subsequent service requests.

Redirects will eventually forward to that URI. It can be used to redirect back to a web application or to jump back into the context of a desktop or mobile application.

If no redirect URI is set, RedirectHandles will get returned instead of Redirects.

§Errors

Fails if the URI is not a valid header value (probably lacks proper percent encoding).

Source

pub fn set_recurring_consents(&mut self, enabled: bool)

Source

pub async fn register_redirect_uri<S: Service>( &self, ticket: &Authenticated<Ticket<S>>, handle: impl Into<String>, redirect_uri: impl Into<String>, ) -> Result<Url>

Register a redirect URI for a given redirect handle.

Returns the URL that the user is meant to get sent to.

§Errors

Fails if the request fails or the response data cannot get parsed as expected.

Source§

impl<T> RoutexClient<T>
where T: HttpClient + Clone,

Source

pub fn search<S: Service>( &self, ticket: Authenticated<Ticket<S>>, filters: impl IntoIterator<Item = SearchFilter>, ) -> SearchRequest<S, T>

Search for service connections (banks and other providers)

The result is a list of connections that match all the SearchFilters.

§Errors

Fails if the request fails.

§Example
use routex_client::prelude::*;

// Split input at whitespace for improved name matching
let mut filters: Vec<_> = user_input
    .split_whitespace()
    .map(|term| SearchFilter::Term(term.to_string()))
    .collect();

filters.push(SearchFilter::Types(vec![ConnectionType::Production]));

let connection_infos = client
    .search(ticket, filters)
    .iban_detection(true)
    .limit(20)
    .send()
    .await?;
Source

pub async fn info<S: Service>( &self, ticket: &Authenticated<Ticket<S>>, connection_id: ConnectionId, ) -> Result<ConnectionInfo>

Get information for a service connection

§Errors
§Examples
let connection_info = client.info(ticket, connection_id).await?;
Source§

impl<T> RoutexClient<T>
where T: HttpClient + Clone,

Source

pub fn accounts( &self, credentials: Credentials, ticket: &Authenticated<Ticket<AccountsService>>, fields: impl IntoIterator<Item = AccountField>, filter: Option<Filter<AccountField>>, ) -> Request<AccountsService, T>

Accounts service

§Example
let credentials = Credentials {
    connection_id,
    user_id,
    password,
    connection_data,
};

let response = client
    .accounts(
        credentials,
        accounts_ticket,
        [
            AccountField::Iban,
            AccountField::Bic,
            AccountField::Name,
            AccountField::DisplayName,
            AccountField::OwnerName,
            AccountField::Currency,
        ],
        Some(
            AccountField::IBAN.not_eq(None)
                .and(
                    AccountField::TYPE.eq(Some(AccountType::Current))
                        .or(AccountField::TYPE.eq(None))
                )
                .and(Account::supports(SupportedService::CollectPayment)),
        ),
    )
    .send()
    .await?;

let OBResponse::Result(result, session, connection_data) = response else {
    todo!("Handle interrupts");
};
Source

pub async fn respond_accounts( &self, ticket: &Authenticated<Ticket<AccountsService>>, context: InputContext<AccountsService>, response: impl Into<String>, ) -> Result<OBResponse<AccountsService>>

Respond to Dialog returned by accounts, respond_accounts, or confirm_accounts

§Errors

Fails if the request fails.

Source

pub async fn confirm_accounts( &self, ticket: &Authenticated<Ticket<AccountsService>>, context: ConfirmationContext<AccountsService>, ) -> Result<OBResponse<AccountsService>>

Confirm Dialog or Redirect returned by accounts, respond_accounts, or confirm_accounts

§Errors

Fails if the request fails.

Source§

impl<T> RoutexClient<T>
where T: HttpClient + Clone,

Source

pub fn balances( &self, credentials: Credentials, ticket: &Authenticated<Ticket<BalancesService>>, accounts: impl IntoIterator<Item = AccountReference>, ) -> Request<BalancesService, T>

Balances service

§Errors

Fails if the request fails.

Source

pub async fn respond_balances( &self, ticket: &Authenticated<Ticket<BalancesService>>, context: InputContext<BalancesService>, response: impl Into<String>, ) -> Result<OBResponse<BalancesService>>

Respond to Dialog returned by balances, respond_balances, or confirm_balances

§Errors

Fails if the request fails.

Source

pub async fn confirm_balances( &self, ticket: &Authenticated<Ticket<BalancesService>>, context: ConfirmationContext<BalancesService>, ) -> Result<OBResponse<BalancesService>>

Confirm Dialog or Redirect returned by balances, respond_balances, or confirm_balances

§Errors

Fails if the request fails.

Source§

impl<T> RoutexClient<T>
where T: HttpClient + Clone,

Source§

impl<T> RoutexClient<T>
where T: HttpClient + Clone,

Source

pub fn collect_payment( &self, credentials: Credentials, ticket: &Authenticated<Ticket<CollectPaymentService>>, account: Option<DebtorAccountReference>, ) -> Request<CollectPaymentService, T>

Collect Payment service

§Example
let response = client
    .collect_payment(
        credentials,
        payment_ticket,
        Some(AccountReference {
            id: AccountIdentifier::Iban(selected_iban),
            currency: None,
        }),
    )
    .session(session)
    .send()
    .await?;
Source

pub async fn respond_collect_payment( &self, ticket: &Authenticated<Ticket<CollectPaymentService>>, context: InputContext<CollectPaymentService>, response: impl Into<String>, ) -> Result<OBResponse<CollectPaymentService>>

Respond to Dialog returned by collect_payment, respond_collect_payment, or confirm_collect_payment

§Errors

Fails if the request fails.

Source

pub async fn confirm_collect_payment( &self, ticket: &Authenticated<Ticket<CollectPaymentService>>, context: ConfirmationContext<CollectPaymentService>, ) -> Result<OBResponse<CollectPaymentService>>

Confirm Dialog or Redirect returned by collect_payment, respond_collect_payment, or confirm_collect_payment

§Errors

Fails if the request fails.

Source§

impl<T> RoutexClient<T>
where T: HttpClient + Clone,

Source

pub fn transfer( &self, credentials: Credentials, ticket: &Authenticated<Ticket<TransferService>>, product: PaymentProduct, debtor_account: Option<AccountReference>, debtor_name: Option<String>, requested_execution_date: Option<ISODateTimeOrDate>, details: impl IntoIterator<Item = TransferDetails>, ) -> Request<TransferService, T>

Source

pub async fn respond_transfer( &self, ticket: &Authenticated<Ticket<TransferService>>, context: InputContext<TransferService>, response: impl Into<String>, ) -> Result<OBResponse<TransferService>>

Respond to Dialog returned by transfer, respond_transfer, or confirm_transfer

§Errors

Fails if the request fails.

Source

pub async fn confirm_transfer( &self, ticket: &Authenticated<Ticket<TransferService>>, context: ConfirmationContext<TransferService>, ) -> Result<OBResponse<TransferService>>

Confirm Dialog or Redirect returned by transfer, respond_transfer, or confirm_transfer

§Errors

Fails if the request fails.

Trait Implementations§

Source§

impl<T: Clone> Clone for RoutexClient<T>

Source§

fn clone(&self) -> RoutexClient<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for RoutexClient<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RoutexClient<Client>

Available on crate feature reqwest only.
Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for RoutexClient<T>

§

impl<T> !RefUnwindSafe for RoutexClient<T>

§

impl<T> Send for RoutexClient<T>
where T: Send,

§

impl<T> Sync for RoutexClient<T>
where T: Sync + Send,

§

impl<T> Unpin for RoutexClient<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for RoutexClient<T>
where T: UnsafeUnpin,

§

impl<T> !UnwindSafe for RoutexClient<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more