@temboplus/frontend-core 0.2.19 → 0.2.20-beta.0
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.
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/models/bank/bank.d.ts +74 -0
- package/package.json +1 -1
|
@@ -32,6 +32,80 @@ export declare class Bank {
|
|
|
32
32
|
*/
|
|
33
33
|
toString(): string;
|
|
34
34
|
static from(swiftCode: BankSwiftCode, countryCode: ISO2CountryCode): Bank;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a Bank instance from a JSON string.
|
|
37
|
+
*
|
|
38
|
+
* The JSON should contain swiftCode and countryCode fields.
|
|
39
|
+
* The bank data is then looked up from the bank service to ensure validity.
|
|
40
|
+
*
|
|
41
|
+
* @static
|
|
42
|
+
* @param {string} jsonString - JSON string containing bank data
|
|
43
|
+
* @returns {Bank | undefined} A new Bank instance if successful, undefined if parsing fails
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const jsonString = '{"swiftCode":"CORUTZTZ","countryCode":"TZ"}';
|
|
48
|
+
* const bank = Bank.fromJSON(jsonString);
|
|
49
|
+
* if (bank) {
|
|
50
|
+
* console.log(bank.fullName); // "CRDB BANK PLC"
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* // Also works with full bank data
|
|
54
|
+
* const fullJson = '{"fullName":"CRDB BANK PLC","shortName":"CRDB","swiftCode":"CORUTZTZ","countryCode":"TZ"}';
|
|
55
|
+
* const bank2 = Bank.fromJSON(fullJson);
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
static fromJSON(jsonString: string): Bank | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Converts the Bank instance to a plain JavaScript object.
|
|
61
|
+
* Suitable for serialization or data transfer.
|
|
62
|
+
*
|
|
63
|
+
* @returns {Object} Plain object representation of the bank
|
|
64
|
+
* @returns {string} returns.fullName - The full registered name of the bank
|
|
65
|
+
* @returns {string} returns.shortName - The commonly used short name
|
|
66
|
+
* @returns {string} returns.swiftCode - The SWIFT/BIC code
|
|
67
|
+
* @returns {ISO2CountryCode} returns.countryCode - The ISO 3166-1 alpha-2 country code
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const bank = Bank.from("CORUTZTZ", "TZ");
|
|
72
|
+
* const obj = bank.toObject();
|
|
73
|
+
* console.log(obj);
|
|
74
|
+
* // {
|
|
75
|
+
* // fullName: "CRDB BANK PLC",
|
|
76
|
+
* // shortName: "CRDB",
|
|
77
|
+
* // swiftCode: "CORUTZTZ",
|
|
78
|
+
* // countryCode: "TZ"
|
|
79
|
+
* // }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
toObject(): {
|
|
83
|
+
fullName: string;
|
|
84
|
+
shortName: string;
|
|
85
|
+
swiftCode: TZBankSwiftCode | KEBankSwiftCode;
|
|
86
|
+
countryCode: ISO2CountryCode;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Serializes the Bank instance to a JSON string.
|
|
90
|
+
*
|
|
91
|
+
* @returns {string} JSON string representation of the bank
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const bank = Bank.from("CORUTZTZ", "TZ");
|
|
96
|
+
* const jsonString = bank.toJSON();
|
|
97
|
+
* console.log(jsonString);
|
|
98
|
+
* // '{"fullName":"CRDB BANK PLC","shortName":"CRDB","swiftCode":"CORUTZTZ","countryCode":"TZ"}'
|
|
99
|
+
*
|
|
100
|
+
* // Store or transmit
|
|
101
|
+
* localStorage.setItem('selectedBank', jsonString);
|
|
102
|
+
*
|
|
103
|
+
* // Later, retrieve and reconstruct
|
|
104
|
+
* const stored = localStorage.getItem('selectedBank');
|
|
105
|
+
* const reconstructed = Bank.fromJSON(stored);
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
toJSON(): string;
|
|
35
109
|
/**
|
|
36
110
|
* Static method to determine if an unknown object is a valid Bank object.
|
|
37
111
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temboplus/frontend-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.20-beta.0",
|
|
4
4
|
"description": "A JavaScript/TypeScript package providing common utilities and logic shared across front-end TemboPlus projects.",
|
|
5
5
|
"author": "Okello Gerald",
|
|
6
6
|
"license": "MIT",
|