From 4fc7ef117946e6bd44baeadc4aa05a787899227e Mon Sep 17 00:00:00 2001 From: RgnDunes Date: Thu, 23 Jan 2025 18:39:45 +0530 Subject: [PATCH 1/8] add export from index file --- .../i18nify-js/src/modules/geo/getBankCode.ts | 76 +++++++++++++++++++ packages/i18nify-js/src/modules/geo/index.ts | 1 + 2 files changed, 77 insertions(+) create mode 100644 packages/i18nify-js/src/modules/geo/getBankCode.ts diff --git a/packages/i18nify-js/src/modules/geo/getBankCode.ts b/packages/i18nify-js/src/modules/geo/getBankCode.ts new file mode 100644 index 00000000..bae3d992 --- /dev/null +++ b/packages/i18nify-js/src/modules/geo/getBankCode.ts @@ -0,0 +1,76 @@ +import { withErrorBoundary } from '../../common/errorBoundary'; +import { + I18NIFY_DATA_SOURCE, + I18NIFY_DATA_SUPPORTED_COUNTRIES, +} from './constants'; +import { I18nifyCountryCodeType } from './types'; + +/** + * Retrieves the short_code for the specified bank in a given country + * + * This function makes a network request to the central i18nify-data source and + * returns a promise for the short_code associated with the bank name passed. + * If the bank or country is invalid, it rejects with an appropriate error. + * + * @param {I18nifyCountryCodeType} _countryCode - The ISO country code (e.g., 'IN') + * @param {string} bankName - The exact name of the bank (as it appears in the data) + * @returns {Promise} Promise that resolves to the short_code of the bank + */ +const getBankCode = ( + _countryCode: I18nifyCountryCodeType, + bankName: string, +): Promise => { + const countryCode = _countryCode.toUpperCase(); + + if (!I18NIFY_DATA_SUPPORTED_COUNTRIES.includes(countryCode)) { + return Promise.reject( + new Error( + `Data not available for country code: ${countryCode}. Data only available for country codes mentioned here: https://github.com/razorpay/i18nify/blob/master/packages/i18nify-js/src/modules/geo/constants.ts#L8`, + ), + ); + } + + if (!bankName) { + return Promise.reject( + new Error( + `Bank name is required to fetch the short_code. Please provide a valid bank name.`, + ), + ); + } + + return fetch(`${I18NIFY_DATA_SOURCE}/bankcodes/${countryCode}.json`) + .then((res) => res.json()) + .then((res) => { + const { details } = res; + if (!details || !Array.isArray(details)) { + return Promise.reject( + new Error( + `Bank data is not in the expected format for ${countryCode}.`, + ), + ); + } + + // Find the bank entry matching the passed bankName + const bank = details.find( + (bankItem: { name: string }) => + bankItem.name.toLowerCase() === bankName.toLowerCase(), + ); + + if (!bank || !bank.short_code) { + return Promise.reject( + new Error( + `Unable to find short_code for bank "${bankName}" in ${countryCode}. Please ensure the bank name is correct.`, + ), + ); + } + + return bank.short_code; + }) + .catch((err) => { + throw new Error( + `An error occurred while fetching bank short_code. The error details are: ${err.message}.`, + ); + }); +}; + +export default withErrorBoundary(getBankCode); diff --git a/packages/i18nify-js/src/modules/geo/index.ts b/packages/i18nify-js/src/modules/geo/index.ts index bc2e76e4..1ff4602a 100644 --- a/packages/i18nify-js/src/modules/geo/index.ts +++ b/packages/i18nify-js/src/modules/geo/index.ts @@ -4,3 +4,4 @@ export { default as getAllCountries } from './getAllCountries'; export { default as getStates } from './getStates'; export { default as getCities } from './getCities'; export { default as getZipcodes } from './getZipcodes'; +export { default as getBankCode } from './getBankCode'; From a001116590ee45635956cdae1992fa79722c0e96 Mon Sep 17 00:00:00 2001 From: Divyansh Singh Date: Thu, 23 Jan 2025 18:43:23 +0530 Subject: [PATCH 2/8] Create strong-pillows-flow.md --- .changeset/strong-pillows-flow.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/strong-pillows-flow.md diff --git a/.changeset/strong-pillows-flow.md b/.changeset/strong-pillows-flow.md new file mode 100644 index 00000000..3db14335 --- /dev/null +++ b/.changeset/strong-pillows-flow.md @@ -0,0 +1,5 @@ +--- +"@razorpay/i18nify-js": patch +--- + +Add getBankCode api in geo module From 7d7b696ee3fa5496b335d2212829fce60a6e6a08 Mon Sep 17 00:00:00 2001 From: RgnDunes Date: Thu, 23 Jan 2025 18:55:31 +0530 Subject: [PATCH 3/8] add UT for getBankCode --- .../modules/geo/__tests__/getBankCode.test.ts | 111 ++++++++++++++++++ .../i18nify-js/src/modules/geo/getBankCode.ts | 12 +- 2 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 packages/i18nify-js/src/modules/geo/__tests__/getBankCode.test.ts diff --git a/packages/i18nify-js/src/modules/geo/__tests__/getBankCode.test.ts b/packages/i18nify-js/src/modules/geo/__tests__/getBankCode.test.ts new file mode 100644 index 00000000..56d2100e --- /dev/null +++ b/packages/i18nify-js/src/modules/geo/__tests__/getBankCode.test.ts @@ -0,0 +1,111 @@ +import getBankCode from '../getBankCode'; + +// A mock object to simulate the data returned by the fetch call +// You can customize this as needed for your tests +const mockBankData = { + details: [ + { + name: 'Abhyudaya Co-operative Bank', + short_code: 'ABHY', + }, + { + name: 'SBI Bank', + short_code: 'SBI', + }, + ], +}; + +// Mock global.fetch by default to return `mockBankData` +global.fetch = jest.fn(() => + Promise.resolve({ + ok: true, + status: 200, + json: () => Promise.resolve(mockBankData), + } as Response), +); + +describe('getBankCode', () => { + beforeEach(() => { + // Reset fetch mock before each test case + jest.clearAllMocks(); + }); + + it('should reject if the bank is not found in the details array', async () => { + const bankName = 'Non Existent Bank'; + + await expect(getBankCode('IN', bankName)).rejects.toThrow( + `Unable to find bank code for bank "${bankName}" in IN. Please ensure the bank name is correct.`, + ); + }); + + it('should return bank code for a valid country code and bank name', async () => { + const countryCode = 'IN'; + const bankName = 'Abhyudaya Co-operative Bank'; + + const result = await getBankCode(countryCode, bankName); + + expect(result).toBe('ABHY'); + }); + + it('should reject with an error message when country code is invalid', async () => { + const invalidCountryCode = 'XYZ'; + const bankName = 'Abhyudaya Co-operative Bank'; + + await expect( + getBankCode(invalidCountryCode as any, bankName), + ).rejects.toThrow( + `Data not available for country code: XYZ. Data only available for country codes mentioned here: https://github.com/razorpay/i18nify/blob/master/packages/i18nify-js/src/modules/geo/constants.ts#L8`, + ); + }); + + it('should reject when bankName is not provided', async () => { + // @ts-expect-error Testing scenario with missing bank name + await expect(getBankCode('IN')).rejects.toThrow( + 'Bank name is required to fetch the bank code. Please provide a valid bank name.', + ); + }); + + it('should reject if the data is not in the expected format (missing details array)', async () => { + global.fetch = jest.fn(() => + Promise.resolve({ + ok: true, + status: 200, + json: () => Promise.resolve({}), // details is missing + } as Response), + ); + + await expect(getBankCode('IN', 'SBI Bank')).rejects.toThrow( + 'Bank data is not in the expected format for IN.', + ); + }); + + it('should reject if the bank is found but bank code is missing', async () => { + // Adjust mock data so the found bank does not have bank code + global.fetch = jest.fn(() => + Promise.resolve({ + ok: true, + status: 200, + json: () => + Promise.resolve({ + details: [{ name: 'Bank Without Shortcode' }], + }), + } as Response), + ); + + const bankName = 'Bank Without Shortcode'; + + await expect(getBankCode('IN', bankName)).rejects.toThrow( + `Unable to find bank code for bank "${bankName}" in IN. Please ensure the bank name is correct.`, + ); + }); + + it('should handle network or fetch errors gracefully', async () => { + global.fetch = jest.fn(() => Promise.reject('API Error')); + + await expect( + getBankCode('IN', 'Abhyudaya Co-operative Bank'), + ).rejects.toThrow( + 'An error occurred while fetching bank bank code. The error details are: undefined.', + ); + }); +}); diff --git a/packages/i18nify-js/src/modules/geo/getBankCode.ts b/packages/i18nify-js/src/modules/geo/getBankCode.ts index bae3d992..d71c6841 100644 --- a/packages/i18nify-js/src/modules/geo/getBankCode.ts +++ b/packages/i18nify-js/src/modules/geo/getBankCode.ts @@ -6,15 +6,15 @@ import { import { I18nifyCountryCodeType } from './types'; /** - * Retrieves the short_code for the specified bank in a given country + * Retrieves the bank code for the specified bank in a given country * * This function makes a network request to the central i18nify-data source and - * returns a promise for the short_code associated with the bank name passed. + * returns a promise for the bank code associated with the bank name passed. * If the bank or country is invalid, it rejects with an appropriate error. * * @param {I18nifyCountryCodeType} _countryCode - The ISO country code (e.g., 'IN') * @param {string} bankName - The exact name of the bank (as it appears in the data) - * @returns {Promise} Promise that resolves to the short_code of the bank + * @returns {Promise} Promise that resolves to the bank code of the bank */ const getBankCode = ( _countryCode: I18nifyCountryCodeType, @@ -33,7 +33,7 @@ const getBankCode = ( if (!bankName) { return Promise.reject( new Error( - `Bank name is required to fetch the short_code. Please provide a valid bank name.`, + `Bank name is required to fetch the bank code. Please provide a valid bank name.`, ), ); } @@ -59,7 +59,7 @@ const getBankCode = ( if (!bank || !bank.short_code) { return Promise.reject( new Error( - `Unable to find short_code for bank "${bankName}" in ${countryCode}. Please ensure the bank name is correct.`, + `Unable to find bank code for bank "${bankName}" in ${countryCode}. Please ensure the bank name is correct.`, ), ); } @@ -68,7 +68,7 @@ const getBankCode = ( }) .catch((err) => { throw new Error( - `An error occurred while fetching bank short_code. The error details are: ${err.message}.`, + `An error occurred while fetching bank bank code. The error details are: ${err.message}.`, ); }); }; From e1a26a735b065d1b9ec2c7c8088147ff036d88da Mon Sep 17 00:00:00 2001 From: RgnDunes Date: Wed, 29 Jan 2025 12:05:29 +0530 Subject: [PATCH 4/8] new module addition - banking --- packages/i18nify-js/src/index.ts | 1 + .../modules/{geo => banking}/__tests__/getBankCode.test.ts | 2 +- .../i18nify-js/src/modules/{geo => banking}/getBankCode.ts | 4 ++-- packages/i18nify-js/src/modules/banking/index.ts | 1 + packages/i18nify-js/src/modules/geo/index.ts | 1 - 5 files changed, 5 insertions(+), 4 deletions(-) rename packages/i18nify-js/src/modules/{geo => banking}/__tests__/getBankCode.test.ts (98%) rename packages/i18nify-js/src/modules/{geo => banking}/getBankCode.ts (96%) create mode 100644 packages/i18nify-js/src/modules/banking/index.ts diff --git a/packages/i18nify-js/src/index.ts b/packages/i18nify-js/src/index.ts index bf59d31b..c10e8f7d 100644 --- a/packages/i18nify-js/src/index.ts +++ b/packages/i18nify-js/src/index.ts @@ -3,4 +3,5 @@ export * from './modules/currency'; export * from './modules/phoneNumber'; export * from './modules/dateTime'; export * from './modules/geo'; +export * from './modules/banking'; export * from './modules/types'; diff --git a/packages/i18nify-js/src/modules/geo/__tests__/getBankCode.test.ts b/packages/i18nify-js/src/modules/banking/__tests__/getBankCode.test.ts similarity index 98% rename from packages/i18nify-js/src/modules/geo/__tests__/getBankCode.test.ts rename to packages/i18nify-js/src/modules/banking/__tests__/getBankCode.test.ts index 56d2100e..0c82899f 100644 --- a/packages/i18nify-js/src/modules/geo/__tests__/getBankCode.test.ts +++ b/packages/i18nify-js/src/modules/banking/__tests__/getBankCode.test.ts @@ -1,4 +1,4 @@ -import getBankCode from '../getBankCode'; +import getBankCode from '../../banking/getBankCode'; // A mock object to simulate the data returned by the fetch call // You can customize this as needed for your tests diff --git a/packages/i18nify-js/src/modules/geo/getBankCode.ts b/packages/i18nify-js/src/modules/banking/getBankCode.ts similarity index 96% rename from packages/i18nify-js/src/modules/geo/getBankCode.ts rename to packages/i18nify-js/src/modules/banking/getBankCode.ts index d71c6841..6eeb8a7f 100644 --- a/packages/i18nify-js/src/modules/geo/getBankCode.ts +++ b/packages/i18nify-js/src/modules/banking/getBankCode.ts @@ -2,8 +2,8 @@ import { withErrorBoundary } from '../../common/errorBoundary'; import { I18NIFY_DATA_SOURCE, I18NIFY_DATA_SUPPORTED_COUNTRIES, -} from './constants'; -import { I18nifyCountryCodeType } from './types'; +} from '../geo/constants'; +import { I18nifyCountryCodeType } from '../geo/types'; /** * Retrieves the bank code for the specified bank in a given country diff --git a/packages/i18nify-js/src/modules/banking/index.ts b/packages/i18nify-js/src/modules/banking/index.ts new file mode 100644 index 00000000..1adfc863 --- /dev/null +++ b/packages/i18nify-js/src/modules/banking/index.ts @@ -0,0 +1 @@ +export { default as getBankCode } from './getBankCode'; diff --git a/packages/i18nify-js/src/modules/geo/index.ts b/packages/i18nify-js/src/modules/geo/index.ts index 1ff4602a..bc2e76e4 100644 --- a/packages/i18nify-js/src/modules/geo/index.ts +++ b/packages/i18nify-js/src/modules/geo/index.ts @@ -4,4 +4,3 @@ export { default as getAllCountries } from './getAllCountries'; export { default as getStates } from './getStates'; export { default as getCities } from './getCities'; export { default as getZipcodes } from './getZipcodes'; -export { default as getBankCode } from './getBankCode'; From e38f03349b1fb705be8e2ea272b118fd8ad0547a Mon Sep 17 00:00:00 2001 From: RgnDunes Date: Wed, 29 Jan 2025 12:12:22 +0530 Subject: [PATCH 5/8] move source file out of geo module --- .../src/modules/banking/__tests__/getBankCode.test.ts | 2 +- packages/i18nify-js/src/modules/banking/getBankCode.ts | 2 +- .../src/modules/geo/__tests__/getFlagOfCountry.test.ts | 2 +- .../src/modules/geo/__tests__/getFlagsForAllCountries.test.ts | 2 +- packages/i18nify-js/src/modules/geo/getAllCountries.ts | 2 +- packages/i18nify-js/src/modules/geo/getCities.ts | 2 +- packages/i18nify-js/src/modules/geo/getFlagOfCountry.ts | 2 +- packages/i18nify-js/src/modules/geo/getFlagsForAllCountries.ts | 2 +- packages/i18nify-js/src/modules/geo/getStates.ts | 2 +- packages/i18nify-js/src/modules/geo/getZipcodes.ts | 2 +- .../src/modules/{geo/constants.ts => sourceConstants.ts} | 0 11 files changed, 10 insertions(+), 10 deletions(-) rename packages/i18nify-js/src/modules/{geo/constants.ts => sourceConstants.ts} (100%) diff --git a/packages/i18nify-js/src/modules/banking/__tests__/getBankCode.test.ts b/packages/i18nify-js/src/modules/banking/__tests__/getBankCode.test.ts index 0c82899f..56d2100e 100644 --- a/packages/i18nify-js/src/modules/banking/__tests__/getBankCode.test.ts +++ b/packages/i18nify-js/src/modules/banking/__tests__/getBankCode.test.ts @@ -1,4 +1,4 @@ -import getBankCode from '../../banking/getBankCode'; +import getBankCode from '../getBankCode'; // A mock object to simulate the data returned by the fetch call // You can customize this as needed for your tests diff --git a/packages/i18nify-js/src/modules/banking/getBankCode.ts b/packages/i18nify-js/src/modules/banking/getBankCode.ts index 6eeb8a7f..39147d30 100644 --- a/packages/i18nify-js/src/modules/banking/getBankCode.ts +++ b/packages/i18nify-js/src/modules/banking/getBankCode.ts @@ -2,7 +2,7 @@ import { withErrorBoundary } from '../../common/errorBoundary'; import { I18NIFY_DATA_SOURCE, I18NIFY_DATA_SUPPORTED_COUNTRIES, -} from '../geo/constants'; +} from '../sourceConstants'; import { I18nifyCountryCodeType } from '../geo/types'; /** diff --git a/packages/i18nify-js/src/modules/geo/__tests__/getFlagOfCountry.test.ts b/packages/i18nify-js/src/modules/geo/__tests__/getFlagOfCountry.test.ts index 14890d0e..2052758d 100644 --- a/packages/i18nify-js/src/modules/geo/__tests__/getFlagOfCountry.test.ts +++ b/packages/i18nify-js/src/modules/geo/__tests__/getFlagOfCountry.test.ts @@ -1,6 +1,6 @@ import { getFlagOfCountry } from '../index'; import { LIST_OF_ALL_COUNTRIES } from '../data/listOfAllCountries'; -import { FLAG_4X3_BASE_PATH, FLAG_BASE_PATH } from '../constants'; +import { FLAG_4X3_BASE_PATH, FLAG_BASE_PATH } from '../../sourceConstants'; import { CountryCodeType } from '../../types'; describe('geo - getFlagOfCountry', () => { diff --git a/packages/i18nify-js/src/modules/geo/__tests__/getFlagsForAllCountries.test.ts b/packages/i18nify-js/src/modules/geo/__tests__/getFlagsForAllCountries.test.ts index 96421f94..3b29976f 100644 --- a/packages/i18nify-js/src/modules/geo/__tests__/getFlagsForAllCountries.test.ts +++ b/packages/i18nify-js/src/modules/geo/__tests__/getFlagsForAllCountries.test.ts @@ -1,6 +1,6 @@ import { getFlagsForAllCountries } from '../index'; import { LIST_OF_ALL_COUNTRIES } from '../data/listOfAllCountries'; -import { FLAG_4X3_BASE_PATH, FLAG_BASE_PATH } from '../constants'; +import { FLAG_4X3_BASE_PATH, FLAG_BASE_PATH } from '../../sourceConstants'; import { CountryCodeType } from '../../types'; describe('geo - getFlagsForAllCountries', () => { diff --git a/packages/i18nify-js/src/modules/geo/getAllCountries.ts b/packages/i18nify-js/src/modules/geo/getAllCountries.ts index 805e3099..c1df148b 100644 --- a/packages/i18nify-js/src/modules/geo/getAllCountries.ts +++ b/packages/i18nify-js/src/modules/geo/getAllCountries.ts @@ -1,6 +1,6 @@ import { withErrorBoundary } from '../../common/errorBoundary'; import { CountryCodeType } from '../types'; -import { I18NIFY_DATA_SOURCE } from './constants'; +import { I18NIFY_DATA_SOURCE } from '../sourceConstants'; import { CountryMetaType } from './types'; /** diff --git a/packages/i18nify-js/src/modules/geo/getCities.ts b/packages/i18nify-js/src/modules/geo/getCities.ts index c204d1f8..66d83ab4 100644 --- a/packages/i18nify-js/src/modules/geo/getCities.ts +++ b/packages/i18nify-js/src/modules/geo/getCities.ts @@ -2,7 +2,7 @@ import { withErrorBoundary } from '../../common/errorBoundary'; import { I18NIFY_DATA_SOURCE, I18NIFY_DATA_SUPPORTED_COUNTRIES, -} from './constants'; +} from '../sourceConstants'; import { I18nifyCountryCodeType } from './types'; /** diff --git a/packages/i18nify-js/src/modules/geo/getFlagOfCountry.ts b/packages/i18nify-js/src/modules/geo/getFlagOfCountry.ts index af642f3a..8ec82f58 100644 --- a/packages/i18nify-js/src/modules/geo/getFlagOfCountry.ts +++ b/packages/i18nify-js/src/modules/geo/getFlagOfCountry.ts @@ -1,6 +1,6 @@ import { CountryCodeType, GetFlagReturnType } from '../types'; import { withErrorBoundary } from '../../common/errorBoundary'; -import { FLAG_4X3_BASE_PATH, FLAG_BASE_PATH } from './constants'; +import { FLAG_4X3_BASE_PATH, FLAG_BASE_PATH } from '../sourceConstants'; import { isCountryValid } from './utils'; /** diff --git a/packages/i18nify-js/src/modules/geo/getFlagsForAllCountries.ts b/packages/i18nify-js/src/modules/geo/getFlagsForAllCountries.ts index ba2a6a15..17549363 100644 --- a/packages/i18nify-js/src/modules/geo/getFlagsForAllCountries.ts +++ b/packages/i18nify-js/src/modules/geo/getFlagsForAllCountries.ts @@ -1,6 +1,6 @@ import { withErrorBoundary } from '../../common/errorBoundary'; import { LIST_OF_ALL_COUNTRIES } from './data/listOfAllCountries'; -import { FLAG_4X3_BASE_PATH, FLAG_BASE_PATH } from './constants'; +import { FLAG_4X3_BASE_PATH, FLAG_BASE_PATH } from '../sourceConstants'; import { GetFlagReturnType, CountryCodeType } from '../types'; /** diff --git a/packages/i18nify-js/src/modules/geo/getStates.ts b/packages/i18nify-js/src/modules/geo/getStates.ts index a2778e7e..0fb1a9c1 100644 --- a/packages/i18nify-js/src/modules/geo/getStates.ts +++ b/packages/i18nify-js/src/modules/geo/getStates.ts @@ -2,7 +2,7 @@ import { withErrorBoundary } from '../../common/errorBoundary'; import { I18NIFY_DATA_SOURCE, I18NIFY_DATA_SUPPORTED_COUNTRIES, -} from './constants'; +} from '../sourceConstants'; import { I18nifyCountryCodeType } from './types'; /** diff --git a/packages/i18nify-js/src/modules/geo/getZipcodes.ts b/packages/i18nify-js/src/modules/geo/getZipcodes.ts index 6c770a78..ec749f88 100644 --- a/packages/i18nify-js/src/modules/geo/getZipcodes.ts +++ b/packages/i18nify-js/src/modules/geo/getZipcodes.ts @@ -3,7 +3,7 @@ import { CountryCodeType } from '../types'; import { I18NIFY_DATA_SOURCE, I18NIFY_DATA_SUPPORTED_COUNTRIES, -} from './constants'; +} from '../sourceConstants'; import { CountryDetailType } from './types'; /** diff --git a/packages/i18nify-js/src/modules/geo/constants.ts b/packages/i18nify-js/src/modules/sourceConstants.ts similarity index 100% rename from packages/i18nify-js/src/modules/geo/constants.ts rename to packages/i18nify-js/src/modules/sourceConstants.ts From fe2fbca822af17274604275da5d334065bd3d14f Mon Sep 17 00:00:00 2001 From: RgnDunes Date: Wed, 29 Jan 2025 12:22:26 +0530 Subject: [PATCH 6/8] add docs --- packages/i18nify-js/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/i18nify-js/README.md b/packages/i18nify-js/README.md index 42e7399a..2d941256 100644 --- a/packages/i18nify-js/README.md +++ b/packages/i18nify-js/README.md @@ -1175,3 +1175,23 @@ Simplify time tracking and events in your app, concentrating solely on time with ##### ZonedDateTime 🌍🕖 [Documentation here](https://react-spectrum.adobe.com/internationalized/date/ZonedDateTime.html) Master global time zones for scheduling and planning across borders, ensuring accuracy and user relevance. + +### Module 05: Banking + +This module's your financial sidekick for all things banking! 🏦💰 Whether you're looking for bank codes or planning to integrate banking details seamlessly into your app, this module has got you covered. No more hunting for bank-specific data—just plug and play! Here are the handy APIs this Banking Module brings to your toolkit. 🚀💳 + +#### getBankCode(\_countryCode, bankName) + +🏦🔍 Need a bank's code in a specific country? This function has your back! Just pass the country code and the exact bank name, and it'll fetch the bank code for you from the central i18nify data source. If the bank or country isn't supported, it'll give you a heads-up with a helpful error. No more guessing or manual lookups—get the right bank code in seconds! + +##### Examples + +```javascript +getBankCode('IN', 'Abhyudaya Co-operative Bank') + .then((code) => console.log(code)) // Outputs the bank code for SBI in India (e.g., "ABHY") + .catch((err) => console.error(err.message)); + +getBankCode('US', 'Bank of America CORPORATION') + .then((code) => console.log(code)) // Outputs the bank code for Bank of America (e.g., "MLCO") + .catch((err) => console.error(err.message)); +``` From 85460ef42437130ffc46ba12444d8c16c86590ba Mon Sep 17 00:00:00 2001 From: RgnDunes Date: Wed, 29 Jan 2025 18:43:56 +0530 Subject: [PATCH 7/8] remove redudant files --- packages/i18nify-js/src/modules/sourceConstants.ts | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 packages/i18nify-js/src/modules/sourceConstants.ts diff --git a/packages/i18nify-js/src/modules/sourceConstants.ts b/packages/i18nify-js/src/modules/sourceConstants.ts deleted file mode 100644 index 843004c8..00000000 --- a/packages/i18nify-js/src/modules/sourceConstants.ts +++ /dev/null @@ -1,8 +0,0 @@ -export const FLAG_4X3_BASE_PATH = - 'https://unpkg.com/@razorpay/i18nify-js/lib/assets/flags'; -export const FLAG_BASE_PATH = 'https://flagcdn.com'; - -export const I18NIFY_DATA_SOURCE = - 'https://raw.githubusercontent.com/razorpay/i18nify/update_country_data/i18nify-data'; - -export const I18NIFY_DATA_SUPPORTED_COUNTRIES = ['IN', 'MY', 'SG', 'US']; From 74d521903117fd194c8b211dfa1e171a2a4d50ff Mon Sep 17 00:00:00 2001 From: RgnDunes Date: Wed, 29 Jan 2025 18:45:03 +0530 Subject: [PATCH 8/8] fix import path --- packages/i18nify-js/src/modules/banking/getBankCode.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/i18nify-js/src/modules/banking/getBankCode.ts b/packages/i18nify-js/src/modules/banking/getBankCode.ts index 39147d30..0edd8347 100644 --- a/packages/i18nify-js/src/modules/banking/getBankCode.ts +++ b/packages/i18nify-js/src/modules/banking/getBankCode.ts @@ -2,7 +2,7 @@ import { withErrorBoundary } from '../../common/errorBoundary'; import { I18NIFY_DATA_SOURCE, I18NIFY_DATA_SUPPORTED_COUNTRIES, -} from '../sourceConstants'; +} from '../shared'; import { I18nifyCountryCodeType } from '../geo/types'; /**