@@ -66,6 +66,7 @@ class TutiApiClient(
6666
6767 var isSingleThreaded = false
6868 @Volatile var authToken: String = " "
69+ @Volatile var defaultHeaders: Map <String , String > = emptyMap()
6970 var ipinUsername: String = " "
7071 var ipinPassword: String = " "
7172 var ebsKey: String = " MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANx4gKYSMv3CrWWsxdPfxDxFvl+Is/0kc1dvMI1yNWDXI3AgdI4127KMUOv7gmwZ6SnRsHX/KAM0IPRe0+Sa0vMCAwEAAQ=="
@@ -102,6 +103,22 @@ class TutiApiClient(
102103 return request
103104 }
104105
106+ private fun normalizeLegacyAuthRequest (
107+ credentials : SignInRequest ? ,
108+ ): com.tuti.model.SignInRequest ? {
109+ if (credentials == null ) {
110+ return null
111+ }
112+ return com.tuti.model.SignInRequest (
113+ password = credentials.password,
114+ otp = credentials.otp,
115+ mobile = credentials.mobile.ifBlank { credentials.username },
116+ auth = credentials.oldToken,
117+ signature = credentials.signature,
118+ message = credentials.message,
119+ )
120+ }
121+
105122 @Deprecated(
106123 message = " Replace with SignIn with new kotlin classes instead." ,
107124 replaceWith = ReplaceWith (" SignIn" )
@@ -114,7 +131,7 @@ class TutiApiClient(
114131 sendRequest(
115132 RequestMethods .POST ,
116133 consumerURL + Operations .SIGN_IN ,
117- credentials,
134+ normalizeLegacyAuthRequest( credentials) ,
118135 onResponse,
119136 onError
120137 )
@@ -309,7 +326,7 @@ class TutiApiClient(
309326 sendRequest(
310327 RequestMethods .POST ,
311328 consumerURL + Operations .SINGLE_SIGN_IN ,
312- credentials,
329+ normalizeLegacyAuthRequest( credentials) ,
313330 onResponse,
314331 onError
315332 )
@@ -355,7 +372,7 @@ class TutiApiClient(
355372 sendRequest(
356373 RequestMethods .POST ,
357374 consumerURL + Operations .GENERATE_LOGIN_OTP_INSECURE ,
358- credentials,
375+ normalizeLegacyAuthRequest( credentials) ,
359376 onResponse,
360377 onError
361378 )
@@ -406,7 +423,7 @@ class TutiApiClient(
406423 sendRequest(
407424 RequestMethods .POST ,
408425 consumerURL + Operations .REFRESH_TOKEN ,
409- credentials,
426+ normalizeLegacyAuthRequest( credentials) ,
410427 onResponse,
411428 onError
412429 )
@@ -1045,14 +1062,9 @@ class TutiApiClient(
10451062
10461063
10471064 /* *
1048- * billInfo gets a bill from EBS using a pre-stored data, only send applicable bill fields
1049- * plus the type of transaction
1050- *
1051- * @param billInfo
1052- * @param onResponse
1053- * @param onError
1065+ * Calls the legacy `/consumer/bills` helper, where the server injects its configured inquiry PAN/IPIN.
10541066 */
1055- fun billInquiry (
1067+ fun getBills (
10561068 billInfo : BillInfo ,
10571069 onResponse : (TutiResponse ) -> Unit ,
10581070 onError : (TutiResponse ? , Exception ? ) -> Unit ,
@@ -1066,6 +1078,39 @@ class TutiApiClient(
10661078 )
10671079 }
10681080
1081+ /* *
1082+ * Retained for compatibility. This overload maps to `/consumer/bills`.
1083+ * Use [getBills] for this flow, or [billInquiry] with [EBSRequest] for `/consumer/bill_inquiry`.
1084+ */
1085+ @Deprecated(
1086+ message = " This overload calls /consumer/bills. Use getBills(BillInfo, ...) or billInquiry(EBSRequest, ...)." ,
1087+ replaceWith = ReplaceWith (" getBills(billInfo, onResponse, onError)" )
1088+ )
1089+ fun billInquiry (
1090+ billInfo : BillInfo ,
1091+ onResponse : (TutiResponse ) -> Unit ,
1092+ onError : (TutiResponse ? , Exception ? ) -> Unit ,
1093+ ): Call {
1094+ return getBills(billInfo, onResponse, onError)
1095+ }
1096+
1097+ /* *
1098+ * Direct bill inquiry against `/consumer/bill_inquiry` using an explicit EBS-style request.
1099+ */
1100+ fun billInquiry (
1101+ request : EBSRequest ,
1102+ onResponse : (TutiResponse ) -> Unit ,
1103+ onError : (TutiResponse ? , Exception ? ) -> Unit ,
1104+ ): Call {
1105+ return sendRequest(
1106+ RequestMethods .POST ,
1107+ consumerURL + Operations .BILL_INQUIRY ,
1108+ request,
1109+ onResponse,
1110+ onError,
1111+ )
1112+ }
1113+
10691114 fun cardTransfer (
10701115 card : Card ,
10711116 ipin : String ,
@@ -1684,6 +1729,10 @@ class TutiApiClient(
16841729 if (token.isNotBlank()) {
16851730 requestBuilder.header(" Authorization" , token)
16861731 }
1732+ val headerSnapshot = defaultHeaders
1733+ headerSnapshot.forEach { (key, value) ->
1734+ requestBuilder.header(key, value)
1735+ }
16871736 return okHttpClient.newWebSocket(requestBuilder.build(), listener)
16881737 }
16891738
@@ -1713,6 +1762,10 @@ class TutiApiClient(
17131762 requestBuilder.header(" Authorization" , tokenSnapshot)
17141763 }
17151764 requestBuilder.header(" Accept" , " application/json" )
1765+ val defaultHeaderSnapshot = defaultHeaders
1766+ defaultHeaderSnapshot.forEach { (key, value) ->
1767+ requestBuilder.header(key, value)
1768+ }
17161769
17171770 // add additional headers set by the user
17181771 headers?.forEach { (key, value) ->
0 commit comments