paystack/
lib.rs

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