esewa-ui-library 1.10.6 → 1.10.7

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/README.md CHANGED
@@ -1623,6 +1623,8 @@ This library provides a set of services that allow interaction between the merch
1623
1623
  - [Media Access Request](#media-access-request)
1624
1624
  - [Validate Payment](#validate-payment)
1625
1625
  - [Request Payment](#request-payment)
1626
+ - [Close App](#close-app)
1627
+ - [Request File Download](#request-file-download)
1626
1628
  - [Error Handling](#error-handling)
1627
1629
 
1628
1630
  ## Initialization
@@ -1881,6 +1883,89 @@ const onCloseRequestClick = () => {
1881
1883
  }
1882
1884
  ```
1883
1885
 
1886
+ #### Request File Download
1887
+
1888
+ Pass the following to request file download.
1889
+
1890
+ **1. Link Type file download request**
1891
+
1892
+ const onPdfDownloadRequestClick = () => {
1893
+ const obj: REQUEST_DATA_TYPE = {
1894
+ requestType: REQUEST_TYPE_ENUM.FILE_DOWNLOAD,
1895
+ callbackKey: CALLBACK_TYPE_ENUM.FILE_DOWNLOAD_CALLBACK,
1896
+ data: {
1897
+ fileName: 'Statement-2025.pdf',
1898
+ type: 'url',
1899
+ content: 'https://www.aeee.in/wp-content/uploads/2020/08/Sample-pdf.pdf' //pass file url
1900
+ }
1901
+ }
1902
+
1903
+ const fileDownloadCallBack: any = (data: any) => {
1904
+ try{
1905
+ if (!data) {
1906
+ throw new Error('Received null or undefined response')
1907
+ }
1908
+ const res = data
1909
+ if (res?.error_message) { //fail case
1910
+ throw new Error('Error res', res.error_message)
1911
+ }
1912
+ else{
1913
+ console.log(res.message) //success case
1914
+ }
1915
+ }
1916
+ catch (error) {
1917
+ console.error('Error parsing response:', error)
1918
+ }
1919
+ }
1920
+
1921
+ requestFromMiniApp(
1922
+ obj,
1923
+ fileDownloadCallBack
1924
+ )
1925
+ }
1926
+
1927
+ **2. Base64 Encoded Type file download request**
1928
+
1929
+ const onPdfDownloadRequestClick = () => {
1930
+ const response = await fetch('/base64.txt');
1931
+ const content = await response.text(); //encoded pdf content/response from api
1932
+ let base64Content = content.includes(',')
1933
+ ? content
1934
+ : `data:application/pdf;base64,${content}`;
1935
+ const obj: REQUEST_DATA_TYPE = {
1936
+ requestType: REQUEST_TYPE_ENUM.FILE_DOWNLOAD,
1937
+ callbackKey: CALLBACK_TYPE_ENUM.FILE_DOWNLOAD_CALLBACK,
1938
+ data: {
1939
+ fileName: 'Statement-base64-2025.pdf',
1940
+ type: 'base64',
1941
+ content: base64Content
1942
+ }
1943
+ }
1944
+
1945
+ const fileDownloadCallBack: any = (data: any) => {
1946
+ try{
1947
+ if (!data) {
1948
+ throw new Error('Received null or undefined response')
1949
+ }
1950
+ const res = data
1951
+ if (res?.error_message) { //fail case
1952
+ throw new Error('Error res', res.error_message)
1953
+ }
1954
+ else{
1955
+ console.log(res.message) //success case
1956
+ }
1957
+ }
1958
+ catch (error) {
1959
+ console.error('Error parsing response:', error)
1960
+ }
1961
+ }
1962
+
1963
+ requestFromMiniApp(
1964
+ obj,
1965
+ fileDownloadCallBack
1966
+ )
1967
+ }
1968
+
1884
1969
  ## Error Handling
1885
1970
 
1886
1971
  Errors are returned as JSON responses with an `error_message` field.
@@ -1928,7 +2013,8 @@ enum REQUEST_TYPE_ENUM {
1928
2013
  MEDIA_ACCESS = 'MEDIA_ACCESS',
1929
2014
  LOCATION_ACCESS = 'LOCATION_ACCESS',
1930
2015
  VALIDATE_TRANSACTION = 'VALIDATE_TRANSACTION',
1931
- CLOSE_APP = 'CLOSE_APP'
2016
+ CLOSE_APP = 'CLOSE_APP',
2017
+ FILE_DOWNLOAD = 'FILE_DOWNLOAD'
1932
2018
  }
1933
2019
  ```
1934
2020
 
@@ -1946,7 +2032,8 @@ enum CALLBACK_TYPE_ENUM{
1946
2032
  MEDIA_ACCESS_CALLBACK = 'MEDIA_ACCESS_CALLBACK',
1947
2033
  LOCATION_ACCESS_CALLBACK = 'LOCATION_ACCESS_CALLBACK',
1948
2034
  VALIDATE_TRANSACTION_CALLBACK = 'VALIDATE_TRANSACTION_CALLBACK',
1949
- CLOSE_APP_CALLBACK = 'CLOSE_APP_CALLBACK'
2035
+ CLOSE_APP_CALLBACK = 'CLOSE_APP_CALLBACK',
2036
+ FILE_DOWNLOAD_CALLBACK = 'FILE_DOWNLOAD_CALLBACK'
1950
2037
  }
1951
2038
  ```
1952
2039
 
@@ -5,7 +5,8 @@ export declare enum REQUEST_TYPE_ENUM {
5
5
  MEDIA_ACCESS = "MEDIA_ACCESS",
6
6
  LOCATION_ACCESS = "LOCATION_ACCESS",
7
7
  VALIDATE_TRANSACTION = "VALIDATE_TRANSACTION",
8
- CLOSE_APP = "CLOSE_APP"
8
+ CLOSE_APP = "CLOSE_APP",
9
+ FILE_DOWNLOAD = "FILE_DOWNLOAD"
9
10
  }
10
11
  export declare enum CALLBACK_TYPE_ENUM {
11
12
  INIT_APP_CALLBACK = "INIT_APP_CALLBACK",
@@ -14,7 +15,8 @@ export declare enum CALLBACK_TYPE_ENUM {
14
15
  MEDIA_ACCESS_CALLBACK = "MEDIA_ACCESS_CALLBACK",
15
16
  LOCATION_ACCESS_CALLBACK = "LOCATION_ACCESS_CALLBACK",
16
17
  VALIDATE_TRANSACTION_CALLBACK = "VALIDATE_TRANSACTION_CALLBACK",
17
- CLOSE_APP_CALLBACK = "CLOSE_APP_CALLBACK"
18
+ CLOSE_APP_CALLBACK = "CLOSE_APP_CALLBACK",
19
+ FILE_DOWNLOAD_CALLBACK = "FILE_DOWNLOAD_CALLBACK"
18
20
  }
19
21
  export interface MINI_APP_RESPONSE_TYPE {
20
22
  requestType: string;
@@ -47,6 +49,7 @@ declare global {
47
49
  LOCATION_ACCESS_CALLBACK?: Callback | null;
48
50
  VALIDATE_TRANSACTION_CALLBACK?: Callback | null;
49
51
  CLOSE_APP_CALLBACK?: Callback | null;
52
+ FILE_DOWNLOAD_CALLBACK?: Callback | null;
50
53
  };
51
54
  iOSNative: {
52
55
  INIT_APP_CALLBACK?: Callback | null;
@@ -56,6 +59,7 @@ declare global {
56
59
  LOCATION_ACCESS_CALLBACK?: Callback | null;
57
60
  VALIDATE_TRANSACTION_CALLBACK?: Callback | null;
58
61
  CLOSE_APP_CALLBACK?: Callback | null;
62
+ FILE_DOWNLOAD_CALLBACK?: Callback | null;
59
63
  };
60
64
  webkit: {
61
65
  messageHandlers: {
package/dist/index.js CHANGED
@@ -7814,6 +7814,7 @@ var reverseSnakeCase = function reverseSnakeCase(str) {
7814
7814
  REQUEST_TYPE_ENUM["LOCATION_ACCESS"] = "LOCATION_ACCESS";
7815
7815
  REQUEST_TYPE_ENUM["VALIDATE_TRANSACTION"] = "VALIDATE_TRANSACTION";
7816
7816
  REQUEST_TYPE_ENUM["CLOSE_APP"] = "CLOSE_APP";
7817
+ REQUEST_TYPE_ENUM["FILE_DOWNLOAD"] = "FILE_DOWNLOAD";
7817
7818
  })(exports.REQUEST_TYPE_ENUM || (exports.REQUEST_TYPE_ENUM = {}));
7818
7819
  (function (CALLBACK_TYPE_ENUM) {
7819
7820
  CALLBACK_TYPE_ENUM["INIT_APP_CALLBACK"] = "INIT_APP_CALLBACK";
@@ -7823,6 +7824,7 @@ var reverseSnakeCase = function reverseSnakeCase(str) {
7823
7824
  CALLBACK_TYPE_ENUM["LOCATION_ACCESS_CALLBACK"] = "LOCATION_ACCESS_CALLBACK";
7824
7825
  CALLBACK_TYPE_ENUM["VALIDATE_TRANSACTION_CALLBACK"] = "VALIDATE_TRANSACTION_CALLBACK";
7825
7826
  CALLBACK_TYPE_ENUM["CLOSE_APP_CALLBACK"] = "CLOSE_APP_CALLBACK";
7827
+ CALLBACK_TYPE_ENUM["FILE_DOWNLOAD_CALLBACK"] = "FILE_DOWNLOAD_CALLBACK";
7826
7828
  })(exports.CALLBACK_TYPE_ENUM || (exports.CALLBACK_TYPE_ENUM = {}));
7827
7829
 
7828
7830
  var _templateObject$o;