Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The client currently covers the following section of the API, and the sections t
- [x] Dedicated Virtual Account
- [x] Apple Pay
- [x] Subaccounts
- [x] Plans
- [ ] Plans
- [ ] Subscriptions
- [ ] Transfer Recipients
- [ ] Transfers
Expand Down
7 changes: 2 additions & 5 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//! This file contains the Paystack API client, and it associated endpoints.
use crate::{
ApplePayEndpoints, CustomersEndpoints, DedicatedVirtualAccountEndpoints, HttpClient,
PlansEndpoints, SubaccountEndpoints, TerminalEndpoints, TransactionEndpoints,
TransactionSplitEndpoints, VirtualTerminalEndpoints,
SubaccountEndpoints, TerminalEndpoints, TransactionEndpoints, TransactionSplitEndpoints,
VirtualTerminalEndpoints,
};
use std::sync::Arc;

Expand All @@ -27,8 +27,6 @@ pub struct PaystackClient<T: HttpClient + Default> {
pub dedicated_virtual_account: DedicatedVirtualAccountEndpoints<T>,
/// Apple Pay API route
pub apple_pay: ApplePayEndpoints<T>,
/// Plans API route
pub plans: PlansEndpoints<T>,
}

impl<T: HttpClient + Default> PaystackClient<T> {
Expand All @@ -47,7 +45,6 @@ impl<T: HttpClient + Default> PaystackClient<T> {
Arc::clone(&http),
),
apple_pay: ApplePayEndpoints::new(Arc::clone(&key), Arc::clone(&http)),
plans: PlansEndpoints::new(Arc::clone(&key), Arc::clone(&http)),
}
}
}
8 changes: 4 additions & 4 deletions src/endpoints/apple_pay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<T: HttpClient + Default> ApplePayEndpoints<T> {
/// # Returns
/// A new ApplePayEndpoints instance
pub fn new(key: Arc<String>, http: Arc<T>) -> ApplePayEndpoints<T> {
let base_url = format!("{PAYSTACK_BASE_URL}/apple-pay/domain");
let base_url = format!("{}/apple-pay/domain", PAYSTACK_BASE_URL);
ApplePayEndpoints {
key: key.to_string(),
base_url,
Expand All @@ -53,7 +53,7 @@ impl<T: HttpClient + Default> ApplePayEndpoints<T> {

let response = self
.http
.post(url, &self.key, &body)
.post(&url, &self.key, &body)
.await
.map_err(|e| PaystackAPIError::ApplePay(e.to_string()))?;

Expand All @@ -72,7 +72,7 @@ impl<T: HttpClient + Default> ApplePayEndpoints<T> {

let response = self
.http
.get(url, &self.key, None)
.get(&url, &self.key, None)
.await
.map_err(|e| PaystackAPIError::ApplePay(e.to_string()))?;

Expand Down Expand Up @@ -100,7 +100,7 @@ impl<T: HttpClient + Default> ApplePayEndpoints<T> {

let response = self
.http
.delete(url, &self.key, &body)
.delete(&url, &self.key, &body)
.await
.map_err(|e| PaystackAPIError::ApplePay(e.to_string()))?;

Expand Down
6 changes: 3 additions & 3 deletions src/endpoints/customers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<T: HttpClient + Default> CustomersEndpoints<T> {
/// # Returns
/// A new CustomersEndpoints instance
pub fn new(key: Arc<String>, http: Arc<T>) -> CustomersEndpoints<T> {
let base_url = format!("{PAYSTACK_BASE_URL}/customer");
let base_url = format!("{}/customer", PAYSTACK_BASE_URL);
CustomersEndpoints {
key: key.to_string(),
base_url,
Expand All @@ -57,7 +57,7 @@ impl<T: HttpClient + Default> CustomersEndpoints<T> {

let response = self
.http
.post(url, &self.key, &body)
.post(&url, &self.key, &body)
.await
.map_err(|e| PaystackAPIError::Customer(e.to_string()))?;

Expand Down Expand Up @@ -88,7 +88,7 @@ impl<T: HttpClient + Default> CustomersEndpoints<T> {

let response = self
.http
.get(url, &self.key, Some(&query))
.get(&url, &self.key, Some(&query))
.await
.map_err(|e| PaystackAPIError::Customer(e.to_string()))?;

Expand Down
17 changes: 9 additions & 8 deletions src/endpoints/dedicated_virtual_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl<T: HttpClient + Default> DedicatedVirtualAccountEndpoints<T> {
/// # Returns
/// A new DedicatedVirtualAccountEndpoints instance
pub fn new(key: Arc<String>, http: Arc<T>) -> DedicatedVirtualAccountEndpoints<T> {
let base_url = format!("{PAYSTACK_BASE_URL}/dedicated_account");
let base_url = format!("{}/dedicated_account", PAYSTACK_BASE_URL);
DedicatedVirtualAccountEndpoints {
key: key.to_string(),
base_url,
Expand All @@ -55,7 +55,7 @@ impl<T: HttpClient + Default> DedicatedVirtualAccountEndpoints<T> {

let response = self
.http
.post(url, &self.key, &body)
.post(&url, &self.key, &body)
.await
.map_err(|e| PaystackAPIError::DedicatedVirtualAccount(e.to_string()))?;

Expand Down Expand Up @@ -84,7 +84,7 @@ impl<T: HttpClient + Default> DedicatedVirtualAccountEndpoints<T> {

let response = self
.http
.post(url, &self.key, &body)
.post(&url, &self.key, &body)
.await
.map_err(|e| PaystackAPIError::DedicatedVirtualAccount(e.to_string()))?;

Expand Down Expand Up @@ -131,7 +131,7 @@ impl<T: HttpClient + Default> DedicatedVirtualAccountEndpoints<T> {
let query: Vec<(&str, &str)> = query.iter().map(|(k, v)| (*k, v.as_str())).collect();
let response = self
.http
.get(url, &self.key, Some(&query))
.get(&url, &self.key, Some(&query))
.await
.map_err(|e| PaystackAPIError::DedicatedVirtualAccount(e.to_string()))?;

Expand Down Expand Up @@ -188,8 +188,8 @@ impl<T: HttpClient + Default> DedicatedVirtualAccountEndpoints<T> {
("account_number", account_number),
("provider_slug", provider_slug),
];
if let Some(value) = date {
query.push(("date", value));
if date.is_some() {
query.push(("date", date.unwrap()));
}

// convert Vec<(&str, String)> to Vec<(&str, &str)>
Expand Down Expand Up @@ -242,6 +242,7 @@ impl<T: HttpClient + Default> DedicatedVirtualAccountEndpoints<T> {
///
/// # Returns
/// A Result containing the dedicated virtual account response data or an error

pub async fn split_dedicated_account_transaction(
&self,
split_dedocated_account_transaction_request: SplitDedicatedAccountTransactionRequest,
Expand All @@ -252,7 +253,7 @@ impl<T: HttpClient + Default> DedicatedVirtualAccountEndpoints<T> {

let response = self
.http
.post(url, &self.key, &body)
.post(&url, &self.key, &body)
.await
.map_err(|e| PaystackAPIError::DedicatedVirtualAccount(e.to_string()))?;

Expand Down Expand Up @@ -281,7 +282,7 @@ impl<T: HttpClient + Default> DedicatedVirtualAccountEndpoints<T> {

let response = self
.http
.delete(url, &self.key, &body)
.delete(&url, &self.key, &body)
.await
.map_err(|e| PaystackAPIError::DedicatedVirtualAccount(e.to_string()))?;

Expand Down
2 changes: 0 additions & 2 deletions src/endpoints/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod apple_pay;
pub mod customers;
pub mod dedicated_virtual_account;
pub mod plans;
pub mod subaccount;
pub mod terminal;
pub mod transaction;
Expand All @@ -12,7 +11,6 @@ pub mod virtual_terminal;
pub use apple_pay::*;
pub use customers::*;
pub use dedicated_virtual_account::*;
pub use plans::*;
pub use subaccount::*;
pub use terminal::*;
pub use transaction::*;
Expand Down
167 changes: 0 additions & 167 deletions src/endpoints/plans.rs

This file was deleted.

6 changes: 3 additions & 3 deletions src/endpoints/subaccount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::sync::Arc;
pub struct SubaccountEndpoints<T: HttpClient + Default> {
/// Paystack API Key
key: String,
/// Base URL for the subaccount route
/// Base URL for the transaction route
base_url: String,
/// Http client for the route
http: Arc<T>,
Expand All @@ -31,7 +31,7 @@ impl<T: HttpClient + Default> SubaccountEndpoints<T> {
/// # Returns
/// A new SubaccountEndpoints instance
pub fn new(key: Arc<String>, http: Arc<T>) -> SubaccountEndpoints<T> {
let base_url = format!("{PAYSTACK_BASE_URL}/subaccount");
let base_url = format!("{}/subaccount", PAYSTACK_BASE_URL);
SubaccountEndpoints {
key: key.to_string(),
base_url,
Expand All @@ -57,7 +57,7 @@ impl<T: HttpClient + Default> SubaccountEndpoints<T> {

let response = self
.http
.post(url, &self.key, &body)
.post(&url, &self.key, &body)
.await
.map_err(|e| PaystackAPIError::Subaccount(e.to_string()))?;

Expand Down
Loading