aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_call_accsys_api
Parameters
Name
Type
Mode
endpoint
text
IN
params
jsonb
IN
Definition
declare v_state TEXT; v_message TEXT; v_detail TEXT; v_hint TEXT; v_context TEXT; v_service_url text = fn_prop_config('ACCSYS_SERVICE_URL', ''); v_service_token text = fn_prop_config('ACCSYS_SERVICE_TOKEN', ''); BEGIN PERFORM sp_raise_error_if(v_service_token = '', 'Service token does not configured'); v_service_url := trim(trailing '/' from v_service_url); endpoint := trim(leading '/' from endpoint); params := coalesce(params, '{}'::jsonb); raise notice E'API Endpoint: %\nAPI Params: %', endpoint, params; raise notice 'Token: %', v_service_token; RETURN sp_call_rpc(v_service_url||'/'||endpoint, v_service_token, params, 'AccSys'); EXCEPTION WHEN OTHERS THEN GET STACKED DIAGNOSTICS v_state = RETURNED_SQLSTATE, v_message = MESSAGE_TEXT, v_detail = PG_EXCEPTION_DETAIL, v_hint = PG_EXCEPTION_HINT, v_context = PG_EXCEPTION_CONTEXT; RETURN fn_handle_error(v_state, v_message, v_detail, v_hint, v_context, endpoint, jsonb_build_object('endpoint', endpoint, 'params', params) ); END