Api reference
components.id_verification.public.business_logic ¶
actions ¶
id_verification ¶
cancel_and_recreate_id_verification ¶
To be used from Marmot. Most expected use case: initial ID check was failed (likely abandoned).
:raises ValueError: if current status is not failed It is likely safe to cancel and restart other checks as well, but there are no meaningful cases for that so far.
Source code in components/id_verification/public/business_logic/actions/id_verification.py
cancel_id_verification_request_by_workflow_run ¶
Cancels an ID verification request by its workflow run ID. A reason must be passed to explain the cancellation.
Note: This function does not commit directly, it's left up to the calling code to do it, or not.
Source code in components/id_verification/public/business_logic/actions/id_verification.py
create_id_verification_request ¶
Creates an ID verification request for a user or a company.
Source code in components/id_verification/public/business_logic/actions/id_verification.py
update_id_verification_request ¶
Updates an existing ID verification request. This function is a placeholder for future updates.
Source code in components/id_verification/public/business_logic/actions/id_verification.py
notifications ¶
send_id_verification_reminder_for_request ¶
Sends an ID verification reminder email for the given request.
Source code in components/id_verification/public/business_logic/actions/notifications.py
queries ¶
id_verification ¶
find_uncompleted_id_verification_requests ¶
Returns a list of uncompleted ID verification requests that are older than the given age.
Source code in components/id_verification/public/business_logic/queries/id_verification.py
get_id_verification_request ¶
Returns the ID verification request with the given ID.
Source code in components/id_verification/public/business_logic/queries/id_verification.py
get_last_active_id_verification_request_for_company ¶
Returns the last active ID verification request that affects the given company. The company can have multiple associated requests (e.g. different users started onboarding), the requests' priority for us is: 1. passed (whenever it happened, for now let's be permissive) 2. most recent otherwise (created, started or failed, it doesn't matter)
Source code in components/id_verification/public/business_logic/queries/id_verification.py
get_last_active_id_verification_request_for_user ¶
Returns the last active ID verification request for the given user.
Source code in components/id_verification/public/business_logic/queries/id_verification.py
get_or_request_id_verification ¶
This method is an entry point into the ID verification flow. If there is a pending ID verification request for the user it will be returned, otherwise a new one will be created. We want to maintain an invariant - no more than one active ID verification request per user. For that reason, we lock the user for ID verification before creating a new request.
we create ID checks for users, not companies.
Company ID provides helpful contextual information, but we don't rely on it much
inside this module.
It makes sense if you remember that the primary use case is onboarding.
However, the state of ID check might impact that of the company(-ies).
Imagine the following events:
- user_1 signs up onboarding company_1 - Request_1 is created for the ID check
new employee policies are blocked
- user_1 signs up onboarding company_2 - user is still prompted to complete Request_1
new employee policies should be blocked, but we need to be able to map
company_2 to Request_1
- Request_1 is passed:
Policies of employees of both company_1 and company_2 should be unblocked.
We need to map Request_1 to [company_1, company_2]
In all these cases, we shouldn't rely on knowing that user_1 started the required check.
Let's store the relevant mapping between ID checks and companies in the DB.
For that purpose, we use IDVerificationRequestAffectsCompany.
:param user_id: user_id corresponds to who we're asking to pass the ID verification
Can be admin of the newly created company or newly signed TNS
:param company_id: company_id corresponds to the company during creating which the user (admin)
is asked to pass the ID verification
:param reason: IDVerificationReason.onboarding_tns or IDVerificationReason.onboarding_company
:param user_info: information necessary to perform the ID check
:param commit: whether to commit the session after creating the request
Source code in components/id_verification/public/business_logic/queries/id_verification.py
components.id_verification.public.entities ¶
id_verification_request ¶
IDVerificationCancellationContext
dataclass
¶
IDVerificationDocumentType ¶
Bases: AlanBaseEnum
Type of document used for ID verification.
national_identity_card
class-attribute
instance-attribute
¶
IDVerificationReason ¶
Bases: AlanBaseEnum
Reason for the ID verification request.
IDVerificationRequest
dataclass
¶
IDVerificationRequest(
id,
created_at,
user_id,
company_id,
reason,
status,
bypassed_by_user_id,
bypassed_with_comment,
params,
onfido_workflow_run,
affected_company_ids,
attempt_context,
document_type=None,
)
IDVerificationRequestAttemptContext
dataclass
¶
Bases: DataClassJsonMixin
Context for an attempt of an ID verification request.
first_attempt
classmethod
¶
Creates the first attempt context for an ID verification request.
Source code in components/id_verification/public/entities/id_verification_request.py
IDVerificationRequestStatus ¶
Bases: AlanBaseEnum
Status of an ID verification request.
is_final ¶
Check if the ID verification request status is final. A final status is one that indicates the request has been completed or terminated, such as passed, failed, or cancelled.
Source code in components/id_verification/public/entities/id_verification_request.py
IDVerificationRequestUserInfo
dataclass
¶
IDVerificationRequestUserInfoAdditionalProperties
dataclass
¶
IDVerificationRequestUserInfoAdditionalProperties(
birth_last_name,
gender,
date_of_birth,
place_of_birth,
session_id,
)
Bases: DataClassJsonMixin
Additional properties for user information in ID verification request. It is used for the clinic id verification flow.
IDVerificationRestartContext
dataclass
¶
IDVerificationRestartContext(
previous_request_id,
trigger,
comment,
previous_attempt_was_abandoned=False,
)
Bases: DataClassJsonMixin
Context for restarting an ID verification request.
IDVerificationRestartTrigger ¶
Bases: AlanBaseEnum
Trigger for restarting an ID verification request.