@@ -291,84 +291,49 @@ async def getCardTransactionHistory(self, cardNo: str, from_date: datetime.datet
291
291
json = json_data )
292
292
return data_out
293
293
294
- async def userinfo (self ):
294
+ async def getBankList (self ):
295
295
"""
296
- Get current user info
296
+ Get transfer all bank list
297
297
298
298
Returns:
299
- success (dict): user info
299
+ success (dict): bank list
300
300
301
301
Raises:
302
302
MBBankError: if api response not ok
303
303
"""
304
- if self ._userinfo is None :
305
- await self ._authenticate ()
306
- else :
307
- await self .getBalance ()
308
- return self ._userinfo
309
-
310
- # working on beta
311
-
312
- async def getBankList (self ):
313
304
data_out = await self ._req ("https://online.mbbank.com.vn/api/retail_web/common/getBankList" )
314
305
return data_out
315
306
316
- async def inquiryAccountName (self , * , typeTransfer : str = None , debitAccount : str , bankCode : str = None ,
317
- creditAccount : str , creditAccountType : typing .Literal ["ACCOUNT" , "CARD" ]):
318
- creditCardNo = None
319
- if (bankCode is None or typeTransfer is None ) and creditAccountType != "CARD" :
320
- raise TypeError ("creditAccount must be \" CARD\" so bankCode or typeTransfer can be None" )
321
- elif creditAccountType == "CARD" :
322
- out = await self .getBankList ()
323
- for i in out ['listBank' ]:
324
- bankCode = None
325
- typeTransfer = None
326
- if creditAccount .startswith (i ["smlCode" ]):
327
- bankCode = i ["smlCode" ]
328
- typeTransfer = i ["typeTransfer" ]
329
- datacard = await self .cardGenerateID (creditAccount )
330
- creditCardNo = datacard ["cardNumber" ]
331
- creditAccount = datacard ["cardID" ]
332
- break
333
- if bankCode is None or typeTransfer is None :
334
- raise Exception (f"Invaild card" )
335
- elif not creditAccount :
336
- raise Exception (f"Card not exist" )
337
- json_data = {
338
- "creditAccount" : creditAccount ,
339
- "creditAccountType" : creditAccountType ,
340
- "bankCode" : bankCode ,
341
- "debitAccount" : debitAccount ,
342
- "type" : typeTransfer ,
343
- "remark" : "" ,
344
- }
345
- if creditCardNo is not None :
346
- json_data .setdefault ("creditCardNo" , creditCardNo )
347
- data_out = await self ._req ("https://online.mbbank.com.vn/api/retail_web/transfer/inquiryAccountName" ,
348
- json = json_data )
349
- return data_out
307
+ async def getAccountByPhone (self , phone : str ):
308
+ """
309
+ Get transfer account info by phone (MBank internal account only)
350
310
351
- async def getServiceToken (self ):
352
- data_out = await self ._req ("https://online.mbbank.com.vn/api/retail_web/common/getServiceToken" )
353
- return data_out
311
+ Args:
312
+ phone (str): MBBank account phone number
354
313
355
- async def cardGenerateID (self , cardNumber : str ):
356
- headers = headers_default .copy ()
357
- json_data = {
358
- "requestID" : f"{ self .__userid } -{ get_now_time ()} " ,
359
- "cardNumber" : cardNumber
360
- }
361
- tok = await self .getServiceToken ()
362
- headers ["Authorization" ] = tok ["type" ].capitalize () + " " + tok ["token" ]
363
- async with aiohttp .ClientSession () as s :
364
- async with s .post ("https://mbcard.mbbank.com.vn:8446/mbcardgw/internet/cardinfo/v1_0/generateid" ,
365
- headers = headers , json = json_data ) as r :
366
- return await r .json ()
314
+ Returns:
315
+ success (dict): account info
367
316
368
- async def getAccountByPhone ( self , phone : str ):
317
+ """
369
318
json_data = {
370
319
"phone" : phone
371
320
}
372
321
data_out = await self ._req ("https://online.mbbank.com.vn/api/retail_web/common/getAccountByPhone" ,
373
322
json = json_data )
374
323
return data_out
324
+
325
+ async def userinfo (self ):
326
+ """
327
+ Get current user info
328
+
329
+ Returns:
330
+ success (dict): user info
331
+
332
+ Raises:
333
+ MBBankError: if api response not ok
334
+ """
335
+ if self ._userinfo is None :
336
+ await self ._authenticate ()
337
+ else :
338
+ await self .getBalance ()
339
+ return self ._userinfo
0 commit comments