flutterwave_v3_models/payment_plans/
create_plan.rs

1use super::{Interval, PlanApiRes};
2use serde::{Deserialize, Serialize};
3use validator::Validate;
4use std::borrow::Cow;
5use crate::{
6    common::payload::Payload,
7    fwcall::{FwCall, ToFwCall},
8};
9
10#[derive(Debug, Serialize, Deserialize, Validate)]
11pub struct CreatePlanReq {
12    pub amount: i32,
13    pub name: String,
14    pub interval: Interval,
15    pub duration: Option<i32>,
16}
17
18impl<'a> ToFwCall<'a> for CreatePlanReq {
19    type ApiRequest = Self;
20
21    type ApiResponse = PlanApiRes;
22
23    fn get_call(self) -> FwCall<'a, Self::ApiRequest, Self::ApiResponse> {
24        FwCall::new(
25            Cow::Borrowed("/v3/payment-plans"),
26            reqwest::Method::POST,
27            Some(Payload::Plain(self)),
28        )
29    }
30}