From 80098279e82ffad24b3384c994f1e64e920c4686 Mon Sep 17 00:00:00 2001 From: Oghenemarho Date: Tue, 21 Oct 2025 21:07:36 +0200 Subject: [PATCH] Revert "feat(plan): Added support for the plan API endpoint." --- README.md | 2 +- src/client.rs | 7 +- src/endpoints/apple_pay.rs | 8 +- src/endpoints/customers.rs | 6 +- src/endpoints/dedicated_virtual_account.rs | 17 +- src/endpoints/mod.rs | 2 - src/endpoints/plans.rs | 167 ------------- src/endpoints/subaccount.rs | 6 +- src/endpoints/terminal.rs | 6 +- src/endpoints/transaction.rs | 6 +- src/endpoints/transaction_split.rs | 8 +- src/endpoints/virtual_terminal.rs | 8 +- src/errors.rs | 2 - src/models/bearer_models.rs | 2 +- src/models/channel_models.rs | 2 +- src/models/currency_models.rs | 12 +- src/models/customer_models.rs | 8 +- src/models/domain_models.rs | 29 --- src/models/mod.rs | 4 - src/models/plans_models.rs | 191 -------------- src/models/split_models.rs | 2 +- src/models/status_models.rs | 4 +- src/models/subaccount_models.rs | 4 +- src/models/subscription_models.rs | 44 +--- src/models/terminal_models.rs | 8 +- src/models/transaction_split_models.rs | 4 +- src/models/virtual_terminal_models.rs | 8 +- src/utils.rs | 42 +--- tests/api/customer.rs | 4 +- tests/api/main.rs | 1 - tests/api/plans.rs | 276 --------------------- tests/api/subaccount.rs | 4 +- tests/api/transaction_split.rs | 2 +- 33 files changed, 66 insertions(+), 830 deletions(-) delete mode 100644 src/endpoints/plans.rs delete mode 100644 src/models/domain_models.rs delete mode 100644 src/models/plans_models.rs delete mode 100644 tests/api/plans.rs diff --git a/README.md b/README.md index 9d5b983..f2a7dbc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/client.rs b/src/client.rs index 51fe13f..f39f88d 100644 --- a/src/client.rs +++ b/src/client.rs @@ -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; @@ -27,8 +27,6 @@ pub struct PaystackClient { pub dedicated_virtual_account: DedicatedVirtualAccountEndpoints, /// Apple Pay API route pub apple_pay: ApplePayEndpoints, - /// Plans API route - pub plans: PlansEndpoints, } impl PaystackClient { @@ -47,7 +45,6 @@ impl PaystackClient { Arc::clone(&http), ), apple_pay: ApplePayEndpoints::new(Arc::clone(&key), Arc::clone(&http)), - plans: PlansEndpoints::new(Arc::clone(&key), Arc::clone(&http)), } } } diff --git a/src/endpoints/apple_pay.rs b/src/endpoints/apple_pay.rs index 69385d8..0866046 100644 --- a/src/endpoints/apple_pay.rs +++ b/src/endpoints/apple_pay.rs @@ -27,7 +27,7 @@ impl ApplePayEndpoints { /// # Returns /// A new ApplePayEndpoints instance pub fn new(key: Arc, http: Arc) -> ApplePayEndpoints { - 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, @@ -53,7 +53,7 @@ impl ApplePayEndpoints { let response = self .http - .post(url, &self.key, &body) + .post(&url, &self.key, &body) .await .map_err(|e| PaystackAPIError::ApplePay(e.to_string()))?; @@ -72,7 +72,7 @@ impl ApplePayEndpoints { let response = self .http - .get(url, &self.key, None) + .get(&url, &self.key, None) .await .map_err(|e| PaystackAPIError::ApplePay(e.to_string()))?; @@ -100,7 +100,7 @@ impl ApplePayEndpoints { let response = self .http - .delete(url, &self.key, &body) + .delete(&url, &self.key, &body) .await .map_err(|e| PaystackAPIError::ApplePay(e.to_string()))?; diff --git a/src/endpoints/customers.rs b/src/endpoints/customers.rs index 98f158d..b39b69d 100644 --- a/src/endpoints/customers.rs +++ b/src/endpoints/customers.rs @@ -31,7 +31,7 @@ impl CustomersEndpoints { /// # Returns /// A new CustomersEndpoints instance pub fn new(key: Arc, http: Arc) -> CustomersEndpoints { - let base_url = format!("{PAYSTACK_BASE_URL}/customer"); + let base_url = format!("{}/customer", PAYSTACK_BASE_URL); CustomersEndpoints { key: key.to_string(), base_url, @@ -57,7 +57,7 @@ impl CustomersEndpoints { let response = self .http - .post(url, &self.key, &body) + .post(&url, &self.key, &body) .await .map_err(|e| PaystackAPIError::Customer(e.to_string()))?; @@ -88,7 +88,7 @@ impl CustomersEndpoints { 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()))?; diff --git a/src/endpoints/dedicated_virtual_account.rs b/src/endpoints/dedicated_virtual_account.rs index bc4755e..e53a244 100644 --- a/src/endpoints/dedicated_virtual_account.rs +++ b/src/endpoints/dedicated_virtual_account.rs @@ -29,7 +29,7 @@ impl DedicatedVirtualAccountEndpoints { /// # Returns /// A new DedicatedVirtualAccountEndpoints instance pub fn new(key: Arc, http: Arc) -> DedicatedVirtualAccountEndpoints { - 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, @@ -55,7 +55,7 @@ impl DedicatedVirtualAccountEndpoints { let response = self .http - .post(url, &self.key, &body) + .post(&url, &self.key, &body) .await .map_err(|e| PaystackAPIError::DedicatedVirtualAccount(e.to_string()))?; @@ -84,7 +84,7 @@ impl DedicatedVirtualAccountEndpoints { let response = self .http - .post(url, &self.key, &body) + .post(&url, &self.key, &body) .await .map_err(|e| PaystackAPIError::DedicatedVirtualAccount(e.to_string()))?; @@ -131,7 +131,7 @@ impl DedicatedVirtualAccountEndpoints { 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()))?; @@ -188,8 +188,8 @@ impl DedicatedVirtualAccountEndpoints { ("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)> @@ -242,6 +242,7 @@ impl DedicatedVirtualAccountEndpoints { /// /// # 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, @@ -252,7 +253,7 @@ impl DedicatedVirtualAccountEndpoints { let response = self .http - .post(url, &self.key, &body) + .post(&url, &self.key, &body) .await .map_err(|e| PaystackAPIError::DedicatedVirtualAccount(e.to_string()))?; @@ -281,7 +282,7 @@ impl DedicatedVirtualAccountEndpoints { let response = self .http - .delete(url, &self.key, &body) + .delete(&url, &self.key, &body) .await .map_err(|e| PaystackAPIError::DedicatedVirtualAccount(e.to_string()))?; diff --git a/src/endpoints/mod.rs b/src/endpoints/mod.rs index 71093e9..2138151 100644 --- a/src/endpoints/mod.rs +++ b/src/endpoints/mod.rs @@ -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; @@ -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::*; diff --git a/src/endpoints/plans.rs b/src/endpoints/plans.rs deleted file mode 100644 index b4fad1d..0000000 --- a/src/endpoints/plans.rs +++ /dev/null @@ -1,167 +0,0 @@ -use std::{marker::PhantomData, sync::Arc}; - -use super::PAYSTACK_BASE_URL; -use crate::{ - HttpClient, Interval, PaystackAPIError, PaystackResult, PlanRequest, PlanResponseData, - PlanStatus, PlanUpdateRequest, Response, -}; - -pub struct PlansEndpoints { - /// Paystack API Key - key: String, - /// Base URL for the plans route - base_url: String, - /// Http client for the route - http: Arc, -} - -/// Create a new `PlansEndpoints` instance -/// -/// # Arguments -/// - `key` - The Paystack API key -/// - `http`: The HTTP client implementation to use for the API requests -/// -/// # Returns -/// A new PlansEndpoints instance -impl PlansEndpoints { - pub fn new(key: Arc, http: Arc) -> PlansEndpoints { - let base_url = format!("{PAYSTACK_BASE_URL}/plan"); - PlansEndpoints { - key: key.to_string(), - base_url, - http, - } - } - - /// Create a plan on your integration - /// - /// # Arguments - /// * `plan_request` - The request data to create the plan. - /// Should be created with a `PlanRequestBuilder` struct. - /// - /// # Returns - /// A Result containing the plan response data or an error - pub async fn create_plan(&self, plan_request: PlanRequest) -> PaystackResult { - let url = &self.base_url; - let body = serde_json::to_value(plan_request) - .map_err(|e| PaystackAPIError::Plan(e.to_string()))?; - - let response = self - .http - .post(url, &self.key, &body) - .await - .map_err(|e| PaystackAPIError::Plan(e.to_string()))?; - - let parsed_response: Response = - serde_json::from_str(&response).map_err(|e| PaystackAPIError::Plan(e.to_string()))?; - - Ok(parsed_response) - } - - /// Lists plans available in your integration - /// - /// # Arguments - /// * `per_page` - specify how many records you want to retrieve per page. Defaults to 50 if None - /// * `page` - specify exactly what page you want to retrieve. Defaults to 1 if None - /// * `status` - Optional parameter to filter list by plans with specified status - /// * `interval` - Optional parameter to filter list by plans with specified interval - /// * `amount`- Optional parameter to filter list by plans with specified amount using the supported currency - /// - /// # Returns - /// A Result containing a vector of plan response data or an error - pub async fn list_plans( - &self, - per_page: Option, - page: Option, - status: Option, - interval: Option, - amount: Option, - ) -> PaystackResult> { - let url = &self.base_url; - - let per_page = per_page.unwrap_or(50).to_string(); - let page = page.unwrap_or(1).to_string(); - - let mut query = vec![("perPage", per_page), ("page", page)]; - - // Process optional parameters - if let Some(s) = status { - query.push(("status", s.to_string())); - } - - if let Some(i) = interval { - query.push(("interval", i.to_string())); - } - - if let Some(a) = amount { - query.push(("amount", a.to_string())); - } - - // convert all string to &str - // TODO: there has to be a cleaner way of doing this - 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)) - .await - .map_err(|e| PaystackAPIError::Plan(e.to_string()))?; - - let parsed_response: Response> = - serde_json::from_str(&response).map_err(|e| PaystackAPIError::Plan(e.to_string()))?; - - Ok(parsed_response) - } - - /// Get details of a plan on your integration - /// - /// # Arguments - /// * `id_or_code` - the plan `ID` or `code` you want to fetch - /// - /// # Returns - /// A Result containing the plan response data or an error - pub async fn fetch_plan(&self, id_or_code: String) -> PaystackResult { - let url = format!("{}/{}", &self.base_url, id_or_code); - - let response = self - .http - .get(&url, &self.key, None) - .await - .map_err(|e| PaystackAPIError::Plan(e.to_string()))?; - - let parsed_response: Response = - serde_json::from_str(&response).map_err(|e| PaystackAPIError::Plan(e.to_string()))?; - - Ok(parsed_response) - } - - /// Update a plan details on your integration - /// - /// # Arguments - /// * `id_or_code` - the plan `ID` or `code` you want to update - /// * `plan_update_request` - The request data to update the plan with. - /// Should be created with a `PlanUpdateRequestBuilder` struct. - /// - /// # Returns - /// A Result containing a success message if the plan has been updated - pub async fn update_plan( - &self, - id_or_code: String, - plan_update_request: PlanUpdateRequest, - ) -> PaystackResult> { - let url = format!("{}/{}", self.base_url, id_or_code); - let body = serde_json::to_value(plan_update_request) - .map_err(|e| PaystackAPIError::Plan(e.to_string()))?; - - let response = self - .http - .put(&url, &self.key, &body) - .await - .map_err(|e| PaystackAPIError::Plan(e.to_string()))?; - - let parsed_response: Response> = - serde_json::from_str(&response).map_err(|e| PaystackAPIError::Plan(e.to_string()))?; - - Ok(parsed_response) - } -} diff --git a/src/endpoints/subaccount.rs b/src/endpoints/subaccount.rs index ae72446..b821a04 100644 --- a/src/endpoints/subaccount.rs +++ b/src/endpoints/subaccount.rs @@ -15,7 +15,7 @@ use std::sync::Arc; pub struct SubaccountEndpoints { /// 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, @@ -31,7 +31,7 @@ impl SubaccountEndpoints { /// # Returns /// A new SubaccountEndpoints instance pub fn new(key: Arc, http: Arc) -> SubaccountEndpoints { - let base_url = format!("{PAYSTACK_BASE_URL}/subaccount"); + let base_url = format!("{}/subaccount", PAYSTACK_BASE_URL); SubaccountEndpoints { key: key.to_string(), base_url, @@ -57,7 +57,7 @@ impl SubaccountEndpoints { let response = self .http - .post(url, &self.key, &body) + .post(&url, &self.key, &body) .await .map_err(|e| PaystackAPIError::Subaccount(e.to_string()))?; diff --git a/src/endpoints/terminal.rs b/src/endpoints/terminal.rs index b08943e..ec1aff1 100644 --- a/src/endpoints/terminal.rs +++ b/src/endpoints/terminal.rs @@ -16,7 +16,7 @@ use super::PAYSTACK_BASE_URL; pub struct TerminalEndpoints { /// Paystack API Key key: String, - /// Base URL for the terminal route + /// Base URL for the transaction route base_url: String, /// Http client for the route http: Arc, @@ -32,7 +32,7 @@ impl TerminalEndpoints { /// # Returns /// A new TerminalEndpoints instance pub fn new(key: Arc, http: Arc) -> TerminalEndpoints { - let base_url = format!("{PAYSTACK_BASE_URL}/terminal"); + let base_url = format!("{}/terminal", PAYSTACK_BASE_URL); TerminalEndpoints { key: key.to_string(), base_url, @@ -137,7 +137,7 @@ impl TerminalEndpoints { let response = self .http - .get(url, &self.key, Some(&query)) + .get(&url, &self.key, Some(&query)) .await .map_err(|e| PaystackAPIError::Terminal(e.to_string()))?; diff --git a/src/endpoints/transaction.rs b/src/endpoints/transaction.rs index 5aabfd2..f588340 100644 --- a/src/endpoints/transaction.rs +++ b/src/endpoints/transaction.rs @@ -32,7 +32,7 @@ impl TransactionEndpoints { /// # Returns /// A new TransactionEndpoints instance pub fn new(key: Arc, http: Arc) -> TransactionEndpoints { - let base_url = format!("{PAYSTACK_BASE_URL}/transaction"); + let base_url = format!("{}/transaction", PAYSTACK_BASE_URL); TransactionEndpoints { key: key.to_string(), base_url, @@ -113,7 +113,7 @@ impl TransactionEndpoints { let response = self .http - .get(url, &self.key, Some(&query)) + .get(&url, &self.key, Some(&query)) .await .map_err(|e| PaystackAPIError::Transaction(e.to_string()))?; @@ -152,7 +152,7 @@ impl TransactionEndpoints { /// /// # Arguments /// * `charge_request` - The charge request data containing authorization details. - /// Should be created with the `ChargeRequestBuilder` struct. + /// Should be created with the `ChargeRequestBuilder` struct. /// /// # Returns /// A Result containing the charge response data or an error diff --git a/src/endpoints/transaction_split.rs b/src/endpoints/transaction_split.rs index ca99684..fda13f9 100644 --- a/src/endpoints/transaction_split.rs +++ b/src/endpoints/transaction_split.rs @@ -15,7 +15,7 @@ use std::sync::Arc; pub struct TransactionSplitEndpoints { /// Paystack API Key key: String, - /// Base URL for the transaction split route + /// Base URL for the transaction route base_url: String, /// Http client for the route http: Arc, @@ -31,7 +31,7 @@ impl TransactionSplitEndpoints { /// # Returns /// A new TransactionSplitEndpoints instance pub fn new(key: Arc, http: Arc) -> TransactionSplitEndpoints { - let base_url = format!("{PAYSTACK_BASE_URL}/split"); + let base_url = format!("{}/split", PAYSTACK_BASE_URL); TransactionSplitEndpoints { key: key.to_string(), base_url, @@ -57,7 +57,7 @@ impl TransactionSplitEndpoints { let response = self .http - .post(url, &self.key, &body) + .post(&url, &self.key, &body) .await .map_err(|e| PaystackAPIError::TransactionSplit(e.to_string()))?; @@ -95,7 +95,7 @@ impl TransactionSplitEndpoints { let response = self .http - .get(url, &self.key, Some(&query)) + .get(&url, &self.key, Some(&query)) .await .map_err(|e| PaystackAPIError::TransactionSplit(e.to_string()))?; diff --git a/src/endpoints/virtual_terminal.rs b/src/endpoints/virtual_terminal.rs index 8bbe4e2..6c8e2aa 100644 --- a/src/endpoints/virtual_terminal.rs +++ b/src/endpoints/virtual_terminal.rs @@ -15,7 +15,7 @@ use std::{marker::PhantomData, sync::Arc}; pub struct VirtualTerminalEndpoints { /// Paystack API key key: String, - /// Base URL for the virtual terminal route + /// Base URL for the transaction route base_url: String, /// Http client for the route http: Arc, @@ -31,7 +31,7 @@ impl VirtualTerminalEndpoints { /// # Returns /// A new VirtualTerminalEndpoints instance pub fn new(key: Arc, http: Arc) -> VirtualTerminalEndpoints { - let base_url = format!("{PAYSTACK_BASE_URL}/virtual_terminal"); + let base_url = format!("{}/virtual_terminal", PAYSTACK_BASE_URL); VirtualTerminalEndpoints { key: key.to_string(), base_url, @@ -57,7 +57,7 @@ impl VirtualTerminalEndpoints { let response = self .http - .post(url, &self.key, &body) + .post(&url, &self.key, &body) .await .map_err(|e| PaystackAPIError::VirtualTerminal(e.to_string()))?; @@ -89,7 +89,7 @@ impl VirtualTerminalEndpoints { let response = self .http - .get(url, &self.key, Some(&query)) + .get(&url, &self.key, Some(&query)) .await .map_err(|e| PaystackAPIError::VirtualTerminal(e.to_string()))?; diff --git a/src/errors.rs b/src/errors.rs index f4e2473..6a280d0 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -35,6 +35,4 @@ pub enum PaystackAPIError { DedicatedVirtualAccount(String), #[error("Apple Pay Error: {0}")] ApplePay(String), - #[error("Plan Error: {0}")] - Plan(String), } diff --git a/src/models/bearer_models.rs b/src/models/bearer_models.rs index f0c626d..9558069 100644 --- a/src/models/bearer_models.rs +++ b/src/models/bearer_models.rs @@ -55,6 +55,6 @@ impl fmt::Display for BearerType { BearerType::AllProportional => "all-proportional", BearerType::All => "all", }; - write!(f, "{lowercase_string}") + write!(f, "{}", lowercase_string) } } diff --git a/src/models/channel_models.rs b/src/models/channel_models.rs index eaee198..3b12ca3 100644 --- a/src/models/channel_models.rs +++ b/src/models/channel_models.rs @@ -71,6 +71,6 @@ impl fmt::Display for Channel { Channel::BankTransfer => "bank_transfer", Channel::ApplePay => "mobile_money", }; - write!(f, "{lower_case}") + write!(f, "{}", lower_case) } } diff --git a/src/models/currency_models.rs b/src/models/currency_models.rs index b87fc14..67ce305 100644 --- a/src/models/currency_models.rs +++ b/src/models/currency_models.rs @@ -18,8 +18,6 @@ use std::fmt; /// - `GHS`: Ghanaian Cedis. /// - `USD`: American Dollar. /// - `ZAR`: South African Rands. -/// - `KES`: Kenya Shilling. -/// - `XOF`: West African CFA Franc. /// - `EMPTY`: Used when the currency can be empty. /// /// # Examples @@ -31,8 +29,6 @@ use std::fmt; /// let ghs = Currency::GHS; /// let usd = Currency::USD; /// let zar = Currency::ZAR; -/// let kes = Currency::KES; -/// let xof = Currency::XOF; /// let empty = Currency::EMPTY; /// /// println!("{:?}", ngn); // Prints: NGN @@ -51,10 +47,6 @@ pub enum Currency { USD, /// South African Rands ZAR, - /// Kenya Shilling - KES, - /// West African CFA Franc - XOF, /// Used when currency can be empty. EMPTY, } @@ -66,10 +58,8 @@ impl fmt::Display for Currency { Currency::GHS => "GHS", Currency::USD => "USD", Currency::ZAR => "ZAR", - Currency::KES => "KES", - Currency::XOF => "XOF", Currency::EMPTY => "", }; - write!(f, "{currency}") + write!(f, "{}", currency) } } diff --git a/src/models/customer_models.rs b/src/models/customer_models.rs index f5e6e7b..f898a10 100644 --- a/src/models/customer_models.rs +++ b/src/models/customer_models.rs @@ -3,8 +3,6 @@ use std::fmt; use derive_builder::Builder; use serde::{Deserialize, Serialize}; -use crate::Domain; - use super::{Authorization, Subscription, TransactionStatusData}; /// This struct represents the Paystack customer data @@ -12,7 +10,7 @@ use super::{Authorization, Subscription, TransactionStatusData}; pub struct CustomerResponseData { pub id: u64, pub integration: Option, - pub domain: Option, + pub domain: Option, pub identified: Option, pub first_name: Option, pub last_name: Option, @@ -112,7 +110,7 @@ impl fmt::Display for IdentificationType { let identification_type = match self { IdentificationType::BankAccount => "bank_account", }; - write!(f, "{identification_type}") + write!(f, "{}", identification_type) } } @@ -132,7 +130,7 @@ impl fmt::Display for RiskAction { RiskAction::Default => "default", RiskAction::Deny => "deny", }; - write!(f, "{risk_action}") + write!(f, "{}", risk_action) } } diff --git a/src/models/domain_models.rs b/src/models/domain_models.rs deleted file mode 100644 index 5aeffaa..0000000 --- a/src/models/domain_models.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! Domain -//! ====== -//! This file constians the domain options for the integration in the paystack API. - -use std::fmt; - -use serde::{Deserialize, Serialize}; - -/// An enum of options for the paystack integration domain -#[derive(Debug, Serialize, Deserialize, Clone, Default)] -#[serde(rename_all = "lowercase")] -pub enum Domain { - /// Integration in the test environment - // Defaulting to test here for less danger - #[default] - Test, - /// Integration in the live environment - Live, -} - -impl fmt::Display for Domain { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let domain = match self { - Domain::Test => "test", - Domain::Live => "live", - }; - write!(f, "{domain}") - } -} diff --git a/src/models/mod.rs b/src/models/mod.rs index e6d238c..13b7358 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -6,8 +6,6 @@ pub mod charge_models; pub mod currency_models; pub mod customer_models; pub mod dedicated_virtual_account_models; -pub mod domain_models; -pub mod plans_models; pub mod response_models; pub mod split_models; pub mod status_models; @@ -27,8 +25,6 @@ pub use charge_models::*; pub use currency_models::*; pub use customer_models::*; pub use dedicated_virtual_account_models::*; -pub use domain_models::*; -pub use plans_models::*; pub use response_models::*; pub use split_models::*; pub use status_models::*; diff --git a/src/models/plans_models.rs b/src/models/plans_models.rs deleted file mode 100644 index 5bc7b82..0000000 --- a/src/models/plans_models.rs +++ /dev/null @@ -1,191 +0,0 @@ -//! Plans Models -//! ============= -//! This file contains the models and options for the Plans endpoint of the Paystack API - -use std::fmt; - -use derive_builder::Builder; -use serde::{Deserialize, Serialize}; - -use crate::utils::string_or_number_to_u32; -use crate::{Currency, Domain, Subscription}; - -/// Request body to create a plan on your integration. -/// Should be created via `PlanRequestBuilder` -#[derive(Clone, Default, Debug, Serialize, Deserialize, Builder)] -pub struct PlanRequest { - /// Name of plan - pub name: String, - /// Amount for the plan. Should be in the subunit of the supported currency - pub amount: String, - /// Interval in words, Use the `Interval` Enum for valid options. - pub interval: Interval, - /// A description of this plan - #[builder(setter(strip_option))] - #[serde(skip_serializing_if = "Option::is_none")] - pub description: Option, - /// Set to false if you don't want invoices to be sent to your customers - #[builder(setter(strip_option), default)] - #[serde(skip_serializing_if = "Option::is_none")] - pub send_invoices: Option, - /// Set to false if you don't want text messages to be sent to your customers - // NB: docs says string, but should be bool. - #[builder(setter(strip_option), default)] - #[serde(skip_serializing_if = "Option::is_none")] - pub send_sms: Option, - /// Currency in which the amount is set. - /// Defaults to the Default Currency of the integration - #[builder(setter(strip_option), default)] - #[serde(skip_serializing_if = "Option::is_none")] - pub currency: Option, - /// Number of invoices to raise during subscription to this plan. - /// Can be overridden by specifying an `invoice_limit` while subscribing. - #[builder(setter(strip_option), default)] - #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_limit: Option, -} - -/// Options for the different payment intervals for plans supported by the paystack API. -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq)] -#[serde(rename_all = "lowercase")] -pub enum Interval { - Daily, - Weekly, - #[default] - Monthly, - Quarterly, - /// Every 6 months - Biannually, - Annually, -} - -impl fmt::Display for Interval { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let interval = match self { - Interval::Daily => "daily", - Interval::Weekly => "weekly", - Interval::Monthly => "monthly", - Interval::Quarterly => "quarterly", - Interval::Biannually => "biannually", - Interval::Annually => "annually", - }; - write!(f, "{interval}") - } -} - -// TODO: figure out the the other plan status -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq)] -#[serde(rename_all = "lowercase")] -#[non_exhaustive] -pub enum PlanStatus { - #[default] - Active, - Archived, - Deleted, -} - -impl fmt::Display for PlanStatus { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let plan_status = match self { - PlanStatus::Active => "Active", - PlanStatus::Archived => "Archived", - PlanStatus::Deleted => "Deleted", - }; - write!(f, "{plan_status}") - } -} - -/// Request body to update a plan on your integration. -/// Should be created via `PlanUpdateRequestBuilder` -#[derive(Debug, Clone, Default, Serialize, Deserialize, Builder)] -#[builder(setter(strip_option), default)] -pub struct PlanUpdateRequest { - /// Name of plan - #[serde(skip_serializing_if = "Option::is_none")] - pub name: Option, - /// Amount for the plan. Should be in the subunit of the supported currency - #[serde(skip_serializing_if = "Option::is_none")] - pub amount: Option, - /// Interval in words, Use the `Interval` Enum for valid options. - #[serde(skip_serializing_if = "Option::is_none")] - pub interval: Option, - /// A description of this plan - #[serde(skip_serializing_if = "Option::is_none")] - pub description: Option, - /// Set to false if you don't want invoices to be sent to your customers - #[serde(skip_serializing_if = "Option::is_none")] - pub send_invoices: Option, - /// Set to false if you don't want text messages to be sent to your customers - #[serde(skip_serializing_if = "Option::is_none")] - pub send_sms: Option, - /// Currency in which the amount is set. - #[serde(skip_serializing_if = "Option::is_none")] - pub currency: Option, - /// Number of invoices to raise during subscription to this plan. - #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_limit: Option, - /// Set to `true` if you want the existing subscriptions to use the new changes - /// Set to `false` and only new subscriptions will be changed. - /// Defaults to true when not set. - #[serde(skip_serializing_if = "Option::is_none")] - pub update_existing_subscriptions: Option, -} - -/// This struct represents the data of the create plan response. -#[derive(Clone, Debug, Serialize, Deserialize, Default)] -pub struct PlanResponseData { - pub subscriptions: Option>, - pub name: String, - #[serde(deserialize_with = "string_or_number_to_u32")] - pub amount: u32, - pub interval: Interval, - pub integration: u32, - pub domain: Domain, - pub plan_code: String, - pub description: Option, - pub send_invoices: Option, - pub send_sms: bool, - pub hosted_page: bool, - pub hosted_page_url: Option, - pub hosted_page_summary: Option, - pub currency: Currency, - pub id: u32, - #[serde(rename = "createdAt")] - pub created_at: String, - #[serde(rename = "updatedAt")] - pub updated_at: String, -} - -#[cfg(test)] -mod tests { - use super::*; - use std::error::Error; - - #[test] - fn can_create_plan_request_with_builder() -> Result<(), Box> { - let plan = PlanRequestBuilder::default() - .name("test plan".to_string()) - .amount("100000".to_string()) - .interval(Interval::Monthly) - .description("some description".to_string()) - .build()?; - - assert_eq!(plan.name, "test plan"); - assert_eq!(plan.amount, "100000"); - assert_eq!(plan.interval, Interval::Monthly); - assert_eq!(plan.description, Some("some description".to_string())); - - Ok(()) - } - - #[test] - fn cannot_create_plan_request_without_compulsory_field() -> Result<(), Box> { - let plan = PlanRequestBuilder::default() - .currency(Currency::XOF) - .build(); - - assert!(plan.is_err()); - - Ok(()) - } -} diff --git a/src/models/split_models.rs b/src/models/split_models.rs index f2d38f5..292b620 100644 --- a/src/models/split_models.rs +++ b/src/models/split_models.rs @@ -44,6 +44,6 @@ impl fmt::Display for SplitType { SplitType::Percentage => "percentage", SplitType::Flat => "flat", }; - write!(f, "{lowercase_string}") + write!(f, "{}", lowercase_string) } } diff --git a/src/models/status_models.rs b/src/models/status_models.rs index 24aecf2..d494379 100644 --- a/src/models/status_models.rs +++ b/src/models/status_models.rs @@ -1,6 +1,6 @@ //! Status //! =============== -//! This file contains the status options for the transactions in the paystack API. +//! This file contains the status options for the paystack API. use serde::{Deserialize, Serialize}; use std::fmt; @@ -48,6 +48,6 @@ impl fmt::Display for Status { Status::Abandoned => "abandoned", Status::Failed => "failed", }; - write!(f, "{lowercase_string}") + write!(f, "{}", lowercase_string) } } diff --git a/src/models/subaccount_models.rs b/src/models/subaccount_models.rs index 9ed416b..3ddb4e8 100644 --- a/src/models/subaccount_models.rs +++ b/src/models/subaccount_models.rs @@ -3,7 +3,7 @@ //! This file contains the models for working with the subaccounts endpoint. use super::Currency; -use crate::{utils::bool_from_int_or_bool, Domain}; +use crate::utils::bool_from_int_or_bool; use derive_builder::Builder; use serde::{Deserialize, Serialize}; @@ -80,7 +80,7 @@ pub struct SubaccountsResponseData { /// Integration ID of subaccount. pub integration: Option, /// Subaccount domain. - pub domain: Option, + pub domain: Option, /// The code of the subaccount. pub subaccount_code: String, /// The name of the business associated with the subaccount. diff --git a/src/models/subscription_models.rs b/src/models/subscription_models.rs index 4ab2393..93380bb 100644 --- a/src/models/subscription_models.rs +++ b/src/models/subscription_models.rs @@ -1,46 +1,4 @@ -use std::fmt; - use serde::{Deserialize, Serialize}; -use crate::{Authorization, Domain}; - #[derive(Debug, Clone, Deserialize, Serialize, Default)] -pub struct Subscription { - pub customer: u32, - pub plan: u32, - pub integration: u32, - pub domain: Domain, - pub start: u32, - pub status: SubscriptionStatus, - pub quantity: u32, - pub amount: u32, - pub subscription_code: String, - pub email_token: String, - pub authorization: Authorization, - pub easy_cron_id: Option, - pub cron_expression: String, - pub next_payment_date: String, - pub open_invoice: Option, - pub id: u32, - #[serde(rename = "createdAt")] - pub created_at: String, - #[serde(rename = "updatedAt")] - pub updated_at: String, -} - -#[derive(Debug, Clone, Serialize, Deserialize, Default)] -#[serde(rename_all = "lowercase")] -#[non_exhaustive] -pub enum SubscriptionStatus { - #[default] - Complete, -} - -impl fmt::Display for SubscriptionStatus { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let status = match self { - SubscriptionStatus::Complete => "complete", - }; - write!(f, "{status}") - } -} +pub struct Subscription {} diff --git a/src/models/terminal_models.rs b/src/models/terminal_models.rs index 016af78..a65f614 100644 --- a/src/models/terminal_models.rs +++ b/src/models/terminal_models.rs @@ -6,8 +6,6 @@ use derive_builder::Builder; use serde::{Deserialize, Serialize}; use std::fmt; -use crate::Domain; - /// The request body to send an event from your application to the Paystack Terminal #[derive(Debug, Clone, Builder, Serialize, Deserialize)] pub struct EventRequest { @@ -56,7 +54,7 @@ impl fmt::Display for TerminalAction { TerminalAction::Print => "print", TerminalAction::View => "view", }; - write!(f, "{action}") + write!(f, "{}", action) } } @@ -66,7 +64,7 @@ impl fmt::Display for EventType { EventType::Invoice => "invoice", EventType::Transaction => "transaction", }; - write!(f, "{event}") + write!(f, "{}", event) } } @@ -108,7 +106,7 @@ pub struct TerminalData { pub device_make: Option, pub terminal_id: String, pub integration: u64, - pub domain: Domain, + pub domain: String, pub name: String, pub address: Option, pub status: String, diff --git a/src/models/transaction_split_models.rs b/src/models/transaction_split_models.rs index 4b02cfd..101b88f 100644 --- a/src/models/transaction_split_models.rs +++ b/src/models/transaction_split_models.rs @@ -2,7 +2,7 @@ //! ======================== //! This file contains the models for working with the transaction splits endpoint. -use crate::{BearerType, Currency, Domain, SplitType, SubaccountBody, SubaccountData}; +use crate::{BearerType, Currency, SplitType, SubaccountBody, SubaccountData}; use derive_builder::Builder; use serde::{Deserialize, Serialize}; @@ -40,7 +40,7 @@ pub struct TransactionSplitResponseData { /// The integration associated with the percentage split. pub integration: u32, /// The domain associated with the percentage split. - pub domain: Domain, + pub domain: String, /// The split code of the percentage split. pub split_code: String, /// Indicates whether the percentage split is active or not. diff --git a/src/models/virtual_terminal_models.rs b/src/models/virtual_terminal_models.rs index 1f3c460..56725ca 100644 --- a/src/models/virtual_terminal_models.rs +++ b/src/models/virtual_terminal_models.rs @@ -3,8 +3,6 @@ use std::fmt; use derive_builder::Builder; use serde::{Deserialize, Serialize}; -use crate::Domain; - use super::Currency; #[derive(Debug, Serialize, Deserialize, Clone, Builder, Default)] @@ -49,7 +47,7 @@ pub struct VirtualTerminalResponseData { pub id: u64, pub name: String, pub integration: u64, - pub domain: Domain, + pub domain: String, pub code: String, pub payment_methods: Option>, pub active: bool, @@ -86,7 +84,7 @@ impl fmt::Display for VirtualTerminalStatus { VirtualTerminalStatus::Active => "active", VirtualTerminalStatus::Inactive => "inactive", }; - write!(f, "{lowercase_string}") + write!(f, "{}", lowercase_string) } } @@ -131,7 +129,7 @@ mod tests { .expect("unable to build virtual terminal request"); assert_eq!(request.name, "Some name"); - assert!(!request.destinations.is_empty()); + assert!(request.destinations.len() > 0); assert!(request.currency.is_some()); assert!(request.custom_field.is_some()); assert!(request.metadata.is_none()); diff --git a/src/utils.rs b/src/utils.rs index cd5db09..c9834e6 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -31,7 +31,7 @@ where if v <= u8::MAX as u64 { Ok(v as u8) } else { - Err(E::custom(format!("u64 value {v} is out of range for u8"))) + Err(E::custom(format!("u64 value {} is out of range for u8", v))) } } } @@ -66,42 +66,10 @@ where if v <= u16::MAX as u64 { Ok(v as u16) } else { - Err(E::custom(format!("u64 value {v} is out of range for u16"))) - } - } - } - - deserializer.deserialize_any(StringOrNumberVisitor) -} - -pub fn string_or_number_to_u32<'de, D>(deserializer: D) -> Result -where - D: serde::Deserializer<'de>, -{ - struct StringOrNumberVisitor; - - impl<'de> serde::de::Visitor<'de> for StringOrNumberVisitor { - type Value = u32; - - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - formatter.write_str("a string or an integer") - } - - fn visit_str(self, v: &str) -> Result - where - E: Error, - { - u32::from_str(v).map_err(serde::de::Error::custom) - } - - fn visit_u64(self, v: u64) -> Result - where - E: Error, - { - if v <= u32::MAX as u64 { - Ok(v as u32) - } else { - Err(E::custom(format!("u64 value {v} is out of range for u32"))) + Err(E::custom(format!( + "u64 value {} is out of range for u16", + v + ))) } } } diff --git a/tests/api/customer.rs b/tests/api/customer.rs index a41e852..acdb847 100644 --- a/tests/api/customer.rs +++ b/tests/api/customer.rs @@ -62,7 +62,7 @@ async fn can_list_customers_in_integration() { // Assert assert!(res.status); assert!(res.message.contains("Customers retrieved")); - assert!(!res.data.unwrap().is_empty()); + assert!(res.data.unwrap().len() > 0); } #[tokio::test] @@ -80,7 +80,7 @@ async fn can_list_customers_in_integration_with_defaults() { // Assert assert!(res.status); assert!(res.message.contains("Customers retrieved")); - assert!(!res.data.unwrap().is_empty()); + assert!(res.data.unwrap().len() > 0); } #[tokio::test] diff --git a/tests/api/main.rs b/tests/api/main.rs index 7481f50..81740fa 100644 --- a/tests/api/main.rs +++ b/tests/api/main.rs @@ -3,7 +3,6 @@ pub mod charge; pub mod customer; pub mod dedicated_virtual_account; pub mod helpers; -pub mod plans; pub mod subaccount; pub mod terminal; pub mod transaction; diff --git a/tests/api/plans.rs b/tests/api/plans.rs deleted file mode 100644 index ef4ffb0..0000000 --- a/tests/api/plans.rs +++ /dev/null @@ -1,276 +0,0 @@ -use fake::{ - faker::{lorem::en::Sentence, name::en::Name}, - Fake, -}; -use paystack::{Interval, PlanRequestBuilder, PlanUpdateRequestBuilder}; -use rand::Rng; - -use crate::helpers::get_paystack_client; - -#[tokio::test] -async fn create_plan_valid() { - // Arrange - let client = get_paystack_client(); - let mut rng = rand::thread_rng(); - - // Act - let name: String = Name().fake(); - let amount: String = rng.gen_range(100..=100_000).to_string(); - let interval = Interval::Monthly; - let description: String = Sentence(4..10).fake(); - let body = PlanRequestBuilder::default() - .name(name.clone()) - .interval(interval.clone()) - .amount(amount) - .description(description) - .build() - .unwrap(); - - let res = client - .plans - .create_plan(body) - .await - .expect("unable to create plan"); - - // Assert - assert!(res.status); - assert_eq!("Plan created", res.message); - let data = res.data.unwrap(); - assert_eq!(&data.name, &name); - assert_eq!(&data.interval, &interval); -} - -#[tokio::test] -async fn create_plan_fails_when_currency_is_not_supported_by_merchant() { - // Arrange - let client = get_paystack_client(); - let mut rng = rand::thread_rng(); - - // Act - let name: String = Name().fake(); - let amount: String = rng.gen_range(100..=100_000).to_string(); - let interval = Interval::Monthly; - let description: String = Sentence(4..10).fake(); - let body = PlanRequestBuilder::default() - .name(name.clone()) - .interval(interval.clone()) - .amount(amount) - .description(description) - // TODO: change this if your integration supports this currency - .currency(paystack::Currency::ZAR) - .build() - .unwrap(); - - let res = client.plans.create_plan(body).await; - - // Assert - if let Err(e) = res { - let res = e.to_string(); - assert!(res.contains("status code: 400 Bad Request")); - } -} - -#[tokio::test] -async fn can_list_all_plans_in_the_integration_with_defaults() { - // Arrange - let client = get_paystack_client(); - - // Act - let res = client - .plans - .list_plans(None, None, None, None, None) - .await - .expect("unable to list plans in the integration"); - - // Assert - assert!(res.status); - assert_eq!(res.message, "Plans retrieved"); -} - -#[tokio::test] -async fn can_fetch_plan_with_id() { - // Arrange - let client = get_paystack_client(); - let mut rng = rand::thread_rng(); - // create plan - let name: String = Name().fake(); - let amount: String = rng.gen_range(100..=100_000).to_string(); - let interval = Interval::Monthly; - let description: String = Sentence(4..10).fake(); - let body = PlanRequestBuilder::default() - .name(name.clone()) - .interval(interval.clone()) - .amount(amount) - .description(description) - .build() - .unwrap(); - - let plan = client - .plans - .create_plan(body) - .await - .expect("unable to create plan"); - - // Act - let plan_id = plan.data.unwrap().id.to_string(); - let res = client - .plans - .fetch_plan(plan_id.clone()) - .await - .expect("unable to fetch plan with {id}"); - - // Assert - assert!(res.status); - assert_eq!(res.message, "Plan retrieved"); - assert_eq!(res.data.unwrap().id.to_string(), plan_id); -} - -#[tokio::test] -async fn can_fetch_plan_with_code() { - // Arrange - let client = get_paystack_client(); - let mut rng = rand::thread_rng(); - // create plan - let name: String = Name().fake(); - let amount: String = rng.gen_range(100..=100_000).to_string(); - let interval = Interval::Monthly; - let description: String = Sentence(4..10).fake(); - let body = PlanRequestBuilder::default() - .name(name.clone()) - .interval(interval.clone()) - .amount(amount) - .description(description) - .build() - .unwrap(); - - let plan = client - .plans - .create_plan(body) - .await - .expect("unable to create plan"); - - // Act - let plan_code = plan.data.unwrap().plan_code.to_string(); - let res = client - .plans - .fetch_plan(plan_code.clone()) - .await - .expect("unable to fetch plan with {code}"); - - // Assert - assert!(res.status); - assert_eq!(res.message, "Plan retrieved"); - assert_eq!(res.data.unwrap().plan_code.to_string(), plan_code); -} - -#[tokio::test] -async fn can_modify_plan_with_plan_code() { - // Arrange - let client = get_paystack_client(); - let mut rng = rand::thread_rng(); - // create plan - let name: String = Name().fake(); - let amount: String = rng.gen_range(100..=100_000).to_string(); - let interval = Interval::Monthly; - let description: String = Sentence(4..10).fake(); - let body = PlanRequestBuilder::default() - .name(name.clone()) - .interval(interval.clone()) - .amount(amount) - .description(description) - .build() - .unwrap(); - - let plan = client - .plans - .create_plan(body) - .await - .expect("unable to create plan"); - - // Act - // modify plan - let new_name: String = Name().fake(); - let new_amount: String = rng.gen_range(100..=100_000).to_string(); - let update_request = PlanUpdateRequestBuilder::default() - .name(new_name) - .amount(new_amount) - .build() - .unwrap(); - - let plan_data = plan.data.unwrap(); - let plan_code = plan_data.plan_code.clone().to_string(); - let res = client - .plans - .update_plan(plan_code.clone(), update_request) - .await - .expect("unable to update plan with code"); - - let updated_plan = client - .plans - .fetch_plan(plan_code.clone()) - .await - .expect("unable to fetch plan with {code}"); - - // Assert - let updated_plan_data = updated_plan.data.unwrap(); - assert!(res.status); - assert!(res.message.contains("Plan updated.")); - assert_ne!(plan_data.name, updated_plan_data.name); - assert_ne!(plan_data.amount, updated_plan_data.amount); -} - -#[tokio::test] -async fn can_modify_plan_with_plan_id() { - // Arrange - let client = get_paystack_client(); - let mut rng = rand::thread_rng(); - // create plan - let name: String = Name().fake(); - let amount: String = rng.gen_range(100..=100_000).to_string(); - let interval = Interval::Monthly; - let description: String = Sentence(4..10).fake(); - let body = PlanRequestBuilder::default() - .name(name.clone()) - .interval(interval.clone()) - .amount(amount) - .description(description) - .build() - .unwrap(); - - let plan = client - .plans - .create_plan(body) - .await - .expect("unable to create plan"); - - // Act - // modify plan - let new_name: String = Name().fake(); - let new_amount: String = rng.gen_range(100..=100_000).to_string(); - let update_request = PlanUpdateRequestBuilder::default() - .name(new_name) - .amount(new_amount) - .build() - .unwrap(); - - let plan_data = plan.data.unwrap(); - let plan_id = plan_data.id.clone().to_string(); - let res = client - .plans - .update_plan(plan_id.clone(), update_request) - .await - .expect("unable to update plan with code"); - - let updated_plan = client - .plans - .fetch_plan(plan_id.clone()) - .await - .expect("unable to fetch plan with {code}"); - - // Assert - let updated_plan_data = updated_plan.data.unwrap(); - assert!(res.status); - assert!(res.message.contains("Plan updated.")); - assert_ne!(plan_data.name, updated_plan_data.name); - assert_ne!(plan_data.amount, updated_plan_data.amount); -} diff --git a/tests/api/subaccount.rs b/tests/api/subaccount.rs index 6bba47b..d3d65da 100644 --- a/tests/api/subaccount.rs +++ b/tests/api/subaccount.rs @@ -53,7 +53,7 @@ async fn list_all_subaccounts_in_the_integration() { // Assert assert!(res.status); assert_eq!(res.message, "Subaccounts retrieved"); - assert!(!res.data.unwrap().is_empty()); + assert!(res.data.unwrap().len() > 0); } #[tokio::test] @@ -69,7 +69,7 @@ async fn fetch_subaccount() { .expect("unable to get exisiting subaccounts"); let sub_account_data = sub_account.data.unwrap(); assert!( - !sub_account_data.is_empty(), + sub_account_data.len() > 0, "No exisiting subaccounts, create one and try again" ); diff --git a/tests/api/transaction_split.rs b/tests/api/transaction_split.rs index e266428..52c88ab 100644 --- a/tests/api/transaction_split.rs +++ b/tests/api/transaction_split.rs @@ -143,7 +143,7 @@ async fn list_transaction_splits_in_the_integration() { let data = res.data.unwrap(); assert!(res.status); assert_eq!(res.message, "Split retrieved".to_string()); - assert!(!data.is_empty()); + assert!(data.len() > 0); let transaction_split = data.first().unwrap(); assert_eq!(