CREATE OR REPLACE FUNCTION medreport.send_medipost_test_response_for_order(medusa_order_id text)
RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
  select net.http_post(
    url := 'https://test.medreport.ee/api/order/medipost-test-response',
    headers := jsonb_build_object(
      'Content-Type', 'application/json',
      'x-jobs-api-key', 'fd26ec26-70ed-11f0-9e95-431ac3b15a84'
    ),
    body := jsonb_build_object(
      'medusaOrderId', medusa_order_id
    )
  ) as request_id;
END;
$$;

grant execute on function medreport.send_medipost_test_response_for_order(text) to service_role;
