forked from Yara724/api
fix(inquiries): route all tenants through ESG and Fanavaran
This commit is contained in:
+18
-120
@@ -319,81 +319,21 @@ curl -X POST "$FANAVARAN_BIME_URL/car/third-party-car-financial-claims" \
|
||||
--data @fanavaran-claim-submit.json
|
||||
```
|
||||
|
||||
## Tejarat Inquiry Provider
|
||||
|
||||
Default base URL:
|
||||
|
||||
```sh
|
||||
TEJARAT_INQUIRY_BASE_URL="${TEJARAT_INQUIRY_BASE_URL:-http://82.99.202.245:3027}"
|
||||
TEJARAT_INQUIRY_EMAIL='xxx@example.com'
|
||||
TEJARAT_INQUIRY_PASSWORD='123321'
|
||||
```
|
||||
|
||||
Used by `src/sand-hub/sand-hub.service.ts` for third-party plate and car-body plate inquiries when ESG is not selected.
|
||||
|
||||
### Sequence
|
||||
|
||||
1. Login to `/user/login`.
|
||||
2. Use returned `accessToken` as `Authorization: Bearer ...`.
|
||||
3. Call inquiry endpoint.
|
||||
|
||||
### Login
|
||||
|
||||
```sh
|
||||
curl -X POST "$TEJARAT_INQUIRY_BASE_URL/user/login" \
|
||||
-H "Accept: */*" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data '{
|
||||
"email": "'"$TEJARAT_INQUIRY_EMAIL"'",
|
||||
"password": "'"$TEJARAT_INQUIRY_PASSWORD"'"
|
||||
}'
|
||||
```
|
||||
|
||||
```sh
|
||||
TEJARAT_ACCESS_TOKEN="<response accessToken>"
|
||||
```
|
||||
|
||||
### Third-Party Plate / Policy Block Inquiry
|
||||
|
||||
```sh
|
||||
curl -X POST "$TEJARAT_INQUIRY_BASE_URL/block-inquiry-tejarat" \
|
||||
-H "Authorization: Bearer $TEJARAT_ACCESS_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json" \
|
||||
--data '{
|
||||
"leftTwoDigits": "12",
|
||||
"serialLetter": "ب",
|
||||
"threeDigits": "345",
|
||||
"rightTwoDigits": "67",
|
||||
"nationalCode": "0012345678"
|
||||
}'
|
||||
```
|
||||
|
||||
### Car-Body Plate Inquiry
|
||||
|
||||
```sh
|
||||
curl -X POST "$TEJARAT_INQUIRY_BASE_URL/block-inquiry-tejarat/badane" \
|
||||
-H "Authorization: Bearer $TEJARAT_ACCESS_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json" \
|
||||
--data '{
|
||||
"part1": 12,
|
||||
"part2": "ب",
|
||||
"part3": 345,
|
||||
"part4": 67,
|
||||
"nationalCode": "0012345678"
|
||||
}'
|
||||
```
|
||||
|
||||
## ESG Inquiry Provider
|
||||
|
||||
Default/fallback base URL in some call sites:
|
||||
Used by `src/sand-hub/sand-hub.service.ts` for third-party plate/VIN, identity
|
||||
and Sheba inquiries in **every tenant**, including Moalem (`CLIENT_ID=7`).
|
||||
|
||||
```sh
|
||||
ESG_URL="${ESG_URL:-http://192.168.20.22:8085}"
|
||||
ESG_URL="https://<gateway-host>/<optional-prefix>"
|
||||
ESG_USERNAME="<gateway-username>"
|
||||
ESG_PASSWORD="<gateway-password>"
|
||||
```
|
||||
|
||||
Used by `src/sand-hub/sand-hub.service.ts` for selected tenants, for example when `CLIENT_ID=8`.
|
||||
There is no fallback URL or fallback to the deprecated Tejarat provider.
|
||||
Car-body plate and VIN inquiries use the tenant’s Fanavaran profile through
|
||||
`LookupsService.findLastProcessedCarPolicy("car-body", query)`, not ESG.
|
||||
See [inquiry provider routing](inquiry-provider-routing.md) for deployment notes.
|
||||
|
||||
### Sequence
|
||||
|
||||
@@ -417,7 +357,7 @@ curl -X POST "$ESG_URL/auth/login" \
|
||||
ESG_ACCESS_TOKEN="<response accessToken>"
|
||||
```
|
||||
|
||||
### Car By Plate (canonical Parsian third-party plate inquiry)
|
||||
### Car By Plate (third-party inquiry for all tenants)
|
||||
|
||||
```sh
|
||||
curl -X POST "$ESG_URL/inquiry/carByPlate" \
|
||||
@@ -483,15 +423,18 @@ curl -X POST "$ESG_URL/inquiry/sheba" \
|
||||
|
||||
## SandHub Provider
|
||||
|
||||
Used by `src/sand-hub/sand-hub.service.ts` for legacy inquiry flows.
|
||||
Used only for the optional driving-licence and legal vehicle-ownership checks.
|
||||
The current ESG API has no equivalent contract for these checks. Plate/VIN,
|
||||
personal identity and Sheba inquiries do not use this adapter. Configure these
|
||||
settings only when the optional checks are enabled.
|
||||
|
||||
Environment:
|
||||
|
||||
```sh
|
||||
SANHUB_BASE_URL='http://82.99.202.245:3027'
|
||||
SANHUB_URL_LOGIN='http://82.99.202.245:3027/user/login'
|
||||
SANHUB_USERNAME='default@admin.com'
|
||||
SANHUB_PASSWORD='123321'
|
||||
SANHUB_BASE_URL='https://<optional-check-provider>'
|
||||
SANHUB_URL_LOGIN='https://<optional-check-provider>/<login-path>'
|
||||
SANHUB_USERNAME='<optional-check-username>'
|
||||
SANHUB_PASSWORD='<optional-check-password>'
|
||||
```
|
||||
|
||||
### Sequence
|
||||
@@ -515,37 +458,6 @@ curl -X POST "$SANHUB_URL_LOGIN" \
|
||||
SANHUB_ACCESS_TOKEN="<response accessToken>"
|
||||
```
|
||||
|
||||
### Third-Party Plate / Policy Block Inquiry
|
||||
|
||||
```sh
|
||||
curl -X POST "$SANHUB_BASE_URL/block-inquiry-tejarat" \
|
||||
-H "Authorization: Bearer $SANHUB_ACCESS_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json" \
|
||||
--data '{
|
||||
"leftTwoDigits": "12",
|
||||
"serialLetter": "ب",
|
||||
"threeDigits": "345",
|
||||
"rightTwoDigits": "67",
|
||||
"nationalCode": "0012345678"
|
||||
}'
|
||||
```
|
||||
|
||||
### Personal Inquiry
|
||||
|
||||
The app converts Jalali birth dates to Gregorian before sending to SandHub.
|
||||
|
||||
```sh
|
||||
curl -X POST "$SANHUB_BASE_URL/personal-inquiry/tejarat-no" \
|
||||
-H "Authorization: Bearer $SANHUB_ACCESS_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json" \
|
||||
--data '{
|
||||
"nationalCode": "0012345678",
|
||||
"birthdate": "1999-02-13"
|
||||
}'
|
||||
```
|
||||
|
||||
### Driving License Check
|
||||
|
||||
```sh
|
||||
@@ -575,20 +487,6 @@ curl -X POST "$SANHUB_BASE_URL/ownership" \
|
||||
}'
|
||||
```
|
||||
|
||||
### Sheba Validation
|
||||
|
||||
```sh
|
||||
curl -X POST "$SANHUB_BASE_URL/sheba/sheba-tejaratno" \
|
||||
-H "Authorization: Bearer $SANHUB_ACCESS_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json" \
|
||||
--data '{
|
||||
"AccountOwnerType": "1",
|
||||
"NationalId": "0012345678",
|
||||
"ShebaId": "IR000000000000000000000000"
|
||||
}'
|
||||
```
|
||||
|
||||
## Map.ir Reverse Geocoding
|
||||
|
||||
Used by `src/claim-request-management/claim-request-management.service.ts`.
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
# Inquiry provider routing
|
||||
|
||||
The running NestJS API routes inquiries through `src/sand-hub/sand-hub.service.ts`.
|
||||
The class name remains for existing dependency injection; it does not select the
|
||||
provider by tenant anymore.
|
||||
|
||||
| Inquiry | Provider | Entry point |
|
||||
| --- | --- | --- |
|
||||
| Third-party policy by plate | ESG `/inquiry/carByPlate` | `getCarByPlateInquiry` |
|
||||
| Third-party policy by national code + VIN | ESG `/inquiry/carByChassis` | `getCarByChassisInquiry` |
|
||||
| Person identity | ESG `/inquiry/person` | `getPersonalInquiry` |
|
||||
| Sheba ownership | ESG `/inquiry/sheba` | `getShebaValidation` |
|
||||
| Car-body policy by plate or VIN | Tenant-specific Fanavaran processed policy lookup | `getCarBodyInquiry` |
|
||||
| Optional driving-licence / legal vehicle ownership | Existing configured `SANHUB_*` adapter | `getDrivingLicenseInfo` / `getCarOwnershipInfo` |
|
||||
|
||||
The ESG endpoints above apply to every tenant. Existing per-client live/mock
|
||||
settings still apply. Disabled inquiries retain their mock behavior; offline
|
||||
third-party plate records are consulted only in disabled mode. No mock or
|
||||
deprecated provider is used as a fallback when a live ESG inquiry fails.
|
||||
|
||||
## Why Moalem reached the retired login
|
||||
|
||||
Previously only `CLIENT_ID=8` selected ESG. `CLIENT_ID=7` therefore selected the
|
||||
old Tejarat transport for third-party plate inquiries, and the old configurable
|
||||
hub for identity and Sheba. Car-body plate inquiries also used the Tejarat
|
||||
transport unless the Fanavaran profile was Parsian. Car-body VIN inquiries
|
||||
already used Fanavaran.
|
||||
|
||||
The retired `getTejaratAccessToken`, `/user/login` transport and
|
||||
`TEJARAT_INQUIRY_*` configuration have been removed from the running API.
|
||||
Both car-body input formats now use the existing Fanavaran lookup. The mapper
|
||||
uses the selected source insurer rather than assuming every car-body result
|
||||
belongs to Parsian. Explicit conflicting insurer codes are rejected.
|
||||
|
||||
## Deployment settings
|
||||
|
||||
Supply these through the API environment, then restart the API:
|
||||
|
||||
```dotenv
|
||||
CLIENT_ID=7
|
||||
FANAVARAN_CLIENT=moallem
|
||||
ESG_URL=https://<gateway-host>/<optional-prefix>
|
||||
ESG_USERNAME=<gateway-username>
|
||||
ESG_PASSWORD=<gateway-password>
|
||||
```
|
||||
|
||||
`moallem` is the existing Fanavaran profile spelling. The explicit
|
||||
`FANAVARAN_CLIENT` setting takes precedence; when absent, `CLIENT_ID=7` now
|
||||
resolves to `moallem`, and `CLIENT_ID=8` still resolves to `parsian`. Other
|
||||
deployments must select their own Fanavaran profile as before. The selected
|
||||
profile must have its existing Fanavaran credentials/contracts configured.
|
||||
|
||||
`ESG_URL` is the base **before** `/auth/login` and `/inquiry/...`; include any
|
||||
gateway prefix in that value. Trailing slashes are normalized. No internal-IP
|
||||
default is used. The ESG user needs access to all four inquiry types. Birth
|
||||
dates are sent in Jalali `YYYY-MM-DD`, with `dateHasPostfix: 0`. The cached ESG
|
||||
token is reused, and an inquiry HTTP 401 clears it before the existing retry.
|
||||
|
||||
`TEJARAT_INQUIRY_BASE_URL`, `TEJARAT_INQUIRY_EMAIL` and
|
||||
`TEJARAT_INQUIRY_PASSWORD` are no longer read by the running API and can be
|
||||
removed from deployment configuration. Do not repoint `SANHUB_*` to ESG: their
|
||||
optional licence/ownership payloads differ, and the ESG repository currently
|
||||
has no matching endpoints. Those two checks keep their existing settings
|
||||
until an explicit replacement contract is provided.
|
||||
|
||||
## Compatibility and verification
|
||||
|
||||
The mapped inquiry fields consumed by the UI remain unchanged. The old
|
||||
`getSandHubResponse` entry point delegates to ESG and returns the mapped result.
|
||||
New car-body audit records identify their source as
|
||||
`FANAVARAN_CAR_BODY_INQUIRY` or `FANAVARAN_CAR_BODY_VIN_INQUIRY`. Historical raw
|
||||
inquiries, audit records and database documents are not rewritten.
|
||||
|
||||
`scripts/refresh-blame-inquiries.js` and `scripts/fanavaran-flow-ui-server.js`
|
||||
are separate manually run diagnostic tools with their own legacy provider
|
||||
settings. They are not invoked by the running application and have not been
|
||||
migrated by this change; do not use their inquiry shortcuts as evidence of the
|
||||
application's current routing.
|
||||
|
||||
Regression tests in `sand-hub.esg-routing.spec.ts` cover tenant IDs 7, 8 and 15,
|
||||
ESG token reuse/401 refresh, missing configuration, disabled inquiries,
|
||||
Fanavaran plate/VIN routing, source-company checks and optional-check
|
||||
compatibility. Provider HTTP calls in these tests are mocked; deployment still
|
||||
requires valid gateway credentials and connectivity.
|
||||
Reference in New Issue
Block a user