paymentlib/nswcpp/jsonb/
component.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use chrono::NaiveDateTime;

use serde::{Deserialize, Serialize};

use crate::nswcpp::enums::card_type::CardType;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct Component {
    pub settlement_date: NaiveDateTime,
    pub card_type: Vec<CardType>,
    pub expiry_date: String,
    pub start_digits: String,
    pub end_digits: String,
    pub receipt_text: String,
    pub component_type: String,
}

impl Component {
    pub fn normalize(&self) -> Component {
        Component {
            settlement_date: self.settlement_date,
            card_type: self.card_type.clone(),
            expiry_date: self.expiry_date.clone(),
            start_digits: self.start_digits.clone(),
            end_digits: self.end_digits.clone(),
            receipt_text: self.receipt_text.clone(),
            component_type: self.component_type.clone(),
        }
    }
}