lib/wolf_core/application/barton/routing.rb
module WolfCore module Barton module Routing include WolfCore::HttpOperations include WolfCore::LambdaFunctionOperations include WolfCore::ExceptionOperations PATH_TO_FUNCTION_NAME_MAPPING = { 'barton/import/jobseeker' => 'BartonImportJobseeker', 'barton/export/jobseeker' => 'BartonExportJobseeker', 'barton/import/order' => 'BartonImportOrder', 'barton/export/order' => 'BartonExportOrder', 'barton/import/order_description' => 'BartonImportOrderDescription', 'barton/import/order_application' => 'BartonImportOrderApplication', 'barton/export/order_application' => 'BartonExportOrderApplication', 'barton/import/contract' => 'BartonImportContract', 'barton/export/contract' => 'BartonExportContract', 'barton/export/jobseeker/file' => 'BartonExportJobseekerFile', 'barton/import/jobseeker/file' => 'BartonImportJobseekerFile', 'barton/export/credential/file' => 'BartonExportCredentialFile', 'barton/import/credential/file' => 'BartonImportCredentialFile', 'barton/manage_assign_package' => 'BartonManageAssignPackage', 'barton/export/credential' => 'BartonExportCredential', 'barton/import/credential' => 'BartonImportCredential', 'barton/export/reference' => 'BartonExportReference', 'barton/import/reference' => 'BartonImportReference', 'barton/export/disclosure' => 'BartonExportDisclosure', 'barton/import/disclosure' => 'BartonImportDisclosure', 'barton/export/jobseeker_order_applications' => 'BartonExportJobseekerOrderApplications', } def route_event_request(path:, body:) environment = ENV['ENVIRONMENT'] deployable_envs = ['production', 'staging'] if deployable_envs.include?(environment) function_name = PATH_TO_FUNCTION_NAME_MAPPING[path] raise_service_error("Function name not found for path: #{path}") if function_name.blank? invoke_lambda( function_name: function_name, payload: body, ) else domain_url = ENV['CURRENT_SAM_URL'] async_http_post(url: "#{domain_url}/#{path}", body: body) end end end end end