Skip to main content

Client

Struct Client 

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

A configured, reusable ALAT API client.

Cloning is cheap (the inner reqwest::Client, Config, and subscription key are reference counted) and clones share the same connection pool, so a single Client can be shared freely across tasks/threads.

§Example

use alat::{Client, Config};

let config = Config::playground("subscription_key", "api_key");
let client = Client::new(config)?;

Implementations§

Source§

impl Client

Source

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

Builds a client from a Config.

Content-Type: application/json and Cache-Control: no-cache (banking reads must never be cached) are installed as default headers. The subscription key (Ocp-Apim-Subscription-Key) and channel API key (x-api-key) are validated here and then injected on every request.

§Errors

Returns Error::Configuration if a credential contains bytes that are not valid in an HTTP header value, or if the underlying HTTP client fails to build. A bad key is reported here, never silently dropped.

Source

pub fn with_subscription_key( &self, subscription_key: impl AsRef<str>, ) -> Result<Self>

Derives a sibling client that uses a different subscription key while sharing this client’s connection pool, channel API key, gateway, and timeout.

Use this when your endpoints span multiple APIM products (each product has its own subscription key). See the module docs.

§Errors

Error::Configuration if the key has invalid header bytes.

Source

pub fn config(&self) -> &Config

Borrows the Config this client was built with.

Source

pub fn subscription_key(&self) -> &str

The subscription key this client currently sends.

Source

pub fn http_client(&self) -> &Client

Borrows the underlying reqwest::Client for advanced/custom requests.

Source

pub async fn get_json<T>( &self, path: &str, query: &[(&str, &str)], extra_headers: &[(&'static str, String)], ) -> Result<T>

Issues a GET and decodes the JSON response into T.

query is a slice of (name, value) pairs that are percent-encoded and appended to the URL. extra_headers adds per-request headers (e.g. the bills/airtime access header) on top of the authentication headers.

Source

pub async fn post_json<B, T>( &self, path: &str, body: &B, extra_headers: &[(&'static str, String)], ) -> Result<T>

Serializes body as JSON, issues a POST, and decodes the response into T.

extra_headers adds per-request headers (e.g. the funds-transfer hash signature, or the bills/airtime access key) alongside auth headers.

Source§

impl Client

Source

pub async fn get_wallet_details( &self, account_number: &str, ) -> Result<WalletAccountDetails>

Fetches a wallet’s balance, status, and type by NUBAN.

GET /ws-acct-mgt/api/AccountMaintenance/CustomerAccount/GetAccountV2/accountNumber/{accountNumber}

Source

pub async fn get_transaction_history( &self, request: &TransactionHistoryRequest, ) -> Result<Vec<Transaction>>

Fetches a wallet’s transaction history over a date range.

POST /ws-acct-mgt/api/AccountMaintenance/CustomerAccount/transhistoryV2

Source§

impl Client

Source

pub async fn get_all_bills(&self) -> Result<Vec<BillCategory>>

Lists every bill category, biller, and package available to your channel.

Requires the access header. GET /bills-payment/api/BillsPayment/GetAllBills

Source

pub async fn validate_customer( &self, request: &ValidateCustomerRequest, ) -> Result<CustomerValidation>

Validates a customer identifier at a biller before payment.

Requires the access header. POST /bills-payment/api/BillsPayment/ValidateCustomer

Source

pub async fn pay_bill(&self, request: &PayBillRequest) -> Result<PaymentResult>

Pays a bill from a client account (returns a pending result).

Requires the access header. POST /bills-payment/api/Shared/PayBill

Source

pub async fn check_bill_transaction_status( &self, request: &CheckTransactionStatusRequest, ) -> Result<TransactionStatus>

Checks the status of a previously submitted bill transaction.

Requires the access header. POST /bills-payment/api/PartnerPayment/checktransactionstatus

Source

pub async fn get_data_plans(&self) -> Result<Vec<DataPlanCategory>>

Lists data plans across all networks.

The access header is optional here but sent if configured. GET /airtime-data/api/Data/GetDataPlans

Source

pub async fn purchase_airtime( &self, request: &PurchaseAirtimeRequest, ) -> Result<PaymentResult>

Purchases airtime from a single client account (returns a pending result).

Requires the access header. POST /airtime-data/api/Airtime/Client/PurchaseAirtime

Source

pub async fn purchase_data( &self, request: &PurchaseDataRequest, ) -> Result<PaymentResult>

Purchases a data bundle from a single client account (returns a pending result).

The access header is optional here but sent if configured. POST /airtime-data/api/Data/Client/PurchaseData

Source§

impl Client

Source

pub async fn initiate_statement( &self, request: &InitiateStatementRequest, ) -> Result<String>

Step 1 — initiate statement generation; returns the referenceId to pass to get_statement_transactions.

POST /get-statement-service/api/AccountMaintenance/InitiateGetCustomerStatement

Source

pub async fn get_statement_transactions( &self, request: &GetStatementRequest, ) -> Result<Vec<Transaction>>

Step 2 — retrieve the prepared statement’s transaction rows.

POST /get-statement-service/api/AccountMaintenance/GetCustomerTransactions

Source§

impl Client

Source

pub fn compute_transfer_hash( &self, salt_key: &str, request: &TransferRequest, ) -> Result<String>

Computes the HMAC-SHA512 hash for a transfer, hex-encoded.

Concatenation order (per ALAT docs): transactionReference + destinationBankCode + destinationAccountNumber + sourceAccountNumber + amount.

§Errors

Error::Validation if salt_key is empty; Error::Configuration if HMAC initialization fails.

Source

pub async fn get_bank_list(&self) -> Result<Vec<Bank>>

Fetches every bank in the NIBSS directory (name + routing code).

GET /funds-transfer-open/api/OpenApiTransfer/GetAllBanks

Source

pub async fn verify_account( &self, bank_code: &str, account_number: &str, channel_id: Option<&str>, ) -> Result<AccountNameEnquiry>

Name enquiry — resolve the registered holder name for a NUBAN at a given bank. Always do this before transfer_funds.

channel_id is an optional query parameter some channels require.

GET /funds-transfer-open/api/Shared/AccountNameEnquiry/{bankCode}/{accountNumber}

Source

pub async fn transfer_funds( &self, salt_key: &str, request: &TransferRequest, ) -> Result<TransferResult>

Submits an interbank transfer, signing it with the hash header.

Returns the pending TransferResult; the final status arrives via your callback URL (or poll the platform reference).

POST /funds-transfer-open/api/OpenApiTransfer/transfer-fund-request

Source

pub async fn get_nip_charges(&self) -> Result<NipCharges>

Fetches the interbank (NIP) charge schedule.

Served by the Wallet Services product’s “Debit Wallet” group on the Playground gateway (/debit-wallet) — i.e. call this with a client configured for Config::playground and a Wallet Services subscription key, not the funds-transfer gateway. On the funds-transfer flow itself, prefer reading the bands off a name enquiry via AccountNameEnquiry::charge_for.

GET /debit-wallet/api/Shared/GetNIPCharges

Source§

impl Client

Source

pub async fn create_prefix(&self, setup: &PrefixSetup) -> Result<String>

Registers a new virtual-account prefix (points it at your settlement account + webhooks). Returns the gateway’s raw acknowledgement string.

POST /VirtualAccount/api/v1/Prefix/CreateNew

Source

pub async fn modify_prefix(&self, setup: &PrefixSetup) -> Result<String>

Updates an existing prefix’s configuration (e.g. rotate webhook URLs, toggle is_active). Returns the gateway’s raw acknowledgement string.

POST /VirtualAccount/api/v1/Prefix/Modify

Source

pub async fn list_prefixes(&self) -> Result<Vec<PrefixSetup>>

Lists all prefixes registered for your channel.

GET /VirtualAccount/api/v1/Prefix

Source

pub async fn get_prefix(&self, prefix: &str) -> Result<PrefixSetup>

Fetches the configuration of a single prefix.

GET /VirtualAccount/api/v1/Prefix/{prefix}

Source

pub async fn query_transactions( &self, request: &TransQueryRequest, ) -> Result<TransQueryResponse>

Queries settled inflows (use to reconcile against your webhook records).

POST /VirtualAccount/api/v1/Trans/TransQuery

Source§

impl Client

Source

pub async fn create_wallet_with_bvn( &self, request: &CreateWalletWithBvnRequest, ) -> Result<Acknowledgement>

BVN · Step 1 — initiate wallet creation with a BVN.

Triggers an OTP to the customer’s phone. The returned Acknowledgement confirms acceptance; proceed to validate_bvn_otp.

POST /account-creation/api/CustomerAccount/PostPartnershipAccountCreationWithBvn

Source

pub async fn validate_bvn_otp( &self, request: &ValidateOtpRequest, ) -> Result<Acknowledgement>

BVN · Step 2 — validate the OTP and enqueue wallet creation.

On success the wallet is queued; the NUBAN is delivered to your callback URL. Then fetch it with get_bvn_partnership_account_details.

POST /account-creation/api/CustomerAccount/ValidateBVNandEnqueueAccountCreation

Source

pub async fn resend_bvn_otp( &self, request: &ResendOtpRequest, ) -> Result<Acknowledgement>

BVN — re-send the onboarding OTP.

POST /account-creation/api/CustomerAccount/ResendOtpRequest/ResendOtp

Source

pub async fn get_bvn_partnership_account_details( &self, phone_number: &str, ) -> Result<PartnershipAccountDetails>

BVN · Step 3 — fetch the created wallet’s details by phone number.

GET /account-creation/api/CustomerAccount/GetPartnershipAccountDetails?phoneNumber=...

Source

pub async fn set_bvn_debit_restriction( &self, request: &DebitRestrictionRequest, ) -> Result<Acknowledgement>

BVN — place or lift a debit restriction (PND) on the wallet.

POST /account-creation/api/CustomerAccount/PartnerDebitRestrictionManagement

Source

pub async fn create_wallet_with_nin( &self, request: &CreateWalletWithNinRequest, ) -> Result<Acknowledgement>

NIN · Step 1 — initiate wallet creation with a NIN.

POST /wallet-creation/api/CustomerAccount/GenerateWalletAccountForPartnerships/Request

Source

pub async fn validate_nin_otp( &self, request: &ValidateOtpRequest, ) -> Result<Acknowledgement>

NIN · Step 2 — validate the OTP and enqueue wallet creation.

POST /wallet-creation/api/CustomerAccount/GenerateWalletAccountForPartnershipsV2/Otp

Source

pub async fn resend_nin_otp( &self, request: &ResendOtpRequest, ) -> Result<Acknowledgement>

NIN — re-send the onboarding OTP.

POST /wallet-creation/api/CustomerAccount/ResendOtpRequest/ResendOtp

Source

pub async fn get_nin_partnership_account_details( &self, phone_number: &str, ) -> Result<PartnershipAccountDetails>

NIN · Step 3 — fetch the created wallet’s details by phone number.

GET /wallet-creation/api/CustomerAccount/GetPartnershipAccountDetails?phoneNumber=...

Source

pub async fn set_nin_debit_restriction( &self, request: &DebitRestrictionRequest, ) -> Result<Acknowledgement>

NIN — place or lift a debit restriction (PND) on the wallet.

POST /wallet-creation/api/CustomerAccount/PartnerDebitRestrictionManagement

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

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 Debug for Client

Source§

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

Formats the value using the given formatter. 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: Sized + 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: Sized + 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