# `emi_service.py` ## Overview This file houses the `EMIService` class and acts as the brain of the EMI Checkout system. It orchestrates the flow of data between the API controllers (from `applications/`), the database layer (`EMIRepository`), and third-party integrations (`accessors/`). ## Key Utilities & Validations Outside the class, the file contains several standalone validation helpers: - `validate_age(dob)`, `validate_ckyc(...)`, `validate_create_loan_request(...)`, `validate_electricity_bill_request(...)` - `create_application_link(app_id)`: Generates tracking/resume links for partial applications. ## Class: `EMIService` ### Initialization - Takes an instance of `EMIRepository` and `Utilities` as injected dependencies via the constructor. ### Core Workflows (Standard EMI) - **Application Management**: `add_application`, `update_customer_details`, `get_application_status`, `application_cancellation_request`, `create_loan`. - **Authentication/OTP**: `initiate_otp`, `send_otp`, `confirm_otp`, `cooldown_check`. - **KYC & Bureau Integration**: - `ckyc`: Orchestrates CKYC checks using PAN/DOB. - `digio_vkyc_method` & `digio_generate_token`: Hooks into the Digio accessor to start VKYC sessions. - `get_bureau`: Orchestrates fetching credit reports. - **Documents & Offers**: `upload_document`, `process_product_details`, `save_offer`. ### No Touch / Solar Workflows The class contains specialized `no_touch_*` variants of core methods for fast-tracked or specialized products: - `no_touch_ckyc`, `no_touch_get_bureau`, `no_touch_confirm_otp`, `no_touch_process_product_details`. - Specialized endpoints for tracking user progress: `get_user_journey_details` and `get_no_touch_user_journey_details`. ### Helper Methods - `get_schema_file` / `get_no_touch_config`: Returns JSON structures that dictate UI rendering paths based on configurations. - `display_merchants`, `display_merchant_name`: Interfaces with the repository to translate slugs/IDs to displayable text. - `send_create_application_communication`: Triggers welcome or OTP communications utilizing external APIs (like Exotel via the `utils`). ## Dependencies - `EMIRepository` - External Accessors (`bureau_service`, `digio`, `creditfair`, `pirimid`) - `utils` (Validation, formatting, S3 uploading) - `bugsnag`, `logging`