flutterwave_v3_models/payment_plans/
update_plan.rs1use std::borrow::Cow;
2
3use crate::{
4 common::payload::Payload,
5 fwcall::{FwCall, ToFwCall},
6};
7use serde::{Deserialize, Serialize};
8use validator::Validate;
9use super::PlanApiRes;
10
11#[derive(Debug, Serialize, Deserialize, Validate)]
12pub struct UpdatePlanReq {
13 pub id: i32,
14 pub body: UpdatePlanReqBody
15}
16
17#[derive(Debug, Serialize, Deserialize, Validate, Default)]
18pub struct UpdatePlanReqBody {
19 pub name: String,
20 pub status: PlanStatus,
21}
22
23#[derive(Debug, Serialize, Deserialize, Default)]
24pub enum PlanStatus {
25 #[default]
26 Active,
27 Inactive,
28}
29
30impl<'a> ToFwCall<'a> for UpdatePlanReq {
31 type ApiRequest = UpdatePlanReqBody;
32
33 type ApiResponse = PlanApiRes;
34
35 fn get_call(self) -> FwCall<'a, Self::ApiRequest, Self::ApiResponse> {
36 FwCall::new(
37 Cow::Owned(format!("/v3/payment-plans/{}", self.id)),
38 reqwest::Method::PUT,
39 Some(Payload::Plain(self.body)),
40 )
41 }
42}