paystack/lib.rs
1//! Convenient rust bindings and types for the Paystack HTTP API aiming to support the entire API surface.
2//! Not the case? Please open an issue. I update the definitions on a weekly basis.
3//!
4//! # Documentation
5//! See the [Rust API docs](https://docs.rs/paystack-rs) or the [examples](/examples).
6//!
7//! ## Installation
8//!
9//! `paystack-rs` uses the `reqwest` http client under the hood and the `tokio` runtime for async operations
10//!
11//! ```toml
12//! [dependencies]
13//! paystack-rs = "1.5.0"
14//! ```
15//!
16//! ## Usage
17//!
18//! Initializing an instance of the Paystack client and creating a transaction.
19//!
20//! ```rust
21//! use std::env;
22//! use std::error::Error;
23//! use dotenv::dotenv;
24//! use paystack::{PaystackClient, TransactionRequestBuilder, PaystackAPIError, Currency, Channel, ReqwestClient};
25//!
26//!
27//! #[tokio::main]
28//! async fn main() -> Result<(), Box<dyn Error>> {
29//! dotenv().ok();
30//! use std::error::Error;
31//! let api_key = env::var("PAYSTACK_API_KEY").unwrap();
32//! let client = PaystackClient::<ReqwestClient>::new(api_key);
33//!
34//!
35//! let email = "email@example.com".to_string();
36//! let amount ="10000".to_string();
37//! let body = TransactionRequestBuilder::default()
38//! .amount(amount)
39//! .email(email)
40//! .currency(Currency::NGN)
41//! .channel(vec![
42//! Channel::Card,
43//! Channel::ApplePay,
44//! Channel::BankTransfer,
45//! Channel::Bank,
46//! ])
47//! .build()?;
48//!
49//! let res = client
50//! .transactions
51//! .initialize_transaction(body)
52//! .await
53//! .expect("Unable to create transaction");
54//!
55//! Ok(())
56//! }
57//! ```
58//!
59//! ## Contributing
60//!
61//! See [CONTRIBUTING.md](/CONTRIBUTING.md) for information on contributing to paystack-rs.
62//!
63// ## License
64//!
65//! Licensed under MIT license ([LICENSE-MIT](/LICENSE-MIT)).
66//!
67
68pub mod client;
69pub mod endpoints;
70pub mod errors;
71pub mod http;
72pub mod macros;
73pub mod models;
74pub mod utils;
75
76// public re-export of modules
77pub use client::*;
78pub use endpoints::*;
79pub use errors::*;
80pub use http::*;
81pub use models::*;
82pub use utils::*;
83
84/// Custom result type for the Paystack API
85pub type PaystackResult<T> = Result<Response<T>, PaystackAPIError>;