NoahClient

Struct NoahClient 

Source
pub struct NoahClient { /* private fields */ }
Expand description

Main client for interacting with the Noah API

This client provides methods to interact with all Noah API endpoints. It handles authentication, request building, and response parsing automatically.

§Thread Safety

The client is Clone and can be shared across threads safely.

§Examples

use noah_sdk::{NoahClient, Config, Environment, AuthConfig};

let config = Config::new(Environment::Sandbox);
let auth = AuthConfig::with_api_key("your-api-key".to_string());
let client = NoahClient::new(config, auth)?;

Implementations§

Source§

impl NoahClient

Source

pub async fn get_balances( &self, page_size: Option<u32>, page_token: Option<&str>, ) -> Result<GetBalancesResponse>

Get account balances with optional pagination

Retrieves a list of balances for the authenticated account. Supports pagination through page_size and page_token parameters.

§Arguments
  • page_size - Optional number of items per page (defaults to API default if None)
  • page_token - Optional token for pagination to get the next page of results
§Returns

Returns a GetBalancesResponse containing the list of balances and pagination information.

§Errors

This function will return an error if:

  • The API request fails
  • Authentication fails
  • The response cannot be deserialized
§Examples
use noah_sdk::{NoahClient, Config, Environment, AuthConfig};

let config = Config::new(Environment::Sandbox);
let auth = AuthConfig::with_api_key("your-api-key".to_string());
let client = NoahClient::new(config, auth)?;

// Get first page
let balances = client.get_balances(None, None).await?;

// Get specific page size
let balances = client.get_balances(Some(100), None).await?;
Source§

impl NoahClient

Source

pub async fn get_channels_sell( &self, params: GetChannelsSellParams<'_>, ) -> Result<GetChannelsResponse>

Get channels for selling crypto (async)

Source

pub async fn get_channel( &self, channel_id: &ChannelID, crypto_currency: &CryptoCurrencyCode, fiat_amount: Option<&PositiveDecimal>, customer_id: Option<&CustomerID>, ) -> Result<Channel>

Get channel by ID (async)

Source

pub async fn get_channels_sell_countries( &self, customer_id: Option<&CustomerID>, ) -> Result<ChannelsCountriesResponse>

Get countries for sell channels (async)

Source§

impl NoahClient

Source

pub async fn create_crypto_payin_session( &self, request: &CryptoPayinRequest, ) -> Result<CheckoutSessionResponse>

Create a cryptocurrency payin checkout session

Creates a checkout session that allows customers to pay using cryptocurrency. Returns a session with a checkout URL that the customer can be redirected to.

§Arguments
  • request - The crypto payin request containing payment details
§Returns

Returns a CheckoutSessionResponse containing the checkout URL and session details.

§Errors

This function will return an error if:

  • The request data is invalid
  • The API request fails
  • Authentication fails
§Examples
use noah_sdk::{NoahClient, Config, Environment, AuthConfig};
use noah_sdk::api::checkout::CryptoPayinRequest;
use noah_sdk::models::common::*;

let config = Config::new(Environment::Sandbox);
let auth = AuthConfig::with_api_key("your-api-key".to_string());
let client = NoahClient::new(config, auth)?;

let request = CryptoPayinRequest {
    crypto_currency: CryptoCurrencyCode::Btc,
    crypto_amount: "0.001".to_string(),
    return_url: "https://example.com/return".to_string(),
    customer_id: "customer-123".to_string(),
    external_id: None,
    customer: None,
    line_items: Default::default(),
    nonce: "unique-nonce".to_string(),
};

let session = client.create_crypto_payin_session(&request).await?;
println!("Redirect customer to: {}", session.hosted_url);
Source

pub async fn create_fiat_payin_session( &self, request: &FiatPayinRequest, ) -> Result<CheckoutSessionResponse>

Create a fiat currency payin checkout session

Creates a checkout session that allows customers to pay using fiat currency via various payment methods (e.g., credit card, bank transfer).

§Arguments
  • request - The fiat payin request containing payment details
§Returns

Returns a CheckoutSessionResponse containing the checkout URL and session details.

§Examples
use noah_sdk::{NoahClient, Config, Environment, AuthConfig};
use noah_sdk::api::checkout::FiatPayinRequest;
use noah_sdk::models::common::*;

let config = Config::new(Environment::Sandbox);
let auth = AuthConfig::with_api_key("your-api-key".to_string());
let client = NoahClient::new(config, auth)?;

let request = FiatPayinRequest {
    payment_method_category: PaymentMethodCategory::Card,
    fiat_currency: "USD".to_string(),
    crypto_currency: CryptoCurrencyCode::Btc,
    fiat_amount: "100.00".to_string(),
    return_url: "https://example.com/return".to_string(),
    customer_id: "customer-123".to_string(),
    external_id: None,
    customer: None,
    line_items: Default::default(),
    nonce: "unique-nonce".to_string(),
};

let session = client.create_fiat_payin_session(&request).await?;
Source

pub async fn create_fiat_payout_session( &self, request: &FiatPayoutRequest, ) -> Result<CheckoutSessionResponse>

Create a fiat currency payout checkout session

Creates a checkout session that allows customers to sell cryptocurrency and receive fiat currency in return.

§Arguments
  • request - The fiat payout request containing sale details
§Returns

Returns a CheckoutSessionResponse containing the checkout URL and session details.

§Examples
use noah_sdk::{NoahClient, Config, Environment, AuthConfig};
use noah_sdk::api::checkout::FiatPayoutRequest;
use noah_sdk::models::common::*;

let config = Config::new(Environment::Sandbox);
let auth = AuthConfig::with_api_key("your-api-key".to_string());
let client = NoahClient::new(config, auth)?;

let request = FiatPayoutRequest {
    crypto_currency: CryptoCurrencyCode::Btc,
    fiat_currency: "USD".to_string(),
    fiat_amount: "1000.00".to_string(),
    crypto_authorized_amount: "0.025".to_string(),
    return_url: "https://example.com/return".to_string(),
    customer_id: "customer-123".to_string(),
    external_id: None,
    customer: None,
    line_items: Default::default(),
    nonce: "unique-nonce".to_string(),
};

let session = client.create_fiat_payout_session(&request).await?;
Source§

impl NoahClient

Source

pub async fn get_customer(&self, customer_id: &CustomerID) -> Result<Customer>

Retrieve a customer by their ID

§Arguments
  • customer_id - The unique identifier of the customer to retrieve
§Returns

Returns a Customer object containing the customer’s information.

§Errors

This function will return an error if:

  • The customer ID is invalid
  • The customer does not exist
  • The API request fails
§Examples
use noah_sdk::{NoahClient, Config, Environment, AuthConfig};
use noah_sdk::models::common::CustomerID;

let config = Config::new(Environment::Sandbox);
let auth = AuthConfig::with_api_key("your-api-key".to_string());
let client = NoahClient::new(config, auth)?;

let customer_id = "customer-123".to_string();
let customer = client.get_customer(&customer_id).await?;
Source

pub async fn create_or_update_customer( &self, customer_id: &CustomerID, customer: &CustomerInput, ) -> Result<()>

Create a new customer or update an existing one

This method will create a customer if they don’t exist, or update an existing customer if they do. The customer ID is used as the unique identifier.

§Arguments
  • customer_id - The unique identifier for the customer
  • customer - The customer data to create or update
§Returns

Returns Ok(()) if the operation succeeds.

§Errors

This function will return an error if:

  • The customer data is invalid
  • The API request fails
  • Authentication fails
§Examples
use noah_sdk::{NoahClient, Config, Environment, AuthConfig};
use noah_sdk::models::customers::CustomerInput;
use noah_sdk::models::common::CustomerID;

let config = Config::new(Environment::Sandbox);
let auth = AuthConfig::with_api_key("your-api-key".to_string());
let client = NoahClient::new(config, auth)?;

use noah_sdk::models::customers::{CustomerInput, IndividualCustomerInput, FullName, StreetAddress};
use noah_sdk::models::common::*;
let customer_id = "customer-123".to_string();
// Note: IndividualCustomerInput requires many fields - see API docs for details
client.create_or_update_customer(&customer_id, &customer).await?;
Source

pub async fn get_customers( &self, page_size: Option<u32>, page_token: Option<&str>, sort_direction: Option<&SortDirection>, ) -> Result<GetCustomersResponse>

List customers with optional pagination and sorting

Retrieves a paginated list of customers. Supports pagination and sorting options.

§Arguments
  • page_size - Optional number of items per page
  • page_token - Optional token for pagination to get the next page
  • sort_direction - Optional sort direction (ascending or descending)
§Returns

Returns a GetCustomersResponse containing the list of customers and pagination info.

§Examples
use noah_sdk::{NoahClient, Config, Environment, AuthConfig};
use noah_sdk::models::common::SortDirection;

let config = Config::new(Environment::Sandbox);
let auth = AuthConfig::with_api_key("your-api-key".to_string());
let client = NoahClient::new(config, auth)?;

// Get first page, sorted descending
let customers = client.get_customers(
    Some(50),
    None,
    Some(&SortDirection::Desc)
).await?;
Source§

impl NoahClient

Source

pub async fn create_onboarding_session( &self, customer_id: &CustomerID, request: &HostedOnboardingRequest, ) -> Result<HostedSessionResponse>

Create onboarding session (async)

Source

pub async fn prefill_onboarding( &self, customer_id: &CustomerID, request: &PrefillOnboardingRequest, ) -> Result<()>

Prefill customer details (async)

Source

pub async fn get_document_upload_url( &self, customer_id: &CustomerID, document_type: &str, country_code: &CountryCode, side: Option<&str>, associate_id: Option<&str>, ) -> Result<PrefillDocumentUploadURLResponse>

Get document upload URL (async)

Source§

impl NoahClient

Source

pub async fn get_payment_methods( &self, customer_id: &CustomerID, page_size: Option<u32>, page_token: Option<&str>, ) -> Result<GetPaymentMethodsResponse>

Get payment methods (async)

Source§

impl NoahClient

Source

pub async fn get_transactions( &self, page_size: Option<u32>, page_token: Option<&str>, sort_direction: Option<&SortDirection>, ) -> Result<GetTransactionsResponse>

Get transactions (async)

Source

pub async fn get_transaction(&self, transaction_id: &str) -> Result<Transaction>

Get transaction by ID (async)

Source

pub async fn prepare_sell( &self, request: &PrepareSellRequest, ) -> Result<PrepareSellResponse>

Prepare sell transaction (async)

Source

pub async fn sell(&self, request: &SellRequest) -> Result<SellResponse>

Create sell transaction (async)

Source§

impl NoahClient

Source

pub async fn create_bank_deposit_to_onchain_address_workflow( &self, request: &BankDepositToOnchainAddressRequest, ) -> Result<BankDepositToOnchainAddressResponse>

Create bank deposit to onchain address workflow (async)

Source§

impl NoahClient

Source

pub fn new(config: Config, auth_config: AuthConfig) -> Result<Self>

Create a new client with the given configuration

§Arguments
  • config - Client configuration (environment, timeout, etc.)
  • auth_config - Authentication configuration (API key or JWT secret)
§Returns

Returns a new NoahClient instance ready to make API requests.

§Errors

This function will return an error if:

  • The HTTP client cannot be created
  • The user agent string is invalid
§Examples
use noah_sdk::{NoahClient, Config, Environment, AuthConfig};

// Using API key authentication
let config = Config::new(Environment::Sandbox);
let auth = AuthConfig::with_api_key("your-api-key".to_string());
let client = NoahClient::new(config.clone(), auth)?;

// Using JWT signing
let auth = AuthConfig::with_secret_key("your-secret-key".to_string());
let client = NoahClient::new(config.clone(), auth)?;

// Using both
let auth = AuthConfig::with_both(
    "your-api-key".to_string(),
    "your-secret-key".to_string()
);
let client = NoahClient::new(config, auth)?;
Source

pub fn base_url(&self) -> &Url

Get the base URL for API requests

Returns the base URL that all API requests will be made against.

§Examples
use noah_sdk::{NoahClient, Config, Environment, AuthConfig};

let config = Config::new(Environment::Sandbox);
let auth = AuthConfig::with_api_key("your-api-key".to_string());
let client = NoahClient::new(config, auth)?;

let base_url = client.base_url();
println!("API base URL: {}", base_url);
Source

pub async fn get<T: DeserializeOwned>(&self, path: &str) -> Result<T>

Make an async GET request

Source

pub async fn post<T: DeserializeOwned, B: Serialize>( &self, path: &str, body: &B, ) -> Result<T>

Make an async POST request

Source

pub async fn put<T: DeserializeOwned, B: Serialize>( &self, path: &str, body: &B, ) -> Result<T>

Make an async PUT request

Trait Implementations§

Source§

impl Clone for NoahClient

Source§

fn clone(&self) -> NoahClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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<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<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