diff --git a/README.md b/README.md index 9bde0fa..2cab523 100644 --- a/README.md +++ b/README.md @@ -820,6 +820,17 @@ Returns the [Topaz](https://www.topaz.com.br/ofd/index.php) token. getTopazToken = (options: {timeout?: number} = {}) => Promise<{token: string}> ``` +### getTopazValues + +App version >=24.9 + +Returns an object containing values from the +[Topaz](https://www.topaz.com.br/ofd/index.php) SDK. + +```ts +getTopazValues = () => Promise<{syncId?: string}> +``` + ### showAppRating Show native app rating dialog diff --git a/index.ts b/index.ts index b34bc88..4e9c9d3 100644 --- a/index.ts +++ b/index.ts @@ -40,6 +40,7 @@ export { getNetworkConnectionInfo, setActionBehavior, getTopazToken, + getTopazValues, getPincodeInfo, onNavigationBarIconClicked, triggerPinOrBiometricAuthentication, diff --git a/src/__tests__/utils-test.ts b/src/__tests__/utils-test.ts index b67b718..5405617 100644 --- a/src/__tests__/utils-test.ts +++ b/src/__tests__/utils-test.ts @@ -15,7 +15,11 @@ import { createFakeAndroidPostMessage, removeFakeAndroidPostMessage, } from './fake-post-message'; -import {getAppMetadata, getNetworkConnectionInfo} from '../utils'; +import { + getAppMetadata, + getNetworkConnectionInfo, + getTopazValues, +} from '../utils'; const ANY_STRING = 'any-string'; const ANY_OTHER_STRING = 'any-other-string'; @@ -627,3 +631,23 @@ test('set confirm action behavior', (done) => { done(); }); }); + +test('get Topaz values', async () => { + const syncId = 'id'; + + createFakeAndroidPostMessage({ + checkMessage: (message) => { + expect(message.type).toBe('GET_TOPAZ_VALUES'); + expect(message.payload).toEqual({}); + }, + getResponse: (message) => ({ + type: message.type, + id: message.id, + payload: {syncId}, + }), + }); + + await getTopazValues().then((res) => { + expect(res).toEqual({syncId}); + }); +}); diff --git a/src/post-message.ts b/src/post-message.ts index 1e4584f..27b8398 100644 --- a/src/post-message.ts +++ b/src/post-message.ts @@ -239,6 +239,11 @@ export type ResponsesFromNativeApp = { id: string; payload: {token: string}; }; + GET_TOPAZ_VALUES: { + type: 'GET_TOPAZ_VALUES'; + id: string; + payload: {syncId?: string}; + }; LOG_OUT: { type: 'LOG_OUT'; id: string; diff --git a/src/utils.ts b/src/utils.ts index 62918d5..5e64872 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -308,6 +308,12 @@ export const getTopazToken = ( options.timeout, ); +export const getTopazValues = (): Promise<{syncId?: string}> => + postMessageToNativeApp({ + type: 'GET_TOPAZ_VALUES', + payload: {}, + }); + export const getPincodeInfo = (): Promise<{status: 'enabled' | 'disabled'}> => postMessageToNativeApp({type: 'GET_PINCODE_INFO'});