sumup_rs/models/
common.rs

1use serde::{Deserialize, Serialize};
2
3// A helper for empty objects {}
4#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5pub struct EmptyObject {}
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct CardDetails {
9    pub number: String,
10    pub expiry_month: String,
11    pub expiry_year: String,
12    pub cvv: String, // Corrected from `cvc` to `cvv` to match SumUp API specification
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub name: Option<String>,
15}
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct Card {
19    pub last_4_digits: String,
20    #[serde(rename = "type")]
21    pub card_type: String,
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct Mandate {
26    #[serde(rename = "type")]
27    pub mandate_type: String,
28    pub status: String,
29    pub merchant_code: String,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct PaymentInstrumentToken {
34    pub token: String,
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
38pub struct Link {
39    pub rel: String,
40    pub href: String,
41    #[serde(rename = "type")]
42    pub link_type: String,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct PaginationParams {
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub limit: Option<i32>,
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub offset: Option<i32>,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
54pub struct PaginatedResponse<T> {
55    pub data: Vec<T>,
56    #[serde(default, skip_serializing_if = "Option::is_none")]
57    pub next_cursor: Option<String>,
58    #[serde(default, skip_serializing_if = "Option::is_none")]
59    pub prev_cursor: Option<String>,
60}