diff --git a/README.md b/README.md index 7729855..5674c20 100644 --- a/README.md +++ b/README.md @@ -175,12 +175,15 @@ payment_methods: List[PaymentMethod] = [ } ] +policy_id: str = 'policy-id' + assessment: dict = api.register_payment('installation-id', 'account-id', 'external-id', addresses=addresses, payment_value=payment_value, - payment_methods=payment_methods) + payment_methods=payment_methods, + policy_id=policy_id) ``` #### Registering Login @@ -193,7 +196,12 @@ from incognia.api import IncogniaAPI api = IncogniaAPI('client-id', 'client-secret') -assessment: dict = api.register_login('installation-id', 'account-id', 'external-id') +policy_id: str = 'policy-id' + +assessment: dict = api.register_login('installation-id', + 'account-id', + 'external-id', + policy_id='policy_id') ``` ## Evidences diff --git a/incognia/api.py b/incognia/api.py index b508f35..79a4f4d 100644 --- a/incognia/api.py +++ b/incognia/api.py @@ -101,7 +101,8 @@ def register_payment(self, addresses: Optional[List[TransactionAddress]] = None, payment_value: Optional[PaymentValue] = None, payment_methods: Optional[List[PaymentMethod]] = None, - evaluate: Optional[bool] = None) -> dict: + evaluate: Optional[bool] = None, + policy_id: Optional[str] = None) -> dict: if not installation_id: raise IncogniaError('installation_id is required.') if not account_id: @@ -118,7 +119,8 @@ def register_payment(self, 'external_id': external_id, 'addresses': addresses, 'payment_value': payment_value, - 'payment_methods': payment_methods + 'payment_methods': payment_methods, + 'policy_id': policy_id } data = encode(body) return self.__request.post(Endpoints.TRANSACTIONS, headers=headers, params=params, @@ -131,7 +133,8 @@ def register_login(self, installation_id: str, account_id: str, external_id: Optional[str] = None, - evaluate: Optional[bool] = None) -> dict: + evaluate: Optional[bool] = None, + policy_id: Optional[str] = None) -> dict: if not installation_id: raise IncogniaError('installation_id is required.') if not account_id: @@ -145,7 +148,8 @@ def register_login(self, 'type': 'login', 'installation_id': installation_id, 'account_id': account_id, - 'external_id': external_id + 'external_id': external_id, + 'policy_id': policy_id } data = encode(body) return self.__request.post(Endpoints.TRANSACTIONS, headers=headers, params=params, @@ -158,7 +162,8 @@ def register_web_login(self, session_token: str, account_id: str, external_id: Optional[str] = None, - evaluate: Optional[bool] = None) -> dict: + evaluate: Optional[bool] = None, + policy_id: Optional[str] = None) -> dict: if not session_token: raise IncogniaError('session_token is required.') if not account_id: @@ -172,7 +177,8 @@ def register_web_login(self, 'type': 'login', 'session_token': session_token, 'account_id': account_id, - 'external_id': external_id + 'external_id': external_id, + 'policy_id': policy_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 d9c5a37..fc92957 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -83,7 +83,8 @@ class TestIncogniaAPI(TestCase): REGISTER_VALID_PAYMENT_DATA: Final[bytes] = encode({ 'type': 'payment', 'installation_id': f'{INSTALLATION_ID}', - 'account_id': f'{ACCOUNT_ID}' + 'account_id': f'{ACCOUNT_ID}', + 'policy_id': f'{POLICY_ID}' }) REGISTER_INVALID_PAYMENT_DATA: Final[bytes] = encode({ 'type': 'payment', @@ -93,12 +94,14 @@ class TestIncogniaAPI(TestCase): REGISTER_VALID_LOGIN_DATA: Final[bytes] = encode({ 'type': 'login', 'installation_id': f'{INSTALLATION_ID}', - 'account_id': f'{ACCOUNT_ID}' + 'account_id': f'{ACCOUNT_ID}', + 'policy_id': f'{POLICY_ID}' }) REGISTER_VALID_WEB_LOGIN_DATA: Final[bytes] = encode({ 'type': 'login', 'session_token': f'{SESSION_TOKEN}', - 'account_id': f'{ACCOUNT_ID}' + 'account_id': f'{ACCOUNT_ID}', + 'policy_id': f'{POLICY_ID}' }) REGISTER_INVALID_LOGIN_DATA: Final[bytes] = encode({ 'type': 'login', @@ -277,7 +280,9 @@ def test_register_payment_when_required_fields_are_valid_should_work( api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET) - request_response = api.register_payment(self.INSTALLATION_ID, self.ACCOUNT_ID) + request_response = api.register_payment(self.INSTALLATION_ID, + self.ACCOUNT_ID, + policy_id=self.POLICY_ID) mock_token_manager_get.assert_called() mock_base_request_post.assert_called_with(Endpoints.TRANSACTIONS, @@ -337,7 +342,9 @@ def test_register_login_when_required_fields_are_valid_should_work( api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET) - request_response = api.register_login(self.INSTALLATION_ID, self.ACCOUNT_ID) + request_response = api.register_login(self.INSTALLATION_ID, + self.ACCOUNT_ID, + policy_id=self.POLICY_ID) mock_token_manager_get.assert_called() mock_base_request_post.assert_called_with(Endpoints.TRANSACTIONS, @@ -397,7 +404,9 @@ def test_register_web_login_when_required_fields_are_valid_should_work( api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET) - request_response = api.register_web_login(self.SESSION_TOKEN, self.ACCOUNT_ID) + request_response = api.register_web_login(self.SESSION_TOKEN, + self.ACCOUNT_ID, + policy_id=self.POLICY_ID) mock_token_manager_get.assert_called() mock_base_request_post.assert_called_with(Endpoints.TRANSACTIONS,