1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//! # async-mpesa
//!
//! The `async-mpesa` crate provides a convenient way to access
//! the mpesa api.
//!
//! The client used to call the apis is asynchronous.
//!
//! ## Making a request
//!
//! You first need to configure the client by providing the api url and key
//! by default the client is configured to use the correct url so providing your
//! own will be unnecessary.
//!
//! The access token if not provided is sourced in the `MPESA_ACCESS_TOKEN` environment variable that
//! you will need to set manually.
//! ```rust
//! let config = MpesaConfig::new()
//! .with_access_token(access_token)
//! .with_api_url(api_url);
//! ```
//!
//! A client is needed to make requests and can be used to
//! create multiple requests.
//! ```rust
//! let client = Client::with_config(config);
//! ```
//!
//! Next to create a request you need to use the specific builder method
//! for the api you are trying to access, here is an example for the stk
//! push api which is called by the `ExpressPushRequestArgs::default`
//! method.
//!
//! ```rust
//! let request = ExpressPushRequestArgs::default()
//! .PartyA("")
//! .PartyB("")
//! .Amount("")
//! .Password(shortcode, passkey, timestamp)
//! .AccountReference("")
//! .TransactionType("")
//! .BusinessShortCode("")
//! .CallbackURL("")
//! .TransactionDesc("")
//! .Timestamp("")
//! .PhoneNumber("")
//! .build()
//! .unwrap();
//! ```
//! To make a request and get a response you also need the specific method for the
//! builder method used.
//!
//! The response is deserialized into a response struct and if it fails it is deserialized
//! into the error struct using the fields names specified in the mpesa docs.
//!
//! ```rust
//! let response = client
//! .stkpush()
//! .create(request)
//! .await
//! .unwrap();
//!
//! println!("{:?}", response);
//!```
pub use Client;
pub use AccountBalance;
pub use B2C;
pub use ExpressQuery;
pub use STKPush;
pub use Qr;
pub use Reversal;
pub use SingleInvoice;
pub use Tax;
pub use TransactionStatus;
pub use Bbuygoods;
pub use Bpaybill;