Module: WolfCore::Integrations::JobseekerApiOperations

Includes:
HttpOperations
Defined in:
lib/wolf_core/application/integrations/jobseeker_api_operations.rb

Instance Method Summary collapse

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, #response_success?, #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

Methods included from ExceptionOperations

#raise_service_error

Instance Method Details

#create_jobseeker(wolf_token:, jobseeker:, tenant:, wolf_platform_url:) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/wolf_core/application/integrations/jobseeker_api_operations.rb', line 71

def create_jobseeker(wolf_token:, jobseeker:, tenant:, wolf_platform_url:)
  parsed_http_post(
    headers: { "Authorization" => "Bearer #{wolf_token}" },
    query: { tenant: tenant },
    url: "#{wolf_platform_url}/api/v2/jobseekers",
    body: jobseeker
  )
end

#create_jobseeker!(wolf_token:, jobseeker:, tenant:, wolf_platform_url:, error_message:, error_data: nil) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/wolf_core/application/integrations/jobseeker_api_operations.rb', line 59

def create_jobseeker!(wolf_token:, jobseeker:, tenant:, wolf_platform_url:, error_message:, error_data: nil)
  response = create_jobseeker(
    wolf_token: wolf_token,
    jobseeker: jobseeker,
    tenant: tenant,
    wolf_platform_url: wolf_platform_url
  )
  error_data ||= {}
  validate_http_response(response: response, message: error_message, error_data: error_data.merge(jobseeker: jobseeker))
  response
end

#fetch_jobseeker(wolf_token:, jobseeker_id:, tenant:, wolf_platform_url:, query: nil) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/wolf_core/application/integrations/jobseeker_api_operations.rb', line 50

def fetch_jobseeker(wolf_token:, jobseeker_id:, tenant:, wolf_platform_url:, query: nil)
  query ||= {}
  parsed_http_get(
    headers: { "Authorization" => "Bearer #{wolf_token}" },
    url: "#{wolf_platform_url}/api/v2/jobseekers/#{jobseeker_id}",
    query: query.merge(tenant: tenant)
  )
end

#fetch_jobseeker!(wolf_token:, jobseeker_id:, tenant:, wolf_platform_url:, error_message:, query: nil, error_data: nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/wolf_core/application/integrations/jobseeker_api_operations.rb', line 37

def fetch_jobseeker!(wolf_token:, jobseeker_id:, tenant:, wolf_platform_url:, error_message:, query: nil, error_data: nil)
  response = fetch_jobseeker(
    wolf_token: wolf_token,
    jobseeker_id: jobseeker_id,
    tenant: tenant,
    wolf_platform_url: wolf_platform_url,
    query: query
  )
  error_data ||= {}
  validate_http_response(response: response, message: error_message, error_data: error_data.merge(jobseeker_id: jobseeker_id, query: query))
  response.body.dig("data", "table", "jobseeker")
end

#fetch_jobseeker_by_user_id!(wolf_token:, tenant:, wolf_platform_url:, user_id:) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/wolf_core/application/integrations/jobseeker_api_operations.rb', line 6

def fetch_jobseeker_by_user_id!(wolf_token:, tenant:, wolf_platform_url:, user_id:)
  jobseekers = fetch_jobseekers!(
    wolf_token: wolf_token,
    tenant: tenant,
    wolf_platform_url: wolf_platform_url,
    query: { user_id: user_id }
  )
  jobseekers.first
end

#fetch_jobseekers(wolf_token:, tenant:, wolf_platform_url:, query: nil) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/wolf_core/application/integrations/jobseeker_api_operations.rb', line 28

def fetch_jobseekers(wolf_token:, tenant:, wolf_platform_url:, query: nil)
  query ||= {}
  parsed_http_get(
    headers: { "Authorization" => "Bearer #{wolf_token}" },
    url: "#{wolf_platform_url}/api/v2/jobseekers",
    query: query.merge(tenant: tenant)
  )
end

#fetch_jobseekers!(wolf_token:, tenant:, wolf_platform_url:, error_message:, query: nil, error_data: nil) ⇒ Object



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

def fetch_jobseekers!(wolf_token:, tenant:, wolf_platform_url:, error_message:, query: nil, error_data: nil)
  response = fetch_jobseekers(
    wolf_token: wolf_token,
    tenant: tenant,
    wolf_platform_url: wolf_platform_url,
    query: query
  )
  error_data ||= {}
  validate_http_response(response: response, message: error_message, error_data: error_data.merge(query: query))
  response.body.dig("data", "table", "jobseeker")
end

#update_jobseeker(wolf_token:, jobseeker:, tenant:, wolf_platform_url:, jobseeker_id:) ⇒ Object



93
94
95
96
97
98
99
100
# File 'lib/wolf_core/application/integrations/jobseeker_api_operations.rb', line 93

def update_jobseeker(wolf_token:, jobseeker:, tenant:, wolf_platform_url:, jobseeker_id:)
  parsed_http_put(
    headers: { "Authorization" => "Bearer #{wolf_token}" },
    query: { tenant: tenant },
    url: "#{wolf_platform_url}/api/v2/jobseekers/#{jobseeker_id}",
    body: jobseeker
  )
end

#update_jobseeker!(wolf_token:, jobseeker:, tenant:, wolf_platform_url:, error_message:, jobseeker_id:, error_data: nil) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/wolf_core/application/integrations/jobseeker_api_operations.rb', line 80

def update_jobseeker!(wolf_token:, jobseeker:, tenant:, wolf_platform_url:, error_message:, jobseeker_id:, error_data: nil)
  response = update_jobseeker(
    wolf_token: wolf_token,
    jobseeker: jobseeker,
    tenant: tenant,
    wolf_platform_url: wolf_platform_url,
    jobseeker_id: jobseeker_id
  )
  error_data ||= {}
  validate_http_response(response: response, message: error_message, error_data: error_data.merge(jobseeker_id: jobseeker_id, jobseeker: jobseeker))
  response
end