Module: WolfCore::Barton::Routing

Includes:
HttpOperations, LambdaFunctionOperations
Defined in:
lib/wolf_core/application/barton/routing.rb

Constant Summary collapse

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

Instance Method Summary collapse

Methods included from LambdaFunctionOperations

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

Methods included from ExceptionOperations

#raise_service_error

Methods included from HttpOperations

#async_http_get, #async_http_post, #async_http_put, #http_get, #http_post, #http_put, #parse_http_response, #validate_http_response

Methods included from AsyncUtils

#run_async

Instance Method Details

#import_order_description(order_id:, listing:) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/wolf_core/application/barton/routing.rb', line 28

def import_order_description(order_id:, listing:)
  domain_url = ENV['GENERATE_JOB_DESCRIPTION_URL']
  path = 'barton/import/order_description'
  headers = {
    'Authorization' => ENV['GENERATE_JOB_DESCRIPTION_TOKEN'],
    'tenant' => ENV['GENERATE_JOB_DESCRIPTION_TENANT'],
  }
  body = { order_id: order_id, listing: listing }

  if domain_url.present?
    async_http_post(url: "#{domain_url}/#{path}", headers: headers, body: body)
  else
    function_name = PATH_TO_FUNCTION_NAME_MAPPING[path]
    body['headers'] = headers
    invoke_lambda(
      function_name: function_name,
      payload: body,
    )
  end
end

#route_event_request(path:, body:) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/wolf_core/application/barton/routing.rb', line 15

def route_event_request(path:, body:)
  domain_url = ENV['CURRENT_SAM_URL']
  if domain_url.present?
    async_http_post(url: "#{domain_url}/#{path}", body: body)
  else
    function_name = PATH_TO_FUNCTION_NAME_MAPPING[path]
    invoke_lambda(
      function_name: function_name,
      payload: body,
    )
  end
end