|
13 | 13 |
|
14 | 14 | API_BASE = "https://api.revolut.com"
|
15 | 15 | _URL_GET_ACCOUNTS = API_BASE + "/user/current/wallet"
|
16 |
| -_URL_GET_TRANSACTIONS_LAST = API_BASE +'/user/current/transactions/last' |
| 16 | +_URL_GET_TRANSACTIONS_LAST = API_BASE + "/user/current/transactions/last" |
17 | 17 | _URL_QUOTE = API_BASE + "/quote/"
|
18 | 18 | _URL_EXCHANGE = API_BASE + "/exchange"
|
19 | 19 | _URL_GET_TOKEN_STEP1 = API_BASE + "/signin"
|
@@ -146,14 +146,16 @@ def _get(self, url, *, expected_status_code=200, **kwargs):
|
146 | 146 | ret = self.session.get(url=url, **kwargs)
|
147 | 147 | if ret.status_code != expected_status_code:
|
148 | 148 | raise ConnectionError(
|
149 |
| - f'Status code {ret.status_code} for url {url}\n{ret.text}') |
| 149 | + 'Status code {} for url {}\n{}'.format( |
| 150 | + ret.status_code, url, ret.text)) |
150 | 151 | return ret
|
151 | 152 |
|
152 | 153 | def _post(self, url, *, expected_status_code=200, **kwargs):
|
153 | 154 | ret = self.session.post(url=url, **kwargs)
|
154 | 155 | if ret.status_code != expected_status_code:
|
155 | 156 | raise ConnectionError(
|
156 |
| - f'Status code {ret.status_code} for url {url}\n{ret.text}') |
| 157 | + 'Status code {} for url {}\n{}'.format( |
| 158 | + ret.status_code, url, ret.text)) |
157 | 159 | return ret
|
158 | 160 |
|
159 | 161 |
|
@@ -471,7 +473,7 @@ def get_token_step1(device_id, phone, password, simulate=False):
|
471 | 473 | c = Client(device_id=device_id, token=_DEFAULT_TOKEN_FOR_SIGNIN)
|
472 | 474 | data = {"phone": phone, "password": password}
|
473 | 475 | ret = c._post(_URL_GET_TOKEN_STEP1, json=data)
|
474 |
| - channel = ret.json().get('channel') |
| 476 | + channel = ret.json().get("channel") |
475 | 477 | return channel
|
476 | 478 |
|
477 | 479 |
|
@@ -506,17 +508,17 @@ def get_token_step2(device_id, phone, code, simulate=False):
|
506 | 508 | def extract_token(json_response):
|
507 | 509 | user_id = json_response["user"]["id"]
|
508 | 510 | access_token = json_response["accessToken"]
|
509 |
| - token_to_encode = f'{user_id}:{access_token}'.encode('ascii') |
| 511 | + token_to_encode = '{}:{}'.format(user_id, access_token).encode("ascii") |
510 | 512 | # Ascii encoding required by b64encode function : 8 bits char as input
|
511 | 513 | token = base64.b64encode(token_to_encode)
|
512 |
| - return token.decode('ascii') |
| 514 | + return token.decode("ascii") |
513 | 515 |
|
514 | 516 |
|
515 | 517 | def signin_biometric(device_id, phone, access_token, selfie_filepath):
|
516 |
| - files = {'selfie': open(selfie_filepath,'rb')} |
| 518 | + files = {"selfie": open(selfie_filepath, "rb")} |
517 | 519 | c = Client(device_id=device_id, token=_DEFAULT_TOKEN_FOR_SIGNIN)
|
518 | 520 | c.session.auth = (phone, access_token)
|
519 |
| - res = c._post('https://api.revolut.com/biometric-signin/selfie', files=files) |
520 |
| - biometric_id = res.json()['id'] |
521 |
| - res = c._post(f'https://api.revolut.com/biometric-signin/confirm/{biometric_id}') |
| 521 | + res = c._post(API_BASE + "/biometric-signin/selfie", files=files) |
| 522 | + biometric_id = res.json()["id"] |
| 523 | + res = c._post(API_BASE + "/biometric-signin/confirm/" + biometric_id) |
522 | 524 | return res.json()
|
0 commit comments