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
impl Client
Sourcepub fn new(config: Config) -> Result<Self>
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.
Sourcepub fn with_subscription_key(
&self,
subscription_key: impl AsRef<str>,
) -> Result<Self>
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.
Sourcepub fn subscription_key(&self) -> &str
pub fn subscription_key(&self) -> &str
The subscription key this client currently sends.
Sourcepub fn http_client(&self) -> &Client
pub fn http_client(&self) -> &Client
Borrows the underlying reqwest::Client for advanced/custom requests.
Sourcepub async fn get_json<T>(
&self,
path: &str,
query: &[(&str, &str)],
extra_headers: &[(&'static str, String)],
) -> Result<T>where
T: DeserializeOwned,
pub async fn get_json<T>(
&self,
path: &str,
query: &[(&str, &str)],
extra_headers: &[(&'static str, String)],
) -> Result<T>where
T: DeserializeOwned,
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.
Sourcepub async fn post_json<B, T>(
&self,
path: &str,
body: &B,
extra_headers: &[(&'static str, String)],
) -> Result<T>
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
impl Client
Sourcepub async fn get_wallet_details(
&self,
account_number: &str,
) -> Result<WalletAccountDetails>
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}
Sourcepub async fn get_transaction_history(
&self,
request: &TransactionHistoryRequest,
) -> Result<Vec<Transaction>>
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
impl Client
Sourcepub async fn get_all_bills(&self) -> Result<Vec<BillCategory>>
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
Sourcepub async fn validate_customer(
&self,
request: &ValidateCustomerRequest,
) -> Result<CustomerValidation>
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
Sourcepub async fn pay_bill(&self, request: &PayBillRequest) -> Result<PaymentResult>
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
Sourcepub async fn check_bill_transaction_status(
&self,
request: &CheckTransactionStatusRequest,
) -> Result<TransactionStatus>
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
Sourcepub async fn get_data_plans(&self) -> Result<Vec<DataPlanCategory>>
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
Sourcepub async fn purchase_airtime(
&self,
request: &PurchaseAirtimeRequest,
) -> Result<PaymentResult>
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
Sourcepub async fn purchase_data(
&self,
request: &PurchaseDataRequest,
) -> Result<PaymentResult>
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
impl Client
Sourcepub async fn initiate_statement(
&self,
request: &InitiateStatementRequest,
) -> Result<String>
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
Sourcepub async fn get_statement_transactions(
&self,
request: &GetStatementRequest,
) -> Result<Vec<Transaction>>
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
impl Client
Sourcepub fn compute_transfer_hash(
&self,
salt_key: &str,
request: &TransferRequest,
) -> Result<String>
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.
Sourcepub async fn get_bank_list(&self) -> Result<Vec<Bank>>
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
Sourcepub async fn verify_account(
&self,
bank_code: &str,
account_number: &str,
channel_id: Option<&str>,
) -> Result<AccountNameEnquiry>
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}
Sourcepub async fn transfer_funds(
&self,
salt_key: &str,
request: &TransferRequest,
) -> Result<TransferResult>
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
Sourcepub async fn get_nip_charges(&self) -> Result<NipCharges>
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
impl Client
Sourcepub async fn create_prefix(&self, setup: &PrefixSetup) -> Result<String>
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
Sourcepub async fn modify_prefix(&self, setup: &PrefixSetup) -> Result<String>
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
Sourcepub async fn list_prefixes(&self) -> Result<Vec<PrefixSetup>>
pub async fn list_prefixes(&self) -> Result<Vec<PrefixSetup>>
Lists all prefixes registered for your channel.
GET /VirtualAccount/api/v1/Prefix
Sourcepub async fn get_prefix(&self, prefix: &str) -> Result<PrefixSetup>
pub async fn get_prefix(&self, prefix: &str) -> Result<PrefixSetup>
Fetches the configuration of a single prefix.
GET /VirtualAccount/api/v1/Prefix/{prefix}
Sourcepub async fn query_transactions(
&self,
request: &TransQueryRequest,
) -> Result<TransQueryResponse>
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
impl Client
Sourcepub async fn create_wallet_with_bvn(
&self,
request: &CreateWalletWithBvnRequest,
) -> Result<Acknowledgement>
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
Sourcepub async fn validate_bvn_otp(
&self,
request: &ValidateOtpRequest,
) -> Result<Acknowledgement>
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
Sourcepub async fn resend_bvn_otp(
&self,
request: &ResendOtpRequest,
) -> Result<Acknowledgement>
pub async fn resend_bvn_otp( &self, request: &ResendOtpRequest, ) -> Result<Acknowledgement>
BVN — re-send the onboarding OTP.
POST /account-creation/api/CustomerAccount/ResendOtpRequest/ResendOtp
Sourcepub async fn get_bvn_partnership_account_details(
&self,
phone_number: &str,
) -> Result<PartnershipAccountDetails>
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=...
Sourcepub async fn set_bvn_debit_restriction(
&self,
request: &DebitRestrictionRequest,
) -> Result<Acknowledgement>
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
Sourcepub async fn create_wallet_with_nin(
&self,
request: &CreateWalletWithNinRequest,
) -> Result<Acknowledgement>
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
Sourcepub async fn validate_nin_otp(
&self,
request: &ValidateOtpRequest,
) -> Result<Acknowledgement>
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
Sourcepub async fn resend_nin_otp(
&self,
request: &ResendOtpRequest,
) -> Result<Acknowledgement>
pub async fn resend_nin_otp( &self, request: &ResendOtpRequest, ) -> Result<Acknowledgement>
NIN — re-send the onboarding OTP.
POST /wallet-creation/api/CustomerAccount/ResendOtpRequest/ResendOtp
Sourcepub async fn get_nin_partnership_account_details(
&self,
phone_number: &str,
) -> Result<PartnershipAccountDetails>
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=...
Sourcepub async fn set_nin_debit_restriction(
&self,
request: &DebitRestrictionRequest,
) -> Result<Acknowledgement>
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