# Pirimid Integration ## Purpose The service integrates with Pirimid for bank document upload and tracking. Implementation: ```text StaticFunctions.uploadPirimidDocument() ``` File: ```text static_functions.py ``` ## Flow 1. Validate that `docFormat` is `pdf`. 2. Base64-decode `docContent`. 3. Build a multipart file upload. 4. Add application and applicant metadata. 5. Add PDF password if provided. 6. Send request to Pirimid. 7. Read `trackingId` from the response. 8. Insert request/response details into `pirimid_bank_analysis`. 9. Return Pirimid response JSON. ## Request To Pirimid URL: ```text Pirimid_Api ``` Headers: ```json { "Accept": "*/*", "API_KEY": "PIRIMID_API_KEY" } ``` Multipart file: ```text document_{application_id}.pdf ``` Payload: | Field | Purpose | | --- | --- | | `id` | Application ID | | `applicant_type` | Applicant type | | `pdfPasswords` | Optional customer document password | Timeout: ```text 100 seconds ``` ## Database Write Table: ```text pirimid_bank_analysis ``` Inserted fields: - `tracking_id` - `application_id` - `request` - `response` - `user_id` - `applicant_type` - `created_at` - `updated_at` `user_id` is currently hardcoded to `107`. ## Configuration | Variable | Purpose | | --- | --- | | `Pirimid_Api` | Pirimid upload URL | | `PIRIMID_API_KEY` | Pirimid API key | ## Failure Behavior On exception, the function logs the error and returns: ```json { "error": "Pirimid upload failed", "message": "..." } ``` ## Documentation Requirement Any endpoint using Pirimid should document: - which applicant type is passed - whether password is optional or required - where the original file came from - expected Pirimid response fields - how `tracking_id` is used downstream - failure response behavior