# `accessor/pirimid.py` ## Overview This file contains the `Pirimid` class, which handles interactions with Pirimid APIs for bank statement analysis. ## Class: `Pirimid` ### Initialization (`__init__`) - Configures the endpoint using `PIRIMID_URL` and `PIRIMID_TENANT_ID` (specifically `/fiu/api//bank-statement/process-work-order`). - Sets up headers including `API_KEY` from `config`. ### Methods #### `initiate_bank_statement_analysis(self, data, repository_object)` - Takes in a `data` dictionary (containing the file and metadata) and a `repository_object`. - Constructs the multipart file payload via `get_request_data()`. - Sends a `POST` request to Pirimid with the PDF file. - If successful (Status 200), it passes the response to `save_response()` to store the tracking ID/status in the database using the provided repository object. - **Returns**: The raw text response from the API. #### `get_request_data(data)` (Class Method) - Formats the PDF file into a multipart-encoded format compatible with `requests`. - Attaches the bank statement password if provided. - If `employment_type` exists and is not `SALARIED`, it defaults it to `SELF_EMPLOYED`. - **Returns**: The structured request data dictionary. #### `save_response(response, _repository, application_id, applicant_type)` (Static Method) - Calls `_repository.insert_pirimid_bank_analysis(...)` to persist the analysis tracking details to the database. - **Returns**: The result of the repository insertion query. ## Dependencies - `requests`, `traceback` - `config`