miso20022 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
miso20022/__init__.py ADDED
@@ -0,0 +1,34 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ """
4
+ ISO 20022 data models package.
5
+ """
6
+
7
+ from dataclasses import asdict
8
+ from miso20022.bah.apphdr import AppHdr
9
+ from miso20022.pacs import Document, FIToFICstmrCdtTrf
10
+ from miso20022.helpers import dict_to_xml
11
+
12
+ def model_to_xml(model, prefix=None, namespace=None):
13
+ """Convert model to XML using the dictionary-based approach."""
14
+ if hasattr(model, 'to_dict'):
15
+ xml_dict = model.to_dict()
16
+ else:
17
+ xml_dict = asdict(model)
18
+ if prefix and namespace:
19
+ xml_dict = {
20
+ "Document": {
21
+ f"@xmlns:{prefix}": namespace,
22
+ **xml_dict
23
+ }
24
+ }
25
+ return dict_to_xml(xml_dict, prefix=prefix, namespace=namespace)
26
+
27
+
28
+ __all__ = [
29
+ "AppHdr",
30
+ "Document",
31
+ "FIToFICstmrCdtTrf",
32
+ "dict_to_xml",
33
+ "model_to_xml",
34
+ ]
miso20022/cli.py ADDED
@@ -0,0 +1,107 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ import argparse
4
+ import json
5
+ import os
6
+ import sys
7
+ from datetime import datetime
8
+ from typing import Dict, Any
9
+
10
+ from miso20022.fedwire import generate_fedwire_message, generate_fedwire_payload
11
+
12
+ def load_input_payload(input_file_path: str) -> Dict[str, Any]:
13
+ """Load a input payload from a JSON file."""
14
+ try:
15
+ with open(input_file_path, 'r') as file:
16
+ return json.load(file)
17
+ except Exception as e:
18
+ print(f"Error loading input file: {e}", file=sys.stderr)
19
+ sys.exit(1)
20
+
21
+ def write_message_to_file(message: str, output_file: str) -> bool:
22
+ """Write the generated message to a file."""
23
+ try:
24
+ with open(output_file, 'w') as file:
25
+ file.write(message)
26
+ print(f"Message successfully written to {output_file}")
27
+ return True
28
+ except Exception as e:
29
+ print(f"Error writing message to file: {e}", file=sys.stderr)
30
+ return False
31
+
32
+ def generate_output_filename(message_code: str, extension: str) -> str:
33
+ """Generate a default output filename."""
34
+ message_type = message_code.split(':')[-1]
35
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
36
+ return f"{message_type}_{timestamp}.{extension}"
37
+
38
+ def handle_generate(args):
39
+ """Handler for the 'generate' command."""
40
+ xsd_path = os.path.abspath(args.xsd_file)
41
+ if not os.path.exists(xsd_path):
42
+ print(f"Error: XSD file not found at {xsd_path}", file=sys.stderr)
43
+ sys.exit(1)
44
+
45
+ input_path = os.path.abspath(args.input_file)
46
+ if not os.path.exists(input_path):
47
+ print(f"Error: Input file not found at {input_path}", file=sys.stderr)
48
+ sys.exit(1)
49
+
50
+ payload = load_input_payload(input_path)
51
+ _, _, complete_message = generate_fedwire_message(args.message_code, args.environment, args.fed_aba, payload, xsd_path)
52
+
53
+ if complete_message:
54
+ output_file = args.output_file or generate_output_filename(args.message_code, 'xml')
55
+ write_message_to_file(complete_message, output_file)
56
+ else:
57
+ print("Failed to generate complete message", file=sys.stderr)
58
+ sys.exit(1)
59
+
60
+ def handle_parse(args):
61
+ """Handler for the 'parse' command."""
62
+ if not os.path.exists(args.input_file):
63
+ print(f"Error: Input file not found at {args.input_file}", file=sys.stderr)
64
+ sys.exit(1)
65
+
66
+ payload = generate_fedwire_payload(args.input_file, args.message_code)
67
+
68
+ if payload:
69
+ output_file = args.output_file or generate_output_filename(args.message_code, 'json')
70
+ try:
71
+ with open(output_file, 'w') as f:
72
+ json.dump(payload, f, indent=4)
73
+ print(f"Payload successfully written to {output_file}")
74
+ except Exception as e:
75
+ print(f"Error writing payload to file: {e}", file=sys.stderr)
76
+ sys.exit(1)
77
+ else:
78
+ print("Failed to parse XML file.", file=sys.stderr)
79
+ sys.exit(1)
80
+
81
+ def main():
82
+
83
+ parser = argparse.ArgumentParser(description='A CLI tool for generating and parsing ISO 20022 messages.')
84
+ subparsers = parser.add_subparsers(dest='command', required=True, help='Available commands')
85
+
86
+ # Generate command
87
+ gen_parser = subparsers.add_parser('generate', help='Generate a complete ISO 20022 message.')
88
+ gen_parser.add_argument('--message_code', help='ISO 20022 message code (e.g., urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08)')
89
+ gen_parser.add_argument('--environment', required=True, choices=['TEST', 'PROD'], help='The environment for the message (TEST or PROD).')
90
+ gen_parser.add_argument('--fed-aba', required=True, help='The Fed ABA number for message generation.')
91
+ gen_parser.add_argument('--input-file', required=True, help='Path to input JSON payload file.')
92
+ gen_parser.add_argument('--output-file', help='Path to output XML file.')
93
+ gen_parser.add_argument('--xsd-file', required=True, help='Path to the XSD file.')
94
+ gen_parser.set_defaults(func=handle_generate)
95
+
96
+ # Parse command
97
+ parse_parser = subparsers.add_parser('parse', help='Parse an ISO 20022 XML file into a JSON payload.')
98
+ parse_parser.add_argument('--input-file', required=True, help='Path to the XML file to parse.')
99
+ parse_parser.add_argument('--message-code', required=True, help='The message code to determine the parsing model.')
100
+ parse_parser.add_argument('--output-file', help='Path to output JSON file.')
101
+ parse_parser.set_defaults(func=handle_parse)
102
+
103
+ args = parser.parse_args()
104
+ args.func(args)
105
+
106
+ if __name__ == '__main__':
107
+ main()
miso20022/fedwire.py ADDED
@@ -0,0 +1,389 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ import sys
4
+ import re
5
+ import json
6
+ import xml.etree.ElementTree as ET
7
+ from typing import Dict, Any, Tuple, Optional, List, Union
8
+ from datetime import datetime
9
+
10
+ # Fix imports to use the correct package structure
11
+ from miso20022.bah.apphdr import AppHdr
12
+ from miso20022.pacs.pacs008 import Document as Pacs008Document
13
+ from miso20022.pacs.pacs028 import Document as Pacs028Document
14
+ from miso20022.pacs.pacs002 import FIToFIPmtStsRpt
15
+ from miso20022.pacs.pacs008 import FIToFICstmrCdtTrf
16
+ from miso20022.helpers import dict_to_xml
17
+ from miso20022.helpers import parse_xml_to_json
18
+
19
+ def parse_message_envelope(xsd_path, message_code):
20
+ """
21
+ Parse the XSD file and return data for a specific message code.
22
+
23
+ Args:
24
+ xsd_path: Path to the XSD file
25
+ message_code: The specific message code to return data for (required)
26
+
27
+ Returns:
28
+ A tuple containing (element_name, target_ns, root_element_name, message_container_name) for the specified message code
29
+
30
+ Raises:
31
+ ValueError: If message_code is not provided or not found in the XSD file
32
+ """
33
+ # Check if message_code is provided
34
+ if not message_code:
35
+ raise ValueError("message_code parameter is required")
36
+
37
+ # Define the namespaces
38
+ namespaces = {
39
+ 'xs': 'http://www.w3.org/2001/XMLSchema'
40
+ }
41
+
42
+ # Parse the XSD file
43
+ try:
44
+ # Read the file content directly to extract namespace declarations
45
+ with open(xsd_path, 'r') as file:
46
+ content = file.read()
47
+
48
+ # Extract namespace declarations using regex
49
+ ns_mapping = {}
50
+ ns_pattern = r'xmlns:([a-zA-Z0-9]+)="([^"]+)"'
51
+ for match in re.finditer(ns_pattern, content):
52
+ prefix, uri = match.groups()
53
+ ns_mapping[prefix] = uri
54
+
55
+ # Now parse the file with ElementTree
56
+ tree = ET.parse(xsd_path)
57
+ root = tree.getroot()
58
+ except Exception as e:
59
+ print(f"Error parsing XSD file: {e}")
60
+ sys.exit(1)
61
+
62
+ # Extract the target namespace
63
+ target_ns = root.get('targetNamespace')
64
+ if not target_ns:
65
+ print("Error: XSD file does not have a target namespace.")
66
+ sys.exit(1)
67
+
68
+ # Add the target namespace to our namespaces dictionary
69
+ namespaces['tns'] = target_ns
70
+
71
+ # Find the root element and message container element
72
+ root_elements = []
73
+ for element in root.findall('.//xs:element', namespaces):
74
+ name = element.get('name')
75
+ if name:
76
+ root_elements.append(name)
77
+
78
+ # Determine the root element (usually the first one defined)
79
+ root_element_name = root_elements[0] if root_elements else None
80
+
81
+ # Determine the message container element (usually the second one defined)
82
+ message_container_name = root_elements[2] if len(root_elements) > 2 else (root_elements[1] if len(root_elements) > 1 else None)
83
+
84
+ # Find all elements that could be message types
85
+ for element in root.findall('.//xs:element', namespaces):
86
+ name = element.get('name')
87
+ # Skip the root elements and technical headers
88
+ if (name and
89
+ name != root_element_name and
90
+ name != message_container_name and
91
+ not name.endswith('TechnicalHeader')):
92
+
93
+ # Check if this element has child elements that include Document
94
+ has_document = False
95
+ for seq in element.findall('.//xs:sequence', namespaces):
96
+ for child in seq.findall('.//xs:element', namespaces):
97
+ ref = child.get('ref')
98
+ if ref and 'Document' in ref:
99
+ has_document = True
100
+ break
101
+
102
+ if has_document:
103
+ # This is a message type element
104
+
105
+ # Find the child elements to determine which message code it uses
106
+ for seq in element.findall('.//xs:sequence', namespaces):
107
+ for child in seq.findall('.//xs:element', namespaces):
108
+ ref = child.get('ref')
109
+ if ref:
110
+ try:
111
+ prefix, local_name = ref.split(':')
112
+ if prefix in ns_mapping:
113
+ namespace = ns_mapping[prefix]
114
+ if local_name == 'Document':
115
+ # Extract the message code from the namespace
116
+ current_message_code = namespace
117
+
118
+ # If we found the requested message code, return the data
119
+ if current_message_code == message_code:
120
+ return name, target_ns, root_element_name, message_container_name
121
+ except ValueError:
122
+ # Skip refs that don't have a prefix
123
+ continue
124
+
125
+ # If we've gone through all elements and haven't found the message code, raise an error
126
+ raise ValueError(f"Message code '{message_code}' not found in the XSD file.")
127
+
128
+ def generate_message_structure(app_hdr_xml, document_xml, name, target_ns, root_element_name, message_container_name):
129
+ """
130
+ Generate the message structure for a given message code.
131
+
132
+ Args:
133
+ app_hdr_xml: The AppHdr XML
134
+ document_xml: The Document XML
135
+ name: The element name
136
+ target_ns: The target namespace
137
+ root_element_name: The root element name
138
+ message_container_name: The message container name
139
+
140
+ Returns:
141
+ The XML structure as a string
142
+ """
143
+ # Create the XML structure
144
+ app_hdr_lines = app_hdr_xml.strip().split('\n')
145
+ document_lines = document_xml.strip().split('\n')
146
+
147
+ # Indent the lines properly
148
+ app_hdr_indented = '\n '.join(app_hdr_lines)
149
+ document_indented = '\n '.join(document_lines)
150
+
151
+ complete_structure = f"""<{root_element_name} xmlns="{target_ns}">
152
+ <{message_container_name}>
153
+ <{name}>
154
+ {app_hdr_indented}
155
+ {document_indented}
156
+ </{name}>
157
+ </{message_container_name}>
158
+ </{root_element_name}>"""
159
+
160
+ return complete_structure
161
+
162
+ def generate_fedwire_message(message_code: str, environment: str, fed_aba: str, payload: Dict[str, Any], xsd_path: str) -> Tuple[Optional[str], Optional[str], Optional[str]]:
163
+ """
164
+ Generate a complete ISO20022 message using the models from miso20022.
165
+
166
+ Args:
167
+ message_code: The ISO20022 message code (e.g., urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08).
168
+ environment: The environment for the message, either "TEST" or "PROD".
169
+ fed_aba: The Fed ABA number for message generation.
170
+ payload: The payload data as a dictionary.
171
+ xsd_path: Path to the XSD file for structure identification.
172
+
173
+ Returns:
174
+ Tuple of (AppHdr XML, Document XML, Complete Structure XML) or (None, None, None) if not supported.
175
+ """
176
+ # Extract the message type from the message code
177
+ message_type = message_code.split(':')[-1]
178
+
179
+ try:
180
+ # Generate AppHdr
181
+ app_hdr = AppHdr.from_payload(environment, fed_aba, message_code, payload)
182
+ app_hdr_dict = app_hdr.to_dict()
183
+ app_hdr_xml = dict_to_xml(app_hdr_dict, "head", "urn:iso:std:iso:20022:tech:xsd:head.001.001.03")
184
+
185
+ # Generate Document based on message type
186
+ document_xml = None
187
+
188
+ # Only support pacs.008 and pacs.028 message types
189
+ if "pacs.008" in message_type:
190
+ try:
191
+ # Use the specific model for pacs.008
192
+ document = Pacs008Document.from_payload(payload)
193
+ document_dict = document.to_dict()
194
+ document_xml = dict_to_xml(document_dict, "pacs", message_code)
195
+ except Exception as e:
196
+ print(f"Error generating pacs.008 structure: {e}")
197
+ return None, None, None
198
+
199
+ elif "pacs.028" in message_type:
200
+ try:
201
+ document = Pacs028Document.from_payload(payload)
202
+ document_dict = document.to_dict()
203
+ document_xml = dict_to_xml(document_dict, "pacs", message_code)
204
+ print(f"Generated structure for pacs.028 message type using model")
205
+ except Exception as e:
206
+ print(f"Error generating pacs.028 structure: {e}")
207
+ print("Make sure you're providing the correct payload structure for pacs.028")
208
+ return None, None, None
209
+ else:
210
+ # All other message types are unsupported
211
+ print(f"Message type {message_type} is not currently supported for generation.")
212
+ return None, None, None
213
+
214
+ # Generate the complete structure
215
+ complete_structure = None
216
+ try:
217
+ # Get the specific message data - use full message_code, not just message_type
218
+ element_name, target_ns, root_element_name, message_container_name = parse_message_envelope(xsd_path, message_code)
219
+
220
+ # Create the complete XML structure with the actual generated content
221
+ app_hdr_lines = app_hdr_xml.strip().split('\n')
222
+ document_lines = document_xml.strip().split('\n')
223
+
224
+ # Indent the lines properly
225
+ app_hdr_indented = '\n '.join(app_hdr_lines)
226
+ document_indented = '\n '.join(document_lines)
227
+
228
+ complete_structure = f"""<{root_element_name} xmlns="{target_ns}">
229
+ <{message_container_name}>
230
+ <{element_name}>
231
+ {app_hdr_indented}
232
+ {document_indented}
233
+ </{element_name}>
234
+ </{message_container_name}>
235
+ </{root_element_name}>"""
236
+ except ValueError as e:
237
+ print(f"Error generating complete structure: {e}")
238
+ return None, None, None
239
+
240
+ return app_hdr_xml, document_xml, complete_structure
241
+
242
+ except Exception as e:
243
+ print(f"Error generating message: {e}")
244
+ return None, None, None
245
+
246
+ def get_account_number(Acct):
247
+ """Safely retrieves the account number from an Acct object."""
248
+ if not Acct or not hasattr(Acct, 'Id') or not Acct.Id:
249
+ return ""
250
+ # Prioritize Other ID if available
251
+ if hasattr(Acct.Id.Othr, 'Id') and Acct.Id.Othr.Id:
252
+ return Acct.Id.Othr.Id
253
+
254
+ # Fallback to IBAN
255
+ if hasattr(Acct.Id, 'IBAN') and Acct.Id.IBAN:
256
+ return Acct.Id.IBAN
257
+
258
+ return ""
259
+
260
+ def pacs_008_to_fedwire_json (app_hdr, cdt_trf_tx_inf, grp_hdr_data):
261
+ """Maps AppHdr and CdtTrfTxInf data classes to the Fedwire JSON format. Supports PACS008 Only"""
262
+
263
+ # Helper to safely extract address lines
264
+ def get_adr_line(pstl_adr, index):
265
+ if not pstl_adr:
266
+ return ""
267
+
268
+ constructed_line = ""
269
+
270
+ if index == 0: # Line 1: Street Name and Building Number
271
+ line_parts = filter(None, [pstl_adr.StrtNm, pstl_adr.BldgNb])
272
+ constructed_line = " ".join(line_parts).strip()
273
+ elif index == 1: # Line 2: Floor and Room
274
+ flr_part = f"Flr {pstl_adr.Flr}" if pstl_adr.Flr else None
275
+ room_part = pstl_adr.Room
276
+ line_parts = filter(None, [flr_part, room_part])
277
+ constructed_line = ", ".join(line_parts).strip()
278
+ elif index == 2: # Line 3: Town, State/Province PostalCode, Country
279
+ town_part = pstl_adr.TwnNm
280
+ # Combine State/Province and Postal Code, e.g., "CA 90210" or "CA" or "90210"
281
+ state_zip_part = " ".join(filter(None, [pstl_adr.CtrySubDvsn, pstl_adr.PstCd])).strip()
282
+ country_part = pstl_adr.Ctry
283
+
284
+ # Combine all parts of Line 3 with commas, filtering out empty ones
285
+ all_line3_parts = filter(None, [town_part, state_zip_part, country_part])
286
+ constructed_line = ", ".join(all_line3_parts).strip()
287
+
288
+ # Return the constructed line if not empty, otherwise fallback to AdrLine
289
+ if constructed_line:
290
+ return constructed_line
291
+ elif pstl_adr.AdrLine and len(pstl_adr.AdrLine) > index and pstl_adr.AdrLine[index]:
292
+ return pstl_adr.AdrLine[index] # Return AdrLine if it's not empty
293
+ else:
294
+ return ""
295
+
296
+ fedwire_message = {
297
+ "fedWireMessage": {
298
+ "inputMessageAccountabilityData": {
299
+ "inputCycleDate": grp_hdr_data.MsgId[:8],
300
+ "inputSource": grp_hdr_data.MsgId[8:13],
301
+ "inputSequenceNumber": grp_hdr_data.MsgId[13:]
302
+ },
303
+ "amount": {
304
+ "amount": str(int(float(cdt_trf_tx_inf.IntrBkSttlmAmt['#text'])))
305
+ },
306
+ "senderDepositoryInstitution": {
307
+ "senderABANumber": cdt_trf_tx_inf.InstgAgt.FinInstnId.ClrSysMmbId.MmbId,
308
+ "senderShortName": cdt_trf_tx_inf.DbtrAgt.FinInstnId.Nm or ""
309
+ },
310
+ "receiverDepositoryInstitution": {
311
+ "receiverABANumber": cdt_trf_tx_inf.InstdAgt.FinInstnId.ClrSysMmbId.MmbId,
312
+ "receiverShortName": cdt_trf_tx_inf.CdtrAgt.FinInstnId.Nm or ""
313
+ },
314
+ "originator": {
315
+ "personal": {
316
+ "name": cdt_trf_tx_inf.Dbtr.Nm,
317
+ "address": {
318
+ "addressLineOne": get_adr_line(cdt_trf_tx_inf.Dbtr.PstlAdr, 0),
319
+ "addressLineTwo": get_adr_line(cdt_trf_tx_inf.Dbtr.PstlAdr, 1),
320
+ "addressLineThree": get_adr_line(cdt_trf_tx_inf.Dbtr.PstlAdr, 2)
321
+ },
322
+ "identifier": get_account_number(cdt_trf_tx_inf.DbtrAcct)
323
+ }
324
+ },
325
+ "beneficiary": {
326
+ "personal": {
327
+ "name": cdt_trf_tx_inf.Cdtr.Nm,
328
+ "address": {
329
+ "addressLineOne": get_adr_line(cdt_trf_tx_inf.Cdtr.PstlAdr, 0),
330
+ "addressLineTwo": get_adr_line(cdt_trf_tx_inf.Cdtr.PstlAdr, 1),
331
+ "addressLineThree": get_adr_line(cdt_trf_tx_inf.Cdtr.PstlAdr, 2)
332
+ },
333
+ "identifier": get_account_number(cdt_trf_tx_inf.CdtrAcct)
334
+ }
335
+ }
336
+ }
337
+ }
338
+ return fedwire_message
339
+
340
+
341
+ def pacs_002_to_fedwire_json(app_hdr, pmt_sts_req):
342
+ """Maps AppHdr and FIToFIPmtStsRpt data classes to the Fedwire JSON format."""
343
+
344
+ #TODO: Add status and reason
345
+ fedwire_message = {
346
+ "fedWireMessage": {
347
+ "inputMessageAccountabilityData": {
348
+ "inputCycleDate": pmt_sts_req.TxInfAndSts.OrgnlGrpInf['OrgnlMsgId'][:8],
349
+ "inputSource": pmt_sts_req.TxInfAndSts.OrgnlGrpInf['OrgnlMsgId'][8:13],
350
+ "inputSequenceNumber": pmt_sts_req.TxInfAndSts.OrgnlGrpInf['OrgnlMsgId'][13:]
351
+ },
352
+ "outputMessageAccountabilityData": {
353
+ "outputCycleDate": pmt_sts_req.GrpHdr.MsgId[:8],
354
+ "outputSource": pmt_sts_req.GrpHdr.MsgId[8:13],
355
+ "outputSequenceNumber": pmt_sts_req.GrpHdr.MsgId[13:]
356
+ }
357
+ }
358
+ }
359
+ return fedwire_message
360
+
361
+
362
+ def generate_fedwire_payload(xml_file, message_code):
363
+
364
+ # 1. Parse the XML file to JSON
365
+ json_output = parse_xml_to_json(xml_file)
366
+ data = json.loads(json_output)
367
+
368
+ # 2. Instantiate the AppHdr & CdtTrfTxInf data class
369
+
370
+ if message_code == "urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08":
371
+
372
+ app_hdr_instance = AppHdr.from_iso20022(data,message_code)
373
+ grp_hdr_data, cdt_trf_tx_inf = FIToFICstmrCdtTrf.from_iso20022(data)
374
+
375
+ # 3. Map to Fedwire JSON format
376
+ fedwire_json = pacs_008_to_fedwire_json(app_hdr_instance, cdt_trf_tx_inf, grp_hdr_data)
377
+
378
+ elif message_code == "urn:iso:std:iso:20022:tech:xsd:pacs.002.001.10":
379
+
380
+ app_hdr_instance = AppHdr.from_iso20022(data,message_code)
381
+ pmt_sts_req= FIToFIPmtStsRpt.from_iso20022(data)
382
+
383
+ # 3. Map to Fedwire JSON format
384
+ fedwire_json = pacs_002_to_fedwire_json(app_hdr_instance, pmt_sts_req)
385
+
386
+ else:
387
+ raise ValueError(f"Unsupported message code: {message_code}")
388
+
389
+ return fedwire_json
miso20022/helpers.py ADDED
@@ -0,0 +1,111 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ """
4
+ Utility to convert dictionaries to XML format.
5
+ """
6
+ from typing import Any, Dict, List, Union, Optional
7
+ import xmltodict
8
+ from lxml import etree
9
+ import json
10
+
11
+ def _remove_none_values(obj):
12
+ """Remove None values from a dictionary recursively."""
13
+ if isinstance(obj, dict):
14
+ return {k: _remove_none_values(v) for k, v in obj.items() if v is not None}
15
+ elif isinstance(obj, list):
16
+ return [_remove_none_values(item) for item in obj]
17
+ return obj
18
+
19
+
20
+ def dict_to_xml(data: Union[Dict[str, Any], List[Any]], prefix, namespace, root: Optional[str] = None) -> str:
21
+ """
22
+ Convert a dictionary to an XML string with optional namespace prefix.
23
+
24
+ Args:
25
+ data: Dictionary or list to convert.
26
+ prefix: Namespace prefix to apply to element tags.
27
+ namespace: Namespace URI to declare on the root element.
28
+ root: Optional root element name to wrap data.
29
+
30
+ Returns:
31
+ Namespaced XML string.
32
+ """
33
+ # Remove None values first
34
+ data = _remove_none_values(data)
35
+
36
+ def _apply_prefix(obj):
37
+ if isinstance(obj, dict):
38
+ new_obj = {}
39
+ for key, value in obj.items():
40
+ # Don't prefix attributes or the text node
41
+ if key.startswith('@') or key == '#text':
42
+ new_obj[key] = _apply_prefix(value)
43
+ else:
44
+ prefixed_key = f"{prefix}:{key}"
45
+ new_obj[prefixed_key] = _apply_prefix(value)
46
+ return new_obj
47
+ elif isinstance(obj, list):
48
+ return [_apply_prefix(item) for item in obj]
49
+ else:
50
+ return obj
51
+
52
+ # Apply prefix to all tags
53
+ if prefix and namespace:
54
+ data = _apply_prefix(data)
55
+
56
+ # If root is provided, wrap the data in it
57
+ if root:
58
+ root_key = f"{prefix}:{root}"
59
+ data = {root_key: data}
60
+ # Declare namespace on the root element
61
+ data[root_key]["@xmlns:" + prefix] = namespace
62
+
63
+ # Generate XML without the XML declaration
64
+ return xmltodict.unparse(data, pretty=True, full_document=False)
65
+
66
+ def parse_xml_to_json(xml_file_path: str) -> str:
67
+ """Parses an XML file and converts it to a JSON string."""
68
+ try:
69
+ tree = etree.parse(xml_file_path)
70
+ root = tree.getroot()
71
+
72
+ def element_to_dict(element):
73
+ """Recursively converts an lxml element to a dictionary."""
74
+ # Remove namespace from tag name
75
+ tag = etree.QName(element).localname
76
+
77
+ node_dict = {}
78
+
79
+ # Add attributes to the dictionary
80
+ if element.attrib:
81
+ node_dict['@attributes'] = {k: v for k, v in element.attrib.items()}
82
+
83
+ # Add child elements to the dictionary
84
+ children = element.getchildren()
85
+ if children:
86
+ for child in children:
87
+ child_tag, child_data = element_to_dict(child).popitem()
88
+ if child_tag in node_dict:
89
+ if not isinstance(node_dict[child_tag], list):
90
+ node_dict[child_tag] = [node_dict[child_tag]]
91
+ node_dict[child_tag].append(child_data)
92
+ else:
93
+ node_dict[child_tag] = child_data
94
+
95
+ # Add text content to the dictionary
96
+ if element.text and element.text.strip():
97
+ text = element.text.strip()
98
+ if node_dict: # If there are attributes or children, add text as a key
99
+ node_dict['#text'] = text
100
+ else: # Otherwise, the element's value is just the text
101
+ node_dict = text
102
+
103
+ return {tag: node_dict}
104
+
105
+ xml_dict = element_to_dict(root)
106
+ return json.dumps(xml_dict, indent=4)
107
+
108
+ except etree.XMLSyntaxError as e:
109
+ raise ValueError(f"Error parsing XML file: {e}")
110
+ except Exception as e:
111
+ raise IOError(f"Error reading file or processing XML: {e}")
@@ -0,0 +1,341 @@
1
+ Metadata-Version: 2.4
2
+ Name: miso20022
3
+ Version: 0.1.0
4
+ Summary: ISO 20022 Message Generator for US Payment Rails
5
+ Author-email: Mbanq <developers@mbanq.com>, Sai Vatsavai <sai.vatsavai@mbanq.com>, Vamsi Krishna <vamsi.krishna@mbanq.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Mbanq/iso20022
8
+ Project-URL: Bug Tracker, https://github.com/Mbanq/iso20022/issues
9
+ Keywords: iso20022,financial,messaging,banking,fedwire,us payment rails,fednow
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Financial and Insurance Industry
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.7
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Topic :: Office/Business :: Financial
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.7
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: xmlschema>=1.9.0
23
+ Requires-Dist: python-dotenv>=0.19.0
24
+ Requires-Dist: xmltodict>=0.13.0
25
+ Requires-Dist: lxml>=4.9.0
26
+ Requires-Dist: setuptools~=58.0.4
27
+ Dynamic: license-file
28
+
29
+ # MISO20022 Python Library
30
+
31
+ This package provides a set of tools for generating and working with ISO 20022 financial messages, with a focus on the US Payment Rails.
32
+
33
+
34
+ ## Installation
35
+
36
+ You can install the package from PyPI:
37
+
38
+ ```bash
39
+ pip install miso20022
40
+ ```
41
+
42
+ ## Usage Examples
43
+
44
+ This section provides detailed examples for the core functionalities of the library.
45
+
46
+ **Index:**
47
+ - [Generating a `pacs.008.001.08` (Customer Credit Transfer) Message](#generating-a-pacs00800108-customer-credit-transfer-message)
48
+ - [Generating a `pacs.028.001.03` (Payment Status Request) Message](#generating-a-pacs02800103-payment-status-request-message)
49
+ - [Parsing a `pacs.008.001.08` XML to JSON](#parsing-a-pacs00800108-xml-to-json)
50
+ - [Parsing a `pacs.002.001.10` (Payment Status Report) XML to JSON](#parsing-a-pacs00200110-payment-status-report-xml-to-json)
51
+
52
+ ---
53
+
54
+ ### Input JSON Structure
55
+
56
+ The `generate_fedwire_message` function expects a specific JSON structure for the `payload` argument. Below are the expected formats for the supported message types.
57
+
58
+ #### `pacs.008.001.08` (Customer Credit Transfer)
59
+
60
+ The payload for a `pacs.008` message should follow this structure:
61
+
62
+ ```json
63
+ {
64
+ "fedWireMessage": {
65
+ "inputMessageAccountabilityData": {
66
+ "inputCycleDate": "20250109",
67
+ "inputSource": "MBANQ",
68
+ "inputSequenceNumber": "001000001"
69
+ },
70
+ "amount": {
71
+ "amount": "1000"
72
+ },
73
+ "senderDepositoryInstitution": {
74
+ "senderABANumber": "<routing_number>",
75
+ "senderShortName": "Pypi Bank"
76
+ },
77
+ "receiverDepositoryInstitution": {
78
+ "receiverABANumber": "<routing_number>",
79
+ "receiverShortName": "HelloBank"
80
+ },
81
+ "originator": {
82
+ "personal": {
83
+ "name": "JANE SMITH",
84
+ "address": {
85
+ "addressLineOne": "456 eat street",
86
+ "addressLineTwo": "SOMEWHERE, CA 67890",
87
+ "addressLineThree": ""
88
+ },
89
+ "identifier": "<account_number>"
90
+ }
91
+ },
92
+ "beneficiary": {
93
+ "personal": {
94
+ "name": "JOHN DOE",
95
+ "address": {
96
+ "addressLineOne": "123 Main street",
97
+ "addressLineTwo": "ANYTOWN, TX 12345",
98
+ "addressLineThree": ""
99
+ },
100
+ "identifier": "<account_number>"
101
+ }
102
+ }
103
+ }
104
+ }
105
+ ```
106
+
107
+ #### `pacs.028.001.03` (Payment Status Request)
108
+
109
+ The payload for a `pacs.028` message should follow this structure:
110
+
111
+ ```json
112
+ {
113
+ "fedWireMessage": {
114
+ "inputMessageAccountabilityData": {
115
+ "inputCycleDate": "20250109",
116
+ "inputSource": "MBANQ",
117
+ "inputSequenceNumber": "001000002"
118
+ },
119
+ "senderDepositoryInstitution": {
120
+ "senderABANumber": "<routing_number>",
121
+ "senderShortName": "<short_name>"
122
+ },
123
+ "receiverDepositoryInstitution": {
124
+ "receiverABANumber": "<routing_number>",
125
+ "receiverShortName": "<short_name>"
126
+ }
127
+ },
128
+ "message_id": "PACS028REQ20250109001",
129
+ "original_msg_id": "20250109MBANQ001000001",
130
+ "original_msg_nm_id": "pacs.008.001.08",
131
+ "original_creation_datetime": "2025-01-09T12:34:56Z",
132
+ "original_end_to_end_id": "MEtoEIDCJShqZKb"
133
+ }
134
+ ```
135
+
136
+ ### Generating a `pacs.008.001.08` (Customer Credit Transfer) Message
137
+
138
+ This example shows how to generate a Fedwire `pacs.008` message from a JSON payload.
139
+
140
+ ```python
141
+ import json
142
+ from miso20022.fedwire import generate_fedwire_message
143
+
144
+ # 1. Load your payment data from a JSON object
145
+ with open('sample_files/sample_payload.json', 'r') as f:
146
+ payload = json.load(f)
147
+
148
+ # 2. Define the necessary message parameters
149
+ message_code = 'urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08'
150
+ environment = "TEST" # Or "PROD"
151
+ fed_aba = '000000008' # The ABA number for the Fed
152
+ xsd_path = 'proprietary_fed_file.xsd' # The XSD file for fedwire format
153
+
154
+ # 3. Generate the complete XML message
155
+ _, _, complete_message = generate_fedwire_message(
156
+ message_code=message_code,
157
+ environment=environment,
158
+ fed_aba=fed_aba,
159
+ payload=payload,
160
+ xsd_path=xsd_path
161
+ )
162
+
163
+ # 4. Save the message to a file
164
+ if complete_message:
165
+ with open('generated_pacs.008.xml', 'w') as f:
166
+ f.write(complete_message)
167
+
168
+ print("pacs.008.001.08 message generated successfully!")
169
+ ```
170
+
171
+ ### Generating a `pacs.028.001.03` (Payment Status Request) Message
172
+
173
+ This example shows how to generate a `pacs.028` payment status request.
174
+
175
+ ```python
176
+ import json
177
+ from miso20022.fedwire import generate_fedwire_message
178
+
179
+ # 1. Load the payload for the status request
180
+ with open('sample_files/sample_pacs028_payload.json', 'r') as f:
181
+ payload = json.load(f)
182
+
183
+ # 2. Define message parameters
184
+ message_code = 'urn:iso:std:iso:20022:tech:xsd:pacs.028.001.03'
185
+ environment = "TEST" # Or "PROD"
186
+ fed_aba = '000000008'
187
+ xsd_path = 'proprietary_fed_file.xsd'
188
+
189
+ # 3. Generate the XML message
190
+ _, _, complete_message = generate_fedwire_message(
191
+ message_code=message_code,
192
+ environment=environment,
193
+ fed_aba=fed_aba,
194
+ payload=payload,
195
+ xsd_path=xsd_path
196
+ )
197
+
198
+ # 4. Save the message to a file
199
+ if complete_message:
200
+ with open('generated_pacs.028.xml', 'w') as f:
201
+ f.write(complete_message)
202
+
203
+ print("pacs.028.001.03 message generated successfully!")
204
+ ```
205
+
206
+ ### Parsing a `pacs.008.001.08` XML to JSON
207
+
208
+ This example shows how to parse a `pacs.008` XML file and convert it into a simplified JSON object.
209
+
210
+ ```python
211
+ from miso20022.fedwire import generate_fedwire_payload
212
+ import json
213
+
214
+ # 1. Define the path to your XML file and the message code
215
+ xml_file = 'incoming_pacs.008.xml'
216
+ message_code = 'urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08'
217
+
218
+ # 2. Parse the XML file
219
+ fedwire_json = generate_fedwire_payload(xml_file, message_code)
220
+
221
+ # 3. Save the JSON payload to a file
222
+ if fedwire_json:
223
+ with open('parsed_pacs.008.json', 'w') as f:
224
+ json.dump(fedwire_json, f, indent=4)
225
+
226
+ print("pacs.008.001.08 XML parsed to JSON successfully!")
227
+ ```
228
+
229
+ ### Parsing a `pacs.002.001.10` (Payment Status Report) XML to JSON
230
+
231
+ This example shows how to parse a `pacs.002` payment status report (ack/nack) into a JSON object.
232
+
233
+ ```python
234
+ from miso20022.fedwire import generate_fedwire_payload
235
+ import json
236
+
237
+ # 1. Define the path to your XML file and the message code
238
+ xml_file = 'sample_files/pacs.002_PaymentAck.xml'
239
+ message_code = 'urn:iso:std:iso:20022:tech:xsd:pacs.002.001.10'
240
+
241
+ # 2. Parse the XML to get the JSON payload
242
+ fedwire_json = generate_fedwire_payload(xml_file, message_code)
243
+
244
+ # 3. Save the payload to a JSON file
245
+ if fedwire_json:
246
+ with open('parsed_pacs.002_payload.json', 'w') as f:
247
+ json.dump(fedwire_json, f, indent=4)
248
+
249
+ print("pacs.002.001.10 XML parsed to JSON successfully!")
250
+ ```
251
+
252
+ ## Command-Line Interface (CLI)
253
+
254
+ The package includes a command-line tool, `miso20022`, for generating and parsing messages directly from your terminal.
255
+
256
+ ### Generating a Message
257
+
258
+ **Usage:**
259
+
260
+ ```bash
261
+ miso20022 generate --message_code [MESSAGE_CODE] --environment [ENV] --fed-aba [ABA_NUMBER] --input-file [PAYLOAD_FILE] --output-file [OUTPUT_XML]
262
+ ```
263
+
264
+ **Arguments:**
265
+
266
+ - `--message_code`: The ISO 20022 message code (e.g., `urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08`).
267
+ - `--environment`: The environment for the message (`TEST` or `PROD`).
268
+ - `--fed-aba`: The Fedwire ABA number.
269
+ - `--input-file`: Path to the input JSON payload file.
270
+ - `--output-file`: (Optional) Path to save the generated XML message.
271
+ - `--xsd-file`: (Optional) Path to the XSD file for validation.
272
+
273
+ **Example:**
274
+
275
+ ```bash
276
+ miso20022 generate \
277
+ --message_code urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08 \
278
+ --environment TEST \
279
+ --fed-aba 000000008 \
280
+ --input-file sample_files/sample_payment.json \
281
+ --output-file pacs.008_output.xml
282
+ ```
283
+
284
+ ### Parsing a Message
285
+
286
+ **Usage:**
287
+
288
+ ```bash
289
+ miso20022 parse --input-file [INPUT_XML] --message-code [MESSAGE_CODE] --output-file [OUTPUT_JSON]
290
+ ```
291
+
292
+ **Arguments:**
293
+
294
+ - `--input-file`: Path to the input ISO 20022 XML file.
295
+ - `--message-code`: The ISO 20022 message code of the input file.
296
+ - `--output-file`: (Optional) Path to save the output JSON payload.
297
+
298
+ **Example:**
299
+
300
+ ```bash
301
+ miso20022 parse \
302
+ --input-file sample_files/pacs.008.001.008_2025_1.xml \
303
+ --message-code urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08 \
304
+ --output-file parsed_payload.json
305
+ ```
306
+
307
+ ---
308
+
309
+ ## Supported Message Types
310
+
311
+ The library provides different levels of support for various message types.
312
+
313
+ ### Message Generation (`generate_fedwire_message`)
314
+
315
+ The following message types are fully supported with dedicated data models for generating complete XML messages:
316
+
317
+ - **`pacs.008.001.08`**: FI to FI Customer Credit Transfer
318
+ - **`pacs.028.001.03`**: FI to FI Payment Status Request
319
+
320
+ While other message types might be generated using the generic handlers, these are the ones with first-class support.
321
+
322
+ ### XML to JSON Parsing (`generate_fedwire_payload`)
323
+
324
+ The library can parse the following XML message types into a simplified Fedwire JSON format:
325
+
326
+ - **`pacs.008.001.08`**: FI to FI Customer Credit Transfer
327
+ - **`pacs.002.001.10`**: FI to FI Payment Status Report
328
+
329
+ Support for parsing other message types can be added by creating new mapping functions.
330
+
331
+ ### Future Support
332
+
333
+ We are actively working to expand the range of supported message types. Future releases will include built-in support for additional `pacs`, `camt`, and other ISO 20022 messages, with planned support for FedNow services. Stay tuned for updates!
334
+
335
+ ## Contributing
336
+
337
+ Contributions are welcome! Please refer to the [Project repository](https://github.com/Mbanq/iso20022) for contribution guidelines, to open an issue, or to submit a pull request.
338
+
339
+ <p align="center"><strong style="font-size: 2em">Built with ❤️ in the Beautiful State of Washington!</strong></p>
340
+
341
+
@@ -0,0 +1,10 @@
1
+ miso20022/__init__.py,sha256=yTENkynwRJv8RUTxoZwIUBjVmi9sy6WNSko3J20C1pg,863
2
+ miso20022/cli.py,sha256=btcqHFS8BbRawzgFfHC7DyHCSVXHZyZ0xazCBSrewSQ,4525
3
+ miso20022/fedwire.py,sha256=xzkYVMwWmUJoGKcH4SgraEZr2Xz1nrJssC5C-jlL5rU,16312
4
+ miso20022/helpers.py,sha256=iUs7osRRK5Y0YX_MXc9FhpdgBVb13yLtsqaHET4DhQw,3986
5
+ miso20022-0.1.0.dist-info/licenses/LICENSE,sha256=anJYlF4dWNaK9dbT5YiQtvP3yC2usnjq9j6dnssLfa8,11362
6
+ miso20022-0.1.0.dist-info/METADATA,sha256=caDDUiiA0-WbXzjaoNNElONPQSO8f4g71p9sOHllq3Y,10780
7
+ miso20022-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ miso20022-0.1.0.dist-info/entry_points.txt,sha256=2vMPbvTduug0nFnDI09fW185WL3IlUA7hJCFUR2257c,49
9
+ miso20022-0.1.0.dist-info/top_level.txt,sha256=amQoMpH9Ct_K-ufsoBI8h3BAVMafLyzZC7ltGXonEak,10
10
+ miso20022-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ miso20022 = miso20022.cli:main
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2025] [BAAS Corporation d/b/a Mbanq]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ miso20022