paystack/client.rs
1//! Client
2//! ===========
3//! The file for the Paystack API client and it's associated functions
4use crate::{
5 SubaccountEndpoints, TerminalEndpoints, TransactionEndpoints, TransactionSplitEndpoints,
6};
7
8/// This is the struct that allows you to authenticate to the PayStack API.
9/// It contains the API key which allows you to interact with the API.
10pub struct PaystackClient<'a> {
11 /// Transaction API route
12 pub transaction: TransactionEndpoints<'a>,
13 /// Transaction Split API route
14 pub transaction_split: TransactionSplitEndpoints<'a>,
15 /// Subaccount API route
16 pub subaccount: SubaccountEndpoints<'a>,
17 /// Terminal API route
18 pub terminal: TerminalEndpoints<'a>,
19}
20
21impl<'a> PaystackClient<'a> {
22 /// This method creates a new PayStack client with the specified API key.
23 ///
24 /// It takes the following parameters:
25 /// - key: Paystack API key.
26 pub fn new(key: &'a str) -> PaystackClient<'a> {
27 PaystackClient {
28 transaction: TransactionEndpoints::new(key),
29 transaction_split: TransactionSplitEndpoints::new(key),
30 subaccount: SubaccountEndpoints::new(key),
31 terminal: TerminalEndpoints::new(key),
32 }
33 }
34}