diff --git a/incognia/api.py b/incognia/api.py index 994d360..0c6d026 100644 --- a/incognia/api.py +++ b/incognia/api.py @@ -32,6 +32,8 @@ def __get_authorization_header(self) -> dict: def register_new_signup(self, request_token: Optional[str], + tenant_id: Optional[str] = None, + related_web_request_token: Optional[str] = None, address_line: Optional[str] = None, structured_address: Optional[StructuredAddress] = None, address_coordinates: Optional[Coordinates] = None, @@ -50,6 +52,8 @@ def register_new_signup(self, headers.update(JSON_CONTENT_HEADER) body = { 'request_token': request_token, + 'tenant_id': tenant_id, + 'related_web_request_token': related_web_request_token, 'address_line': address_line, 'structured_address': structured_address, 'address_coordinates': address_coordinates, @@ -69,6 +73,7 @@ def register_new_signup(self, def register_new_web_signup(self, request_token: Optional[str], + tenant_id: Optional[str] = None, policy_id: Optional[str] = None, account_id: Optional[str] = None, custom_properties: Optional[dict] = None, @@ -81,6 +86,7 @@ def register_new_web_signup(self, headers.update(JSON_CONTENT_HEADER) body = { 'request_token': request_token, + 'tenant_id': tenant_id, 'policy_id': policy_id, 'account_id': account_id, 'custom_properties': custom_properties, @@ -152,7 +158,9 @@ def register_payment(self, store_id: Optional[str] = None, person_id: Optional[PersonID] = None, debtor_account: Optional[BankAccountInfo] = None, - creditor_account: Optional[BankAccountInfo] = None) -> dict: + creditor_account: Optional[BankAccountInfo] = None, + tenant_id: Optional[str] = None, + related_web_request_token: Optional[str] = None) -> dict: if not request_token: raise IncogniaError('request_token is required.') if not account_id: @@ -190,6 +198,8 @@ def register_payment(self, 'person_id': person_id, 'debtor_account': debtor_account, 'creditor_account': creditor_account, + 'tenant_id': tenant_id, + 'related_web_request_token': related_web_request_token, } data = encode(body) return self.__request.post(Endpoints.TRANSACTIONS, headers=headers, params=params, @@ -208,7 +218,9 @@ def register_login(self, device_os: Optional[str] = None, app_version: Optional[str] = None, custom_properties: Optional[dict] = None, - person_id: Optional[PersonID] = None) -> dict: + person_id: Optional[PersonID] = None, + tenant_id: Optional[str] = None, + related_web_request_token: Optional[str] = None) -> dict: if not request_token: raise IncogniaError('request_token is required.') @@ -240,6 +252,8 @@ def register_login(self, 'app_version': app_version, 'custom_properties': custom_properties, 'person_id': person_id, + 'tenant_id': tenant_id, + 'related_web_request_token': related_web_request_token, } data = encode(body) return self.__request.post(Endpoints.TRANSACTIONS, headers=headers, params=params, @@ -255,7 +269,8 @@ def register_web_login(self, evaluate: Optional[bool] = None, policy_id: Optional[str] = None, custom_properties: Optional[dict] = None, - person_id: Optional[PersonID] = None) -> dict: + person_id: Optional[PersonID] = None, + tenant_id: Optional[str] = None) -> dict: if not request_token: raise IncogniaError('request_token is required.') if not account_id: @@ -273,6 +288,7 @@ def register_web_login(self, 'policy_id': policy_id, 'custom_properties': custom_properties, 'person_id': person_id, + 'tenant_id': tenant_id, } data = encode(body) return self.__request.post(Endpoints.TRANSACTIONS, headers=headers, params=params, diff --git a/tests/test_api.py b/tests/test_api.py index 3b41c2a..eee298e 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -22,6 +22,8 @@ class TestIncogniaAPI(TestCase): ADDRESS_LINE: Final[str] = 'ANY_ADDRESS_LINE' DEVICE_OS: Final[str] = 'ANY_DEVICE_OS' APP_VERSION: Final[str] = 'ANY_APP_VERSION' + TENANT_ID: Final[str] = 'TENANT_ID' + RELATED_WEB_REQUEST_TOKEN: Final[str] = 'RELATED_WEB_REQUEST_TOKEN' PERSON_ID: Final[dict] = { 'type': 'cpf', 'value': '12345678901' @@ -72,6 +74,8 @@ class TestIncogniaAPI(TestCase): } FULL_REGISTER_SIGNUP_DATA: Final[bytes] = encode({ 'request_token': f'{REQUEST_TOKEN}', + 'tenant_id': TENANT_ID, + 'related_web_request_token': RELATED_WEB_REQUEST_TOKEN, 'address_line': f'{ADDRESS_LINE}', 'structured_address': STRUCTURED_ADDRESS, 'address_coordinates': ADDRESS_COORDINATES, @@ -91,6 +95,7 @@ class TestIncogniaAPI(TestCase): }) FULL_REGISTER_WEB_SIGNUP_DATA: Final[bytes] = encode({ 'request_token': f'{REQUEST_TOKEN}', + 'tenant_id': TENANT_ID, 'policy_id': f'{POLICY_ID}', 'account_id': f'{ACCOUNT_ID}', 'custom_properties': CUSTOM_PROPERTIES, @@ -207,7 +212,9 @@ class TestIncogniaAPI(TestCase): 'store_id': f'{STORE_ID}', 'person_id': PERSON_ID, 'debtor_account': BANK_ACCOUNT_INFO, - 'creditor_account': BANK_ACCOUNT_INFO + 'creditor_account': BANK_ACCOUNT_INFO, + 'tenant_id': TENANT_ID, + 'related_web_request_token': RELATED_WEB_REQUEST_TOKEN }) REGISTER_VALID_PAYMENT_DATA_WITH_LOCATION: Final[bytes] = encode({ 'type': 'payment', @@ -245,6 +252,8 @@ class TestIncogniaAPI(TestCase): 'app_version': f'{APP_VERSION}', 'custom_properties': CUSTOM_PROPERTIES, 'person_id': PERSON_ID, + 'tenant_id': TENANT_ID, + 'related_web_request_token': RELATED_WEB_REQUEST_TOKEN }) REGISTER_VALID_WEB_LOGIN_DATA: Final[bytes] = encode({ 'type': 'login', @@ -259,7 +268,8 @@ class TestIncogniaAPI(TestCase): 'external_id': f'{EXTERNAL_ID}', 'policy_id': f'{POLICY_ID}', 'custom_properties': CUSTOM_PROPERTIES, - 'person_id': PERSON_ID + 'person_id': PERSON_ID, + 'tenant_id': TENANT_ID, }) REGISTER_INVALID_LOGIN_DATA: Final[bytes] = encode({ 'type': 'login', @@ -328,6 +338,8 @@ def test_register_new_signup_when_request_token_is_valid_should_return_full_vali device_os=self.DEVICE_OS, app_version=self.APP_VERSION, person_id=self.PERSON_ID, + tenant_id=self.TENANT_ID, + related_web_request_token=self.RELATED_WEB_REQUEST_TOKEN, custom_properties=self.CUSTOM_PROPERTIES) mock_token_manager_get.assert_called() @@ -348,7 +360,8 @@ def test_register_new_web_signup_when_request_token_is_valid_should_return_full_ policy_id=self.POLICY_ID, account_id=self.ACCOUNT_ID, custom_properties=self.CUSTOM_PROPERTIES, - person_id=self.PERSON_ID) + person_id=self.PERSON_ID, + tenant_id=self.TENANT_ID) mock_token_manager_get.assert_called() mock_base_request_post.assert_called_with(Endpoints.SIGNUPS, @@ -529,7 +542,9 @@ def test_register_payment_with_all_fields_should_work( store_id=self.STORE_ID, person_id=self.PERSON_ID, debtor_account=self.BANK_ACCOUNT_INFO, - creditor_account=self.BANK_ACCOUNT_INFO + creditor_account=self.BANK_ACCOUNT_INFO, + tenant_id=self.TENANT_ID, + related_web_request_token=self.RELATED_WEB_REQUEST_TOKEN, ) mock_token_manager_get.assert_called() @@ -681,7 +696,8 @@ def test_register_web_login_when_all_fields_are_valid_should_work( external_id=self.EXTERNAL_ID, policy_id=self.POLICY_ID, custom_properties=self.CUSTOM_PROPERTIES, - person_id=self.PERSON_ID) + person_id=self.PERSON_ID, + tenant_id=self.TENANT_ID,) mock_token_manager_get.assert_called() mock_base_request_post.assert_called_with(Endpoints.TRANSACTIONS, headers=self.AUTH_AND_JSON_CONTENT_HEADERS, @@ -765,15 +781,19 @@ def test_register_login_with_all_fields_should_work( api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET) - request_response = api.register_login(self.REQUEST_TOKEN, - self.ACCOUNT_ID, - location=self.LOCATION, - external_id=self.EXTERNAL_ID, - policy_id=self.POLICY_ID, - device_os=self.DEVICE_OS, - app_version=self.APP_VERSION, - custom_properties=self.CUSTOM_PROPERTIES, - person_id=self.PERSON_ID) + request_response = api.register_login( + self.REQUEST_TOKEN, + self.ACCOUNT_ID, + location=self.LOCATION, + external_id=self.EXTERNAL_ID, + policy_id=self.POLICY_ID, + device_os=self.DEVICE_OS, + app_version=self.APP_VERSION, + custom_properties=self.CUSTOM_PROPERTIES, + person_id=self.PERSON_ID, + tenant_id=self.TENANT_ID, + related_web_request_token=self.RELATED_WEB_REQUEST_TOKEN, + ) mock_token_manager_get.assert_called() mock_base_request_post.assert_called_with(Endpoints.TRANSACTIONS,