Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- Add OMNL/CBK Indonesia submission and audit binder docs, manifests, attestations - Add scripts/omnl transaction-package pipeline, LEI/PvP helpers, jq/lib fixtures - Update entity master data, MASTER_INDEX, TODOS, dbis-rail docs and rulebook - Add proof_package/regulatory skeleton and transaction package zip + snapshot JSON - validate-omnl-rail workflow, forge-verification-proxy tweak, .gitignore hygiene - Bump smom-dbis-138 (cronos verify docs/scripts) and explorer-monorepo (SPA + env report) Made-with: Cursor
68 lines
2.4 KiB
Bash
Executable File
68 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# OMNL Fineract — POST LEI identifier for one client (idempotent).
|
|
# Use when omnl-entity-data-apply.sh has no accountNo match but you know the Fineract client id
|
|
# (see ./scripts/omnl/omnl-list-clients.sh).
|
|
#
|
|
# Usage: ./scripts/omnl/omnl-apply-lei-to-client.sh <clientId> [lei]
|
|
# clientId Fineract client resource id (integer).
|
|
# lei optional; default: entity 1 LEI from OMNL_ENTITY_MASTER_DATA.json
|
|
# Env: DRY_RUN=1 print only.
|
|
# ENTITY_DATA path to master JSON (same default as omnl-entity-data-apply.sh)
|
|
|
|
set -euo pipefail
|
|
REPO_ROOT="${REPO_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
|
|
DRY_RUN="${DRY_RUN:-0}"
|
|
ENTITY_DATA="${ENTITY_DATA:-${REPO_ROOT}/docs/04-configuration/mifos-omnl-central-bank/OMNL_ENTITY_MASTER_DATA.json}"
|
|
|
|
# shellcheck source=lib/omnl-fineract-common.sh
|
|
source "${REPO_ROOT}/scripts/omnl/lib/omnl-fineract-common.sh"
|
|
|
|
CLIENT_ID="${1:-${OMNL_LEI_CLIENT_ID:-}}"
|
|
if [ -z "$CLIENT_ID" ]; then
|
|
echo "Usage: $0 <clientId> [lei]" >&2
|
|
echo "Or set OMNL_LEI_CLIENT_ID and run without args." >&2
|
|
exit 1
|
|
fi
|
|
|
|
LEI="${2:-}"
|
|
if [ -z "$LEI" ]; then
|
|
if [ ! -f "$ENTITY_DATA" ]; then
|
|
echo "Entity data not found: $ENTITY_DATA (pass lei as second arg)" >&2
|
|
exit 1
|
|
fi
|
|
LEI=$(jq -r '.entities[0].lei // empty' "$ENTITY_DATA")
|
|
fi
|
|
if [ -z "$LEI" ] || [ "$LEI" = "null" ]; then
|
|
echo "No LEI in $ENTITY_DATA entities[0].lei; pass lei as second argument." >&2
|
|
exit 1
|
|
fi
|
|
|
|
omnl_fineract_load_env
|
|
omnl_fineract_init_curl || exit 1
|
|
|
|
if [ "$DRY_RUN" = "1" ]; then
|
|
echo "[DRY RUN] Would POST clients/${CLIENT_ID}/identifiers LEI=$LEI (resolve type from template at apply time)" >&2
|
|
exit 0
|
|
fi
|
|
|
|
if omnl_fineract_client_has_document_key "$CLIENT_ID" "$LEI"; then
|
|
echo "Client $CLIENT_ID already has identifier documentKey=$LEI" >&2
|
|
exit 0
|
|
fi
|
|
|
|
lei_type_id=$(omnl_fineract_get_lei_document_type_id "$CLIENT_ID")
|
|
if [ -z "$lei_type_id" ] || [ "$lei_type_id" = "null" ]; then
|
|
echo "No LEI document type for client $CLIENT_ID (check identifiers template / admin codes)." >&2
|
|
exit 1
|
|
fi
|
|
|
|
payload=$(jq -n --arg key "$LEI" --argjson typeId "$lei_type_id" '{ documentKey: $key, documentTypeId: $typeId, description: "LEI", status: "Active" }')
|
|
|
|
res=$(curl "${CURL_OPTS[@]}" -X POST -d "$payload" "${BASE_URL}/clients/${CLIENT_ID}/identifiers" 2>/dev/null) || true
|
|
if echo "$res" | jq -e '.resourceId // .clientId' >/dev/null 2>&1; then
|
|
echo "OK: LEI posted for client $CLIENT_ID" >&2
|
|
exit 0
|
|
fi
|
|
echo "POST failed: $res" >&2
|
|
exit 1
|