Skip to content

Commit 4bb998c

Browse files
committed
feat: added support for fetching supported bank providers
1 parent bfff1c7 commit 4bb998c

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

src/endpoints/dedicated_virtual_account.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use std::{marker::PhantomData, sync::Arc};
77
use serde_json::json;
88

99
use crate::{
10-
DedicatedVirtualAccountRequest, DedicatedVirtualAccountResponseData, HttpClient,
11-
ListDedicatedAccountFilter, PaystackAPIError, PaystackResult, Response,
10+
BankProviderData, DedicatedVirtualAccountRequest, DedicatedVirtualAccountResponseData,
11+
HttpClient, ListDedicatedAccountFilter, PaystackAPIError, PaystackResult, Response,
1212
SplitDedicatedAccountTransactionRequest,
1313
};
1414

@@ -303,4 +303,28 @@ impl<T: HttpClient + Default> DedicatedVirtualAccountEndpoints<T> {
303303
Err(e) => Err(PaystackAPIError::DedicatedVirtualAccount(e.to_string())),
304304
}
305305
}
306+
307+
/// Get available bank providers for a dedicated virtual account
308+
///
309+
/// # Arguments
310+
/// None
311+
///
312+
/// # Returns
313+
/// A Result containing a vector of bank provider data or an error
314+
pub async fn fetch_bank_providers(&self) -> PaystackResult<Vec<BankProviderData>> {
315+
let url = format!("{}/available_providers", self.base_url);
316+
317+
let response = self.http.get(&url, &self.key, None).await;
318+
319+
match response {
320+
Ok(response) => {
321+
let parsed_response: Response<Vec<BankProviderData>> =
322+
serde_json::from_str(&response)
323+
.map_err(|e| PaystackAPIError::DedicatedVirtualAccount(e.to_string()))?;
324+
325+
Ok(parsed_response)
326+
}
327+
Err(e) => Err(PaystackAPIError::DedicatedVirtualAccount(e.to_string())),
328+
}
329+
}
306330
}

src/models/dedicated_virtual_account.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ pub struct Assignment {
8181
pub assinged_at: String,
8282
}
8383

84+
#[derive(Debug, Clone, Deserialize, Serialize)]
85+
pub struct BankProviderData {
86+
pub provider_slug: String,
87+
pub bank_id: u64,
88+
pub bank_name: String,
89+
pub id: u64,
90+
}
91+
8492
#[derive(Clone, Debug, Deserialize, Serialize, Default, Builder)]
8593
pub struct ListDedicatedAccountFilter {
8694
/// Status of the dedicated virtual account

0 commit comments

Comments
 (0)