Skip to content

Commit cd320d1

Browse files
authored
feat: added support for the dedicated virtual account api endpoint
feat: added support for the dedicated virtual account api endpoint
2 parents 2c7b330 + 8e49151 commit cd320d1

17 files changed

Lines changed: 784 additions & 147 deletions

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Build
22
on:
33
push:
4-
branches: ["main", "master", "dev"]
4+
branches: ["dev"]
55
env:
66
CARGO_TERM_COLOR: always
77
PAYSTACK_API_KEY: ${{secrets.PAYSTACK_API_KEY}}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The client currently covers the following section of the API, and the sections t
1818
- [x] Terminal
1919
- [x] Virtual Terminal
2020
- [x] Customers
21-
- [ ] Dedicated Virtual Account
21+
- [x] Dedicated Virtual Account
2222
- [ ] Apple Pay
2323
- [ ] Subaccounts
2424
- [ ] Plans

src/client.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//! =========
33
//! This file contains the Paystack API client, and it associated endpoints.
44
use crate::{
5-
CustomersEndpoints, HttpClient, SubaccountEndpoints, TerminalEndpoints, TransactionEndpoints,
6-
TransactionSplitEndpoints, VirtualTerminalEndpoints,
5+
CustomersEndpoints, DedicatedVirtualAccountEndpoints, HttpClient, SubaccountEndpoints,
6+
TerminalEndpoints, TransactionEndpoints, TransactionSplitEndpoints, VirtualTerminalEndpoints,
77
};
88
use std::sync::Arc;
99

@@ -22,6 +22,8 @@ pub struct PaystackClient<T: HttpClient + Default> {
2222
pub virutal_terminal: VirtualTerminalEndpoints<T>,
2323
/// Customers API route
2424
pub customers: CustomersEndpoints<T>,
25+
/// Dedicated Virtual Account API route
26+
pub dedicated_virtual_account: DedicatedVirtualAccountEndpoints<T>,
2527
}
2628

2729
impl<T: HttpClient + Default> PaystackClient<T> {
@@ -35,6 +37,10 @@ impl<T: HttpClient + Default> PaystackClient<T> {
3537
terminal: TerminalEndpoints::new(Arc::clone(&key), Arc::clone(&http)),
3638
virutal_terminal: VirtualTerminalEndpoints::new(Arc::clone(&key), Arc::clone(&http)),
3739
customers: CustomersEndpoints::new(Arc::clone(&key), Arc::clone(&http)),
40+
dedicated_virtual_account: DedicatedVirtualAccountEndpoints::new(
41+
Arc::clone(&key),
42+
Arc::clone(&http),
43+
),
3844
}
3945
}
4046
}

src/endpoints/customers.rs

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ pub struct CustomersEndpoints<T: HttpClient + Default> {
2323
}
2424

2525
impl<T: HttpClient + Default> CustomersEndpoints<T> {
26-
/// Constructor
26+
/// Creates a new CustomersEndpoints instance
27+
///
28+
/// # Arguments
29+
/// * `key` - The Paystack API key
30+
/// * `http` - The HTTP client implementation to use for API requests
31+
///
32+
/// # Returns
33+
/// A new CustomersEndpoints instance
2734
pub fn new(key: Arc<String>, http: Arc<T>) -> CustomersEndpoints<T> {
2835
let base_url = String::from("https://api.paystack.co/customer");
2936
CustomersEndpoints {
@@ -35,9 +42,12 @@ impl<T: HttpClient + Default> CustomersEndpoints<T> {
3542

3643
/// Create customer on your integration
3744
///
38-
/// It takes the following parameters:
39-
/// - create_customer_request: contains the information about the customer to be created.
40-
/// It should be built with `CreateCustomerRequestBuilder`.
45+
/// # Arguments
46+
/// * `create_customer_request` - Contains the information about the customer to be created.
47+
/// It should be built with `CreateCustomerRequestBuilder`.
48+
///
49+
/// # Returns
50+
/// A Result containing the customer response data or an error
4151
pub async fn create_customer(
4252
&self,
4353
create_customer_request: CreateCustomerRequest,
@@ -60,11 +70,14 @@ impl<T: HttpClient + Default> CustomersEndpoints<T> {
6070
}
6171
}
6272

63-
/// List customers available on your integration
73+
/// Lists customers available on your integration
6474
///
65-
/// It takes the following parameters:
66-
/// - `per_page`: Specify how many records you want to retreive per page. If not specified, default value of 50.
67-
/// - `page`: Specify exactly waht page you want to retreive. If not specified, default value of 1.
75+
/// # Arguments
76+
/// * `per_page` - Optional number of records to retrieve per page. Default is 50
77+
/// * `page` - Optional page number to retrieve. Default is 1
78+
///
79+
/// # Returns
80+
/// A Result containing a vector of customer response data or an error
6881
pub async fn list_customers(
6982
&self,
7083
per_page: Option<u8>,
@@ -90,10 +103,13 @@ impl<T: HttpClient + Default> CustomersEndpoints<T> {
90103
}
91104
}
92105

93-
/// Get details of a customer on your integration.
106+
/// Gets details of a customer on your integration
107+
///
108+
/// # Arguments
109+
/// * `email_or_code` - Email or customer code for the customer to fetch
94110
///
95-
/// It takes the following parameters:
96-
/// - `email_or_code`: An `email`or `customer code` for the customer you want to fetch.
111+
/// # Returns
112+
/// A Result containing the customer response data or an error
97113
pub async fn fetch_customer(
98114
&self,
99115
email_or_code: String,
@@ -114,12 +130,15 @@ impl<T: HttpClient + Default> CustomersEndpoints<T> {
114130
}
115131
}
116132

117-
/// Update a customer's details on your integration
133+
/// Updates a customer's details on your integration
118134
///
119-
/// It takes the following parameters:
120-
/// - `customer_code`: The customer's code
121-
/// - `update_customer_request`: The data to update the customer with.
122-
/// It should be created with the `UpdateCustomerRequestBuilder` struct.
135+
/// # Arguments
136+
/// * `customer_code` - The customer's code
137+
/// * `update_customer_request` - The data to update the customer with.
138+
/// Should be created with the UpdateCustomerRequestBuilder struct
139+
///
140+
/// # Returns
141+
/// A Result containing the updated customer response data or an error
123142
pub async fn update_customer(
124143
&self,
125144
customer_code: String,
@@ -143,12 +162,15 @@ impl<T: HttpClient + Default> CustomersEndpoints<T> {
143162
}
144163
}
145164

146-
/// Validate a customer's identity
165+
/// Validates a customer's identity
166+
///
167+
/// # Arguments
168+
/// * `customer_code` - Email or customer code of customer to be identified
169+
/// * `customer_validation_request` - The data to validate the customer with.
170+
/// Should be created with the ValidateCustomerRequestBuilder struct
147171
///
148-
/// It takes in the following parameters:
149-
/// - `customer_code`: email, or customer code of customer to be identified.
150-
/// - `customer_validation_request`: The data to validate the customer with.
151-
/// It should be created with the `ValidateCustomerRequestBuilder` struct.
172+
/// # Returns
173+
/// A Result containing the validation response or an error
152174
pub async fn validate_customer(
153175
&self,
154176
customer_code: String,
@@ -172,11 +194,14 @@ impl<T: HttpClient + Default> CustomersEndpoints<T> {
172194
}
173195
}
174196

175-
/// Whitelist or blacklist a customer on your integration
197+
/// Whitelists or blacklists a customer on your integration
176198
///
177-
/// It takes in the following parameters:
178-
/// - `customer_code`: Customer's code, or email address.
179-
/// - `risk_action`: One of the possible risk actions for the customer.
199+
/// # Arguments
200+
/// * `customer_code` - Customer's code or email address
201+
/// * `risk_action` - The risk action to apply to the customer
202+
///
203+
/// # Returns
204+
/// A Result containing the updated customer response data or an error
180205
pub async fn whitelist_or_blacklist_customer(
181206
&self,
182207
customer_code: String,
@@ -202,10 +227,13 @@ impl<T: HttpClient + Default> CustomersEndpoints<T> {
202227
}
203228
}
204229

205-
/// Deactivate an authorization when the card needs to be forgotten
230+
/// Deactivates an authorization when the card needs to be forgotten
231+
///
232+
/// # Arguments
233+
/// * `authorization_code` - Authorization code to be deactivated
206234
///
207-
/// It takes the following parameters:
208-
/// - `authorization_code`: Authorization code to be deactivated.
235+
/// # Returns
236+
/// A Result containing the deactivation response or an error
209237
pub async fn deactivate_authorization(
210238
&self,
211239
authorization_code: String,

0 commit comments

Comments
 (0)