flutterwave_v3_models/api_responses/
mod.rs1pub mod custom_stat_code;
2pub use custom_stat_code::StatCode;
3
4use reqwest::StatusCode;
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Deserialize, Serialize)]
8#[serde(untagged)]
9pub enum ResponseType<T> {
10 Success(T),
11 Error(FwErrorRes)
12}
13
14impl<T:> ResponseType<T> {
15 pub fn replace_stat_code(self, status_code: StatusCode) -> Self {
16 match self {
17 ResponseType::Success(data) => ResponseType::Success(data),
18 ResponseType::Error(mut err) => {
19 err.status_code = status_code.into();
20 ResponseType::Error(err)
21 }
22 }
23 }
24}
25
26#[derive(Debug, Deserialize, Serialize)]
27pub struct ErrorResData {
28 pub code: String,
29 pub message: String,
30}
31
32#[derive(Debug, Deserialize, Serialize)]
33pub struct FwErrorRes {
34 #[serde(default)]
35 pub status_code: StatCode,
36 pub status: String,
37 pub message: String,
38 pub data: Option<ErrorResData>
39}