1use crate::{
5 CustomersEndpoints, HttpClient, SubaccountEndpoints, TerminalEndpoints, TransactionEndpoints,
6 TransactionSplitEndpoints, VirtualTerminalEndpoints,
7};
8use std::sync::Arc;
9
10pub struct PaystackClient<T: HttpClient + Default> {
13 pub transactions: TransactionEndpoints<T>,
15 pub transaction_split: TransactionSplitEndpoints<T>,
17 pub subaccount: SubaccountEndpoints<T>,
19 pub terminal: TerminalEndpoints<T>,
21 pub virutal_terminal: VirtualTerminalEndpoints<T>,
23 pub customers: CustomersEndpoints<T>,
25}
26
27impl<T: HttpClient + Default> PaystackClient<T> {
28 pub fn new(api_key: String) -> PaystackClient<T> {
29 let http = Arc::new(T::default());
30 let key = Arc::new(api_key);
31 PaystackClient {
32 transactions: TransactionEndpoints::new(Arc::clone(&key), Arc::clone(&http)),
33 transaction_split: TransactionSplitEndpoints::new(Arc::clone(&key), Arc::clone(&http)),
34 subaccount: SubaccountEndpoints::new(Arc::clone(&key), Arc::clone(&http)),
35 terminal: TerminalEndpoints::new(Arc::clone(&key), Arc::clone(&http)),
36 virutal_terminal: VirtualTerminalEndpoints::new(Arc::clone(&key), Arc::clone(&http)),
37 customers: CustomersEndpoints::new(Arc::clone(&key), Arc::clone(&http)),
38 }
39 }
40}