# `accessor/digio.py` ## Overview This file handles the integration with Digio APIs, primarily for Video KYC (VKYC) and generic document signing templates. ## Authentication Digio requires Basic Authentication. The username and password (Client ID and Client Secret) are base64 encoded. The credentials used depend on whether the lender is P2P (`P2P_DIGIO_CLIENT_ID`) or CF (`CF_DIGIO_CLIENT_ID`). ## Functions ### `create_template(customer_id, name, crn, lender_id, param, kyc_type)` Creates a request for a Digio template (e.g., for VKYC or standard signing). - **Endpoint**: `POST ` (from config, typically `/client/kyc/v2/request/with_template`). - **Logic**: - If `kyc_type` equals `DIGIO_TWO_WAY_VKYC` (3): Triggers the VKYC workflow using `CF_DIGIO_VKYC_WORKFLOW`. It populates extended details like Father's Name, Loan purpose, Installation address, and EMI amount. - If it is standard KYC, it uses either `CF_DIGIO_WORKFLOW` or `P2P_DIGIO_WORKFLOW` depending on whether the `lender_id` matches `P2P_LENDER_ID`. - **Returns**: A JSON response from Digio containing template initialization details (e.g., access token, entity ID). ### `regenerate_token(id, lender_id)` Regenerates an access token for an existing Digio entity. - **Endpoint**: `POST ` (from config, typically `/user/auth/generate_token`). - **Payload**: `{"entity_id": id}` - **Logic**: Automatically selects the correct Client ID and Secret (CF or P2P) based on the `lender_id`. - **Returns**: A JSON response containing the newly generated token. ## Dependencies - `requests`, `json`, `logging`, `datetime` - `config` - `base64_encode` (from `utils.base64_parsing`)