paystack/models/
response.rs

1//! response
2//! ========
3//! Holds the generic response templates for the API
4use crate::utils::option_string_or_number_to_u16;
5use serde::{Deserialize, Serialize};
6
7/// Generic response body template for the API
8#[derive(Clone, Debug, Serialize, Deserialize)]
9pub struct Response<T> {
10    /// This lets you know if your request was successful or not.
11    pub status: bool,
12    /// This is a summary of the response and its status.
13    pub message: String,
14    /// This contains the result of your request
15    #[serde(default)]
16    pub data: Option<T>,
17    /// This contains meta data object
18    pub meta: Option<Meta>,
19    #[serde(rename = "type")]
20    pub response_type: Option<String>,
21    pub code: Option<String>,
22}
23
24/// The Meta object is used to provide context for the contents of the data key.
25#[derive(Clone, Debug, Serialize, Deserialize, Default)]
26#[serde(rename_all = "camelCase")]
27#[serde(default)]
28pub struct Meta {
29    /// This is the total number of transactions that were performed by the customer.
30    #[serde(deserialize_with = "option_string_or_number_to_u16")]
31    pub total: Option<u16>,
32    /// This is the number of records skipped before the first record in the array returned.
33    #[serde(deserialize_with = "option_string_or_number_to_u16")]
34    pub skipped: Option<u16>,
35    /// This is the maximum number of records that will be returned per request.
36    #[serde(deserialize_with = "option_string_or_number_to_u16")]
37    pub per_page: Option<u16>,
38    /// This is the current page being returned.
39    #[serde(deserialize_with = "option_string_or_number_to_u16")]
40    pub page: Option<u16>,
41    /// This is how many pages in total are available for retrieval considering the maximum records per page specified.
42    #[serde(deserialize_with = "option_string_or_number_to_u16")]
43    pub page_count: Option<u16>,
44    pub next: Option<String>,
45    pub previous: Option<String>,
46    pub next_step: Option<String>,
47}