lib/wolf_core/application/integrations/routing_operations.rb
module WolfCore module Integrations module RoutingOperations include WolfCore::HttpOperations include WolfCore::LambdaFunctionOperations include WolfCore::ExceptionOperations PATH_TO_FUNCTION_NAME_MAPPING = { 'burnett/jobseekers/export' => 'BurnettExportJobseeker', 'burnett/jobseekers/import' => 'BurnettImportJobseeker', 'burnett/orders/export' => 'BurnettExportOrder', 'burnett/order_applications/export' => 'BurnettExportOrderApplication', 'burnett/clients/import' => 'BurnettImportClient', 'burnett/clients/bulk_import' => 'BurnettBulkImportClients', 'burnett/clients/export' => 'BurnettExportClient', } def route_event_request(path:, body:) environment = ENV['ENVIRONMENT'] || 'development' deployable_envs = ['production', 'staging', 'testing'] if deployable_envs.include?(environment.downcase) function_name = "#{PATH_TO_FUNCTION_NAME_MAPPING[path]}#{environment.titleize}" 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