Module: WolfCore::Integrations::RoutingOperations

Includes:
ExceptionOperations, HttpOperations, LambdaFunctionOperations
Defined in:
lib/wolf_core/application/integrations/routing_operations.rb

Constant Summary collapse

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',
}

Instance Method Summary collapse

Methods included from ExceptionOperations

#raise_service_error

Methods included from LambdaFunctionOperations

#get_event_params, #invoke_lambda, #parse_lambda_response, #result_to_response, #validate_lambda_response

Methods included from StringUtils

#camelcase_to_spaces, #clean_phone_number, #deep_parse_json, #hash_str_to_json, #remove_blank_spaces

Methods included from HttpOperations

#async_http_get, #async_http_patch, #async_http_post, #async_http_put, #http_get, #http_patch, #http_post, #http_put, #parse_http_response, #parsed_http_get, #parsed_http_patch, #parsed_http_post, #parsed_http_put, #safe_http_get, #safe_http_patch, #safe_http_post, #safe_http_put, #validate_http_response

Methods included from LoggingUtils

#log_object

Methods included from AsyncUtils

#run_async

Instance Method Details

#route_event_request(path:, body:) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/wolf_core/application/integrations/routing_operations.rb', line 18

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