Skip to content

Commit

Permalink
feat - fix conflicting feature docs and add new feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
c12i committed Jun 11, 2021
1 parent 96805df commit b744706
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ An unofficial Rust wrapper around the [Safaricom API](https://developer.safarico

```toml
[dependencies]
mpesa = "0.3.6"
mpesa = "0.3.7"
```

Optionally, you can disable default-features, which is basically the entire suite of MPESA APIs to conditionally select from either `["b2b", "b2c", "account_balance"]` services, which make use of `openssl` and `base64` dependencies that can be opted out of compilation if not required.
Optionally, you can disable default-features, which is basically the entire suite of MPESA APIs to conditionally select from either `["b2b", "b2c" ,"account_balance", "c2b_register", "c2b_simulate", "express_request"]` services.
Example:

```toml
[dependencies]
mpesa = { version = "0.3.6", default_features = false, features = ["b2b"] }
mpesa = { version = "0.3.7", default_features = false, features = ["b2b", "express_request"] }
```

In your lib or binary crate:
Expand Down
23 changes: 10 additions & 13 deletions mpesa_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mpesa"
version = "0.3.6"
version = "0.3.7"
authors = ["Collins Muriuki <murerwacollins@gmail.com>"]
edition = "2018"
description = "A wrapper around the M-PESA API in Rust."
Expand All @@ -13,6 +13,8 @@ license = "MIT"
serde_json = "1.0"
dotenv = "0.15.0"
mpesa_derive = "0.2.1"
openssl = "0.10.30"
base64 = "0.12.3"
failure = "0.1.5"
failure_derive = "0.1.5"
chrono = "0.4"
Expand All @@ -25,16 +27,11 @@ features = ["blocking", "json"]
version = "1.0.114"
features = ["derive"]

[dependencies.openssl]
version = "0.10.30"
optional = true

[dependencies.base64]
version = "0.12.3"
optional = true

[features]
default = ["b2b", "b2c" ,"account_balance"]
account_balance = ["openssl", "base64"]
b2c = ["openssl", "base64"]
b2b = ["openssl", "base64"]
default = ["b2b", "b2c" ,"account_balance", "c2b_register", "c2b_simulate", "express_request"]
b2b = []
b2c = []
account_balance = []
c2b_register = []
c2b_simulate = []
express_request = []
3 changes: 3 additions & 0 deletions mpesa_core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ impl<'a> Mpesa {
/// .response_type(mpesa::ResponseTypes::Complete) // optional, defaults to `ResponseTypes::Complete`
/// .send();
/// ```
#[cfg(feature = "c2b_register")]
pub fn c2b_register(&'a self) -> C2bRegisterBuilder<'a> {
C2bRegisterBuilder::new(&self)
}
Expand All @@ -202,6 +203,7 @@ impl<'a> Mpesa {
/// .bill_ref_number("Your_BillRefNumber>") // optional, defaults to "None"
/// .send();
/// ```
#[cfg(feature = "c2b_simulate")]
pub fn c2b_simulate(&'a self) -> C2bSimulateBuilder<'a> {
C2bSimulateBuilder::new(&self)
}
Expand Down Expand Up @@ -250,6 +252,7 @@ impl<'a> Mpesa {
/// .transaction_desc("Description") // Optional, defaults to "None"
/// .send();
/// ```
#[cfg(feature = "express_request")]
pub fn express_request(
&'a self,
business_short_code: &'a str,
Expand Down
7 changes: 4 additions & 3 deletions mpesa_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
//!
//! ```toml
//! [dependencies]
//! mpesa = "0.3.6"
//! mpesa = "0.3.7"
//! ```
//! Optionally, you can disable default-features, which is basically the entire suite of MPESA APIs to conditionally select from either `["b2b", "b2c", "account_balance"]` services, which make use of `openssl` and `base64` dependencies that can be opted out of compilation if not required.
//! Optionally, you can disable default-features, which is basically the entire suite of MPESA APIs to conditionally select from either `["b2b", "b2c" ,"account_balance", "c2b_register", "c2b_simulate", "express_request"]` services.
//! Example:
//!
//! ```toml
//! [dependencies]
//! mpesa = { version = "0.3.6", default_features = false, features = ["b2b"] }
//! mpesa = { version = "0.3.7", default_features = false, features = ["b2b", "express_request"] }
//! ```
//!
//! In your lib or binary crate:
Expand Down

0 comments on commit b744706

Please sign in to comment.