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
impl NoahClient
Sourcepub async fn get_balances(
&self,
page_size: Option<u32>,
page_token: Option<&str>,
) -> Result<GetBalancesResponse>
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
impl NoahClient
Sourcepub async fn get_channels_sell(
&self,
params: GetChannelsSellParams<'_>,
) -> Result<GetChannelsResponse>
pub async fn get_channels_sell( &self, params: GetChannelsSellParams<'_>, ) -> Result<GetChannelsResponse>
Get channels for selling crypto (async)
Sourcepub async fn get_channel(
&self,
channel_id: &ChannelID,
crypto_currency: &CryptoCurrencyCode,
fiat_amount: Option<&PositiveDecimal>,
customer_id: Option<&CustomerID>,
) -> Result<Channel>
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)
Sourcepub async fn get_channels_sell_countries(
&self,
customer_id: Option<&CustomerID>,
) -> Result<ChannelsCountriesResponse>
pub async fn get_channels_sell_countries( &self, customer_id: Option<&CustomerID>, ) -> Result<ChannelsCountriesResponse>
Get countries for sell channels (async)
Source§impl NoahClient
impl NoahClient
Sourcepub async fn create_crypto_payin_session(
&self,
request: &CryptoPayinRequest,
) -> Result<CheckoutSessionResponse>
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);Sourcepub async fn create_fiat_payin_session(
&self,
request: &FiatPayinRequest,
) -> Result<CheckoutSessionResponse>
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?;Sourcepub async fn create_fiat_payout_session(
&self,
request: &FiatPayoutRequest,
) -> Result<CheckoutSessionResponse>
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
impl NoahClient
Sourcepub async fn get_customer(&self, customer_id: &CustomerID) -> Result<Customer>
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?;Sourcepub async fn create_or_update_customer(
&self,
customer_id: &CustomerID,
customer: &CustomerInput,
) -> Result<()>
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 customercustomer- 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?;Sourcepub async fn get_customers(
&self,
page_size: Option<u32>,
page_token: Option<&str>,
sort_direction: Option<&SortDirection>,
) -> Result<GetCustomersResponse>
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 pagepage_token- Optional token for pagination to get the next pagesort_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
impl NoahClient
Sourcepub async fn create_onboarding_session(
&self,
customer_id: &CustomerID,
request: &HostedOnboardingRequest,
) -> Result<HostedSessionResponse>
pub async fn create_onboarding_session( &self, customer_id: &CustomerID, request: &HostedOnboardingRequest, ) -> Result<HostedSessionResponse>
Create onboarding session (async)
Sourcepub async fn prefill_onboarding(
&self,
customer_id: &CustomerID,
request: &PrefillOnboardingRequest,
) -> Result<()>
pub async fn prefill_onboarding( &self, customer_id: &CustomerID, request: &PrefillOnboardingRequest, ) -> Result<()>
Prefill customer details (async)
Sourcepub 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>
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
impl NoahClient
Sourcepub async fn get_payment_methods(
&self,
customer_id: &CustomerID,
page_size: Option<u32>,
page_token: Option<&str>,
) -> Result<GetPaymentMethodsResponse>
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
impl NoahClient
Sourcepub async fn get_transactions(
&self,
page_size: Option<u32>,
page_token: Option<&str>,
sort_direction: Option<&SortDirection>,
) -> Result<GetTransactionsResponse>
pub async fn get_transactions( &self, page_size: Option<u32>, page_token: Option<&str>, sort_direction: Option<&SortDirection>, ) -> Result<GetTransactionsResponse>
Get transactions (async)
Sourcepub async fn get_transaction(&self, transaction_id: &str) -> Result<Transaction>
pub async fn get_transaction(&self, transaction_id: &str) -> Result<Transaction>
Get transaction by ID (async)
Sourcepub async fn prepare_sell(
&self,
request: &PrepareSellRequest,
) -> Result<PrepareSellResponse>
pub async fn prepare_sell( &self, request: &PrepareSellRequest, ) -> Result<PrepareSellResponse>
Prepare sell transaction (async)
Sourcepub async fn sell(&self, request: &SellRequest) -> Result<SellResponse>
pub async fn sell(&self, request: &SellRequest) -> Result<SellResponse>
Create sell transaction (async)
Source§impl NoahClient
impl NoahClient
Sourcepub async fn create_bank_deposit_to_onchain_address_workflow(
&self,
request: &BankDepositToOnchainAddressRequest,
) -> Result<BankDepositToOnchainAddressResponse>
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
impl NoahClient
Sourcepub fn new(config: Config, auth_config: AuthConfig) -> Result<Self>
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)?;Sourcepub fn base_url(&self) -> &Url
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);Sourcepub async fn get<T: DeserializeOwned>(&self, path: &str) -> Result<T>
pub async fn get<T: DeserializeOwned>(&self, path: &str) -> Result<T>
Make an async GET request
Trait Implementations§
Source§impl Clone for NoahClient
impl Clone for NoahClient
Source§fn clone(&self) -> NoahClient
fn clone(&self) -> NoahClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more