lib/wolf_core/application/integrations/jobseeker_api_operations.rb
module WolfCore
module Integrations
module JobseekerApiOperations
include WolfCore::HttpOperations
def fetch_jobseeker!(wolf_token:, jobseeker_id:, tenant:, wolf_platform_url:, error_message:)
response = safe_http_get(
headers: { 'Authorization' => "Bearer #{wolf_token}" },
url: "#{wolf_platform_url}/api/v2/jobseekers/#{jobseeker_id}",
query: { tenant: tenant },
error_message: error_message,
)
response_body = response.body
response_body.dig('data', 'table', 'jobseeker')
end
def fetch_jobseeker(wolf_token:, jobseeker_id:, tenant:, wolf_platform_url:)
response = http_get(
headers: { 'Authorization' => "Bearer #{wolf_token}" },
url: "#{wolf_platform_url}/api/v2/jobseekers/#{jobseeker_id}",
query: { tenant: tenant },
)
response_body = response.body
return unless response_body.instance_of?(Hash)
response_body.dig('data', 'table', 'jobseeker')
end
def create_jobseeker!(wolf_token:, jobseeker:, tenant:, wolf_platform_url:, error_message:)
safe_http_post(
headers: { 'Authorization' => "Bearer #{wolf_token}" },
query: { tenant: tenant },
url: "#{wolf_platform_url}/api/v2/jobseekers",
body: jobseeker,
error_message: error_message,
)
end
def create_jobseeker(wolf_token:, jobseeker:, tenant:, wolf_platform_url:)
http_post(
headers: { 'Authorization' => "Bearer #{wolf_token}" },
query: { tenant: tenant },
url: "#{wolf_platform_url}/api/v2/jobseekers",
body: jobseeker
)
end
def update_jobseeker!(wolf_token:, jobseeker:, tenant:, wolf_platform_url:, error_message:, jobseeker_id:)
safe_http_put(
headers: { 'Authorization' => "Bearer #{wolf_token}" },
query: { tenant: tenant },
url: "#{wolf_platform_url}/api/v2/jobseekers/#{jobseeker_id}",
body: jobseeker,
error_message: error_message,
)
end
def update_jobseeker(wolf_token:, jobseeker:, tenant:, wolf_platform_url:, jobseeker_id:)
http_put(
headers: { 'Authorization' => "Bearer #{wolf_token}" },
query: { tenant: tenant },
url: "#{wolf_platform_url}/api/v2/jobseekers/#{jobseeker_id}",
body: jobseeker
)
end
end
end
end