diff --git a/.circleci/config.yml b/.circleci/config.yml index a50e2ea..c1c9dbc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - codecov: codecov/codecov@5.0.3 + codecov: codecov/codecov@6.0.0 defaults: &defaults working_directory: ~/project diff --git a/test/unit/testReleasePrep.py b/test/unit/testReleasePrep.py index 6c34932..b563c1c 100644 --- a/test/unit/testReleasePrep.py +++ b/test/unit/testReleasePrep.py @@ -52,6 +52,18 @@ def get(self, endpoint): def post(self, endpoint, body): self.calls.append(("POST", endpoint, body)) + if endpoint == "/v1/verifications/trigger": + return { + "ok": True, + "recipientId": body["recipientId"], + "verifications": [ + { + "type": body["types"][0], + "status": "created", + "verificationId": "IV-123", + } + ], + } if endpoint.startswith("/v1/batches/"): return {"ok": True, "batch": {"id": "B-123", "status": "open"}} if endpoint.startswith("/v1/invoices/payment/create"): @@ -105,15 +117,28 @@ def test_verification_gateway_calls_documented_endpoints(self): expire = gateway.verification.expire({"type": "individual", "verificationIds": ["IV-123"]}) trigger = gateway.verification.trigger("individual", {"recipientIds": ["R-123"]}) watchlist = gateway.verification.trigger_watchlist({"recipientIds": ["R-123"]}) + identity = gateway.verification.trigger_identity_or_business_verification({ + "recipientId": "R-123", + "types": ["individual"], + "retryAllowed": True, + }) self.assertEqual("WV-123", search[0].id) self.assertEqual("WV-123", expire[0].id) self.assertEqual("WV-123", trigger[0].id) self.assertEqual("WV-123", watchlist[0].id) + self.assertTrue(identity.ok) + self.assertEqual("R-123", identity.recipientId) + self.assertEqual("IV-123", identity.verifications[0].verificationId) self.assertEqual(("GET", "/v1/verifications?verificationType=watchlist&page=1&pageSize=10", None), fake_client.calls[0]) self.assertEqual(("PATCH", "/v1/verifications/expire", {"type": "individual", "verificationIds": ["IV-123"]}), fake_client.calls[1]) self.assertEqual(("POST", "/v1/verifications/individual/trigger", {"recipientIds": ["R-123"]}), fake_client.calls[2]) self.assertEqual(("POST", "/v1/verifications/watchlist/trigger", {"recipientIds": ["R-123"]}), fake_client.calls[3]) + self.assertEqual(("POST", "/v1/verifications/trigger", { + "recipientId": "R-123", + "types": ["individual"], + "retryAllowed": True, + }), fake_client.calls[4]) def test_invoice_payment_create_preserves_existing_body_and_adds_batch_id(self): gateway = Gateway(Configuration("public", "private")) diff --git a/trolley/verification_gateway.py b/trolley/verification_gateway.py index 1a05968..a736f7d 100644 --- a/trolley/verification_gateway.py +++ b/trolley/verification_gateway.py @@ -42,6 +42,33 @@ def trigger(self, verification_type, body): response = trolley.configuration.Configuration.client(self.config).post(endpoint, body) return self.__build_verifications_from_response(response, True) + def trigger_identity_or_business_verification(self, body): + if body is None: + raise InvalidFieldException("Body cannot be None.") + endpoint = '/v1/verifications/trigger' + response = trolley.configuration.Configuration.client(self.config).post(endpoint, body) + triggered_verification = namedtuple( + "TriggeredVerification", + ["type", "status", "verificationId", "error"], + ) + verifications = [ + triggered_verification( + verification.get('type'), + verification.get('status'), + verification.get('verificationId'), + verification.get('error'), + ) + for verification in response.get('verifications', []) + ] + return namedtuple( + "IdentityOrBusinessVerificationResult", + ["ok", "recipientId", "verifications"], + )( + response.get('ok'), + response.get('recipientId'), + verifications, + ) + def trigger_watchlist(self, body): if body is None: raise InvalidFieldException("Body cannot be None.")