1use crate::document::*;
21use crate::error::ValidationError;
22use serde::{Deserialize, Serialize};
23
24#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
26pub enum Document {
27 #[serde(rename = "NtfctnOfCrspdc")]
30 NotificationOfCorrespondenceV01(Box<admi_024_001_01::NotificationOfCorrespondenceV01>),
31
32 #[serde(rename = "Rct")]
35 ReceiptV08(Box<camt_025_001_08::ReceiptV08>),
36
37 #[serde(rename = "RsltnOfInvstgtn")]
39 ResolutionOfInvestigationV09(Box<camt_029_001_09::ResolutionOfInvestigationV09>),
40
41 #[serde(rename = "BkToCstmrAcctRpt")]
43 BankToCustomerAccountReportV08(Box<camt_052_001_08::BankToCustomerAccountReportV08>),
44
45 #[serde(rename = "BkToCstmrStmt")]
47 BankToCustomerStatementV08(Box<camt_053_001_08::BankToCustomerStatementV08>),
48
49 #[serde(rename = "BkToCstmrDbtCdtNtfctn")]
51 BankToCustomerDebitCreditNotificationV08(
52 Box<camt_054_001_08::BankToCustomerDebitCreditNotificationV08>,
53 ),
54
55 #[serde(rename = "CstmrPmtCxlReq")]
57 CustomerPaymentCancellationRequestV08(
58 Box<camt_055_001_08::CustomerPaymentCancellationRequestV08>,
59 ),
60
61 #[serde(rename = "FIToFIPmtCxlReq")]
63 FIToFIPaymentCancellationRequestV08(Box<camt_056_001_08::FIToFIPaymentCancellationRequestV08>),
64
65 #[serde(rename = "NtfctnToRcv")]
67 NotificationToReceiveV06(Box<camt_057_001_06::NotificationToReceiveV06>),
68
69 #[serde(rename = "NtfctnToRcvCxlAdvc")]
71 NotificationToReceiveCancellationAdviceV08(
72 Box<camt_058_001_08::NotificationToReceiveCancellationAdviceV08>,
73 ),
74
75 #[serde(rename = "AcctRptgReq")]
77 AccountReportingRequestV05(Box<camt_060_001_05::AccountReportingRequestV05>),
78
79 #[serde(rename = "ChrgsInf")]
81 ChargesPaymentNotificationV02(Box<camt_105_001_02::ChargesPaymentNotificationV02>),
82
83 #[serde(rename = "ChrgsInfMC")]
85 ChargesPaymentNotificationV02MC(Box<camt_105_001_02_mc::ChargesPaymentNotificationV02>),
86
87 #[serde(rename = "ChrgsReq")]
89 ChargesPaymentRequestV02(Box<camt_106_001_02::ChargesPaymentRequestV02>),
90
91 #[serde(rename = "ChrgsReqMC")]
93 ChargesPaymentRequestV02MC(Box<camt_106_001_02_mc::ChargesPaymentRequestV02>),
94
95 #[serde(rename = "ChqPresntmntNtfctn")]
97 ChequePresentmentNotificationV01(Box<camt_107_001_01::ChequePresentmentNotificationV01>),
98
99 #[serde(rename = "ChqCxlOrStopReq")]
101 ChequeCancellationOrStopRequestV01(Box<camt_108_001_01::ChequeCancellationOrStopRequestV01>),
102
103 #[serde(rename = "ChqCxlOrStopRpt")]
105 ChequeCancellationOrStopReportV01(Box<camt_109_001_01::ChequeCancellationOrStopReportV01>),
106
107 #[serde(rename = "FIToFIPmtStsRpt")]
110 FIToFIPaymentStatusReportV10(Box<pacs_002_001_10::FIToFIPaymentStatusReportV10>),
111
112 #[serde(rename = "FIToFICstmrDrctDbt")]
114 FIToFICustomerDirectDebitV08(Box<pacs_003_001_08::FIToFICustomerDirectDebitV08>),
115
116 #[serde(rename = "PmtRtr")]
118 PaymentReturnV09(Box<pacs_004_001_09::PaymentReturnV09>),
119
120 #[serde(rename = "FIToFICstmrCdtTrf")]
122 FIToFICustomerCreditTransferV08(Box<pacs_008_001_08::FIToFICustomerCreditTransferV08>),
123
124 #[serde(rename = "FIToFICstmrCdtTrfSTP")]
126 FIToFICustomerCreditTransferV08STP(Box<pacs_008_001_08_stp::FIToFICustomerCreditTransferV08>),
127
128 #[serde(rename = "FinInstnCdtTrf")]
130 FinancialInstitutionCreditTransferV08(
131 Box<pacs_009_001_08::FinancialInstitutionCreditTransferV08>,
132 ),
133
134 #[serde(rename = "FinInstnCdtTrfAdv")]
136 FinancialInstitutionCreditTransferV08ADV(
137 Box<pacs_009_001_08_adv::FinancialInstitutionCreditTransferV08>,
138 ),
139
140 #[serde(rename = "FinInstnCdtTrfCov")]
142 FinancialInstitutionCreditTransferV08COV(
143 Box<pacs_009_001_08_cov::FinancialInstitutionCreditTransferV08>,
144 ),
145
146 #[serde(rename = "CstmrCdtTrfInitn")]
149 CustomerCreditTransferInitiationV09(Box<pain_001_001_09::CustomerCreditTransferInitiationV09>),
150
151 #[serde(rename = "CstmrPmtStsRpt")]
153 CustomerPaymentStatusReportV10(Box<pain_002_001_10::CustomerPaymentStatusReportV10>),
154
155 #[serde(rename = "CstmrDrctDbtInitn")]
157 CustomerDirectDebitInitiationV08(Box<pain_008_001_08::CustomerDirectDebitInitiationV08>),
158
159 #[default]
161 UNKNOWN,
162}
163
164impl Document {
165 pub fn validate(&self) -> Result<(), ValidationError> {
167 match self {
168 Document::NotificationOfCorrespondenceV01(value) => value.validate(),
170
171 Document::ReceiptV08(value) => value.validate(),
173 Document::ResolutionOfInvestigationV09(value) => value.validate(),
174 Document::BankToCustomerAccountReportV08(value) => value.validate(),
175 Document::BankToCustomerStatementV08(value) => value.validate(),
176 Document::BankToCustomerDebitCreditNotificationV08(value) => value.validate(),
177 Document::CustomerPaymentCancellationRequestV08(value) => value.validate(),
178 Document::FIToFIPaymentCancellationRequestV08(value) => value.validate(),
179 Document::NotificationToReceiveV06(value) => value.validate(),
180 Document::NotificationToReceiveCancellationAdviceV08(value) => value.validate(),
181 Document::AccountReportingRequestV05(value) => value.validate(),
182 Document::ChargesPaymentNotificationV02(value) => value.validate(),
183 Document::ChargesPaymentNotificationV02MC(value) => value.validate(),
184 Document::ChargesPaymentRequestV02(value) => value.validate(),
185 Document::ChargesPaymentRequestV02MC(value) => value.validate(),
186 Document::ChequePresentmentNotificationV01(value) => value.validate(),
187 Document::ChequeCancellationOrStopRequestV01(value) => value.validate(),
188 Document::ChequeCancellationOrStopReportV01(value) => value.validate(),
189
190 Document::FIToFIPaymentStatusReportV10(value) => value.validate(),
192 Document::FIToFICustomerDirectDebitV08(value) => value.validate(),
193 Document::PaymentReturnV09(value) => value.validate(),
194 Document::FIToFICustomerCreditTransferV08(value) => value.validate(),
195 Document::FIToFICustomerCreditTransferV08STP(value) => value.validate(),
196 Document::FinancialInstitutionCreditTransferV08(value) => value.validate(),
197 Document::FinancialInstitutionCreditTransferV08ADV(value) => value.validate(),
198 Document::FinancialInstitutionCreditTransferV08COV(value) => value.validate(),
199
200 Document::CustomerCreditTransferInitiationV09(value) => value.validate(),
202 Document::CustomerPaymentStatusReportV10(value) => value.validate(),
203 Document::CustomerDirectDebitInitiationV08(value) => value.validate(),
204
205 Document::UNKNOWN => Err(ValidationError::new(
206 9999,
207 "Unknown document type".to_string(),
208 )),
209 }
210 }
211
212 pub fn message_type(&self) -> &'static str {
214 match self {
215 Document::NotificationOfCorrespondenceV01(_) => "admi.024.001.01",
217
218 Document::ReceiptV08(_) => "camt.025.001.08",
220 Document::ResolutionOfInvestigationV09(_) => "camt.029.001.09",
221 Document::BankToCustomerAccountReportV08(_) => "camt.052.001.08",
222 Document::BankToCustomerStatementV08(_) => "camt.053.001.08",
223 Document::BankToCustomerDebitCreditNotificationV08(_) => "camt.054.001.08",
224 Document::CustomerPaymentCancellationRequestV08(_) => "camt.055.001.08",
225 Document::FIToFIPaymentCancellationRequestV08(_) => "camt.056.001.08",
226 Document::NotificationToReceiveV06(_) => "camt.057.001.06",
227 Document::NotificationToReceiveCancellationAdviceV08(_) => "camt.058.001.08",
228 Document::AccountReportingRequestV05(_) => "camt.060.001.05",
229 Document::ChargesPaymentNotificationV02(_) => "camt.105.001.02",
230 Document::ChargesPaymentNotificationV02MC(_) => "camt.105.001.02.mc",
231 Document::ChargesPaymentRequestV02(_) => "camt.106.001.02",
232 Document::ChargesPaymentRequestV02MC(_) => "camt.106.001.02.mc",
233 Document::ChequePresentmentNotificationV01(_) => "camt.107.001.01",
234 Document::ChequeCancellationOrStopRequestV01(_) => "camt.108.001.01",
235 Document::ChequeCancellationOrStopReportV01(_) => "camt.109.001.01",
236
237 Document::FIToFIPaymentStatusReportV10(_) => "pacs.002.001.10",
239 Document::FIToFICustomerDirectDebitV08(_) => "pacs.003.001.08",
240 Document::PaymentReturnV09(_) => "pacs.004.001.09",
241 Document::FIToFICustomerCreditTransferV08(_) => "pacs.008.001.08",
242 Document::FIToFICustomerCreditTransferV08STP(_) => "pacs.008.001.08.stp",
243 Document::FinancialInstitutionCreditTransferV08(_) => "pacs.009.001.08",
244 Document::FinancialInstitutionCreditTransferV08ADV(_) => "pacs.009.001.08.adv",
245 Document::FinancialInstitutionCreditTransferV08COV(_) => "pacs.009.001.08.cov",
246
247 Document::CustomerCreditTransferInitiationV09(_) => "pain.001.001.09",
249 Document::CustomerPaymentStatusReportV10(_) => "pain.002.001.10",
250 Document::CustomerDirectDebitInitiationV08(_) => "pain.008.001.08",
251
252 Document::UNKNOWN => "unknown",
253 }
254 }
255
256 pub fn is_cbpr_plus_compliant(&self) -> bool {
258 match self {
259 Document::UNKNOWN => false,
260 _ => true, }
262 }
263}