async_mpesa/
stkpush.rs

1use crate::{
2    client::Client,
3    config::Config,
4    error::MpesaError,
5    types::{ExpressPushRequest, ExpressPushResponse}
6};
7
8/// Client to call the stkpush API
9pub struct STKPush<'m, C: Config> {
10    client: &'m Client<C>,
11}
12
13impl <'m, C: Config> STKPush<'m, C> {
14    pub fn new(client: &'m Client<C>) -> Self {
15        Self { client }
16    }
17
18    /// Creates a request for the provided parameters
19    pub async fn create(
20        &self,
21        request: ExpressPushRequest,
22    ) -> Result<ExpressPushResponse, MpesaError> {
23        self.client.post("/mpesa/stkpush/v1/processrequest", request).await
24    }
25}