open_payments_fednow/fednow_outgoing_external.rs
1// Open Payment Message Parsing Library
2// https://github.com/Open-Payments/messages
3//
4// This library is designed to parse message formats based on the ISO 20022 standards,
5// including but not limited to FedNow messages. It supports various financial message types,
6// such as customer credit transfers, payment status reports, administrative notifications,
7// and other ISO 20022 messages, using Serde for efficient serialization and deserialization.
8//
9// Copyright (c) 2024 Open Payments by Harishankar Narayanan
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21//
22// You may obtain a copy of this library at
23// https://github.com/Open-Payments/messages
24
25
26#![allow(unused_imports)]
27use regex::Regex;
28use crate::common::*;
29use open_payments_common::ValidationError;
30#[cfg(feature = "derive_serde")]
31use serde::{Deserialize, Serialize};
32
33// FedNowOutgoing ...
34#[cfg_attr(feature = "derive_debug", derive(Debug))]
35#[cfg_attr(feature = "derive_default", derive(Default))]
36#[cfg_attr(feature = "derive_serde", derive(Serialize, Deserialize))]
37#[cfg_attr(feature = "derive_clone", derive(Clone))]
38#[cfg_attr(feature = "derive_partial_eq", derive(PartialEq))]
39pub struct FedNowOutgoing {
40 #[cfg_attr( feature = "derive_serde", serde(rename = "FedNowTechnicalHeader", skip_serializing_if = "Option::is_none") )]
41 pub fed_now_technical_header: Option<FedNowTechnicalHeader>,
42 #[cfg_attr( feature = "derive_serde", serde(rename = "FedNowOutgoingMessage") )]
43 pub fed_now_outgoing_message: FedNowOutgoingMessage,
44}
45
46impl FedNowOutgoing {
47 pub fn validate(&self) -> Result<(), ValidationError> {
48 if let Some(ref val) = self.fed_now_technical_header { val.validate()? }
49 self.fed_now_outgoing_message.validate()?;
50 Ok(())
51 }
52}