feat(MED-85): run sending fake medipost results in dev from Medusa BO

This commit is contained in:
2025-08-28 10:24:13 +03:00
parent d760f86632
commit 47ab39172e
7 changed files with 89 additions and 2 deletions

View File

@@ -0,0 +1,42 @@
create extension if not exists pg_net;
create or replace function medreport.medipost_retry_dispatch(
order_id text
)
returns jsonb
language plpgsql
as $function$
declare
response_result record;
begin
select into response_result
net.http_post(
url := 'https://test.medreport.ee/api/job/medipost-retry-dispatch',
headers := jsonb_build_object(
'Content-Type', 'application/json',
'x-jobs-api-key', 'fd26ec26-70ed-11f0-9e95-431ac3b15a84'
),
body := jsonb_build_object(
'medusaOrderId', order_id
)::text
) as request_id;
return jsonb_build_object(
'success', true
);
exception
when others then
return jsonb_build_object(
'success', false
);
end;
$function$;
grant execute on function medreport.medipost_retry_dispatch(text) to service_role;
comment on function medreport.medipost_retry_dispatch(text) is
'Manually trigger a medipost retry dispatch for a specific order ID.
Parameters:
- order_id: The medusa order ID to retry dispatch for
Returns: JSONB with success status and request details';

View File

@@ -0,0 +1,16 @@
CREATE OR REPLACE FUNCTION medreport.sync_analysis_results()
RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
select net.http_post(
url := 'https://test.medreport.ee/api/job/sync-analysis-results',
headers := jsonb_build_object(
'Content-Type', 'application/json',
'x-jobs-api-key', 'fd26ec26-70ed-11f0-9e95-431ac3b15a84'
)
) as request_id;
END;
$$;
grant execute on function medreport.sync_analysis_results() to service_role;

View File

@@ -0,0 +1,20 @@
-- Parameters order_id
CREATE OR REPLACE FUNCTION medreport.send_medipost_test_response_for_order(order_id text)
RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
select net.http_post(
url := 'https://test.medreport.ee/api/job/send-medipost-test-response-for-order',
headers := jsonb_build_object(
'Content-Type', 'application/json',
'x-jobs-api-key', 'fd26ec26-70ed-11f0-9e95-431ac3b15a84'
),
body := jsonb_build_object(
'order_id', order_id
)
) as request_id;
END;
$$;
grant execute on function medreport.send_medipost_test_response_for_order(text) to service_role;