pub struct Fpx;
impl Fpx {
pub const STATUS_NEW: i32 = 0;
pub const STATUS_PENDING: i32 = 1;
pub const STATUS_FAILED: i32 = 2;
pub const STATUS_SUCCESS: i32 = 3;
pub const STATUS_CANCELLED: i32 = 4;
pub fn status_text(status_code: i32) -> &'static str {
match status_code {
Self::STATUS_NEW => "New",
Self::STATUS_PENDING => "Pending",
Self::STATUS_CANCELLED => "Cancelled",
Self::STATUS_SUCCESS => "Successful",
Self::STATUS_FAILED => "Failed",
_ => "UNKNOWN STATUS",
}
}
}
pub struct FpxDirectDebit;
impl FpxDirectDebit {
pub const ENROLMENT: &'static str = "01";
pub const MAINTENANCE: &'static str = "02";
pub const TERMINATION: &'static str = "03";
pub const NRIC: i32 = 1;
pub const OLD_IC: i32 = 2;
pub const PASSPORT: i32 = 3;
pub const BUSINESS_REGISTRATION: i32 = 4;
pub const OTHERS: i32 = 5;
pub const MODE_DAILY: &'static str = "DL";
pub const MODE_WEEKLY: &'static str = "WK";
pub const MODE_MONTHLY: &'static str = "MT";
pub const MODE_YEARLY: &'static str = "YR";
pub const STATUS_NEW: i32 = 0;
pub const STATUS_WAITING_APPROVAL: i32 = 1;
pub const STATUS_FAILED_BANK_VERIFICATION: i32 = 2;
pub const STATUS_ACTIVE: i32 = 3;
pub const STATUS_TERMINATED: i32 = 4;
pub const STATUS_APPROVED: i32 = 5;
pub const STATUS_REJECTED: i32 = 6;
pub const STATUS_CANCELLED: i32 = 7;
pub const STATUS_ERROR: i32 = 8;
pub fn status_text(status_code: i32) -> &'static str {
match status_code {
Self::STATUS_NEW => "New",
Self::STATUS_WAITING_APPROVAL => "Waiting Approval",
Self::STATUS_FAILED_BANK_VERIFICATION => "Bank Verification Failed",
Self::STATUS_APPROVED => "Approved",
Self::STATUS_REJECTED => "Rejected",
Self::STATUS_CANCELLED => "Cancelled",
Self::STATUS_ERROR => "Error",
Self::STATUS_ACTIVE => "Active",
Self::STATUS_TERMINATED => "Terminated",
_ => "UNKNOWN STATUS",
}
}
pub fn application_type_text(application_type: &str) -> Option<&'static str> {
match application_type {
Self::ENROLMENT => Some("Enrollment"),
Self::MAINTENANCE => Some("Maintenance"),
Self::TERMINATION => Some("Termination"),
_ => None,
}
}
pub fn frequency_mode_text(frequency_mode: &str) -> Option<&'static str> {
match frequency_mode {
Self::MODE_DAILY => Some("Daily"),
Self::MODE_WEEKLY => Some("Weekly"),
Self::MODE_MONTHLY => Some("Monthly"),
Self::MODE_YEARLY => Some("Yearly"),
_ => None,
}
}
}
pub mod duitnow {
pub struct Dobw;
impl Dobw {
pub const CASA: &'static str = "01";
pub const CREDIT_CARD: &'static str = "02";
pub const EWALLET: &'static str = "03";
pub const STATUS_NEW: i32 = 0;
pub const STATUS_PENDING: i32 = 1;
pub const STATUS_FAILED: i32 = 2;
pub const STATUS_SUCCESS: i32 = 3;
pub const STATUS_CANCELLED: i32 = 4;
pub fn status_text(status_code: i32) -> &'static str {
match status_code {
Self::STATUS_NEW => "New",
Self::STATUS_PENDING => "Pending",
Self::STATUS_CANCELLED => "Cancelled",
Self::STATUS_SUCCESS => "Successful",
Self::STATUS_FAILED => "Failed",
_ => "UNKNOWN STATUS",
}
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn fpx_status_text() {
assert_eq!(Fpx::status_text(Fpx::STATUS_SUCCESS), "Successful");
assert_eq!(Fpx::status_text(Fpx::STATUS_NEW), "New");
assert_eq!(Fpx::status_text(99), "UNKNOWN STATUS");
}
#[test]
fn direct_debit_helpers() {
assert_eq!(FpxDirectDebit::status_text(FpxDirectDebit::STATUS_ACTIVE), "Active");
assert_eq!(
FpxDirectDebit::application_type_text(FpxDirectDebit::ENROLMENT),
Some("Enrollment")
);
assert_eq!(FpxDirectDebit::application_type_text("99"), None);
assert_eq!(
FpxDirectDebit::frequency_mode_text(FpxDirectDebit::MODE_MONTHLY),
Some("Monthly")
);
}
#[test]
fn dobw_status_text() {
use duitnow::Dobw;
assert_eq!(Dobw::status_text(Dobw::STATUS_SUCCESS), "Successful");
assert_eq!(Dobw::CASA, "01");
}
}