use crate::client::Client;
use crate::envelope::ServiceResponse;
use crate::error::Result;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WalletAccountDetails {
pub wallet_number: String,
pub available_balance: String,
pub wallet_status: String,
pub account_type: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TransactionHistoryRequest {
pub account_number: String,
pub from: String,
pub to: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub key_word: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Transaction {
pub title: Option<String>,
pub amount: f64,
#[serde(rename = "type")]
pub transaction_type: Option<String>,
pub date: Option<String>,
pub transaction_date: Option<String>,
pub narration: Option<String>,
pub status: Option<String>,
pub credit_type: Option<String>,
pub sender: Option<String>,
pub sender_account_number: Option<String>,
pub destination_bank: Option<String>,
pub destination_account_number: Option<String>,
#[serde(rename = "recieverName")]
pub receiver_name: Option<String>,
pub reference_id: Option<String>,
pub is_view_receipt_enabled: Option<bool>,
pub tran_id: Option<String>,
}
impl Client {
pub async fn get_wallet_details(&self, account_number: &str) -> Result<WalletAccountDetails> {
let path = format!(
"ws-acct-mgt/api/AccountMaintenance/CustomerAccount/GetAccountV2/accountNumber/{}",
account_number
);
self.get_json::<ServiceResponse<WalletAccountDetails>>(&path, &[], &[])
.await?
.into_result()
}
pub async fn get_transaction_history(
&self,
request: &TransactionHistoryRequest,
) -> Result<Vec<Transaction>> {
self.post_json::<_, ServiceResponse<Vec<Transaction>>>(
"ws-acct-mgt/api/AccountMaintenance/CustomerAccount/transhistoryV2",
request,
&[],
)
.await?
.into_result()
}
}