module WolfCore::Burnett::Onboarding::CandidateOperations

def create_candidate(erecruit_token:, erecruit_platform_url:, candidate:)

def create_candidate(erecruit_token:, erecruit_platform_url:, candidate:)
  parsed_http_post(
    headers: { "Authorization" => "Bearer #{erecruit_token}" },
    url: "#{erecruit_platform_url}/Candidate",
    body: candidate
  )
end

def create_candidate!(erecruit_token:, erecruit_platform_url:, candidate:, error_message:, error_data: nil)

def create_candidate!(erecruit_token:, erecruit_platform_url:, candidate:, error_message:, error_data: nil)
  response = safe_http_post(
    headers: { "Authorization" => "Bearer #{erecruit_token}" },
    url: "#{erecruit_platform_url}/Candidate",
    body: candidate,
    error_message: error_message,
    error_data: error_data
  )
  response.body
end

def submit_candidate_cv(erecruit_token:, erecruit_platform_url:, candidate_id:, cv_url:)

def submit_candidate_cv(erecruit_token:, erecruit_platform_url:, candidate_id:, cv_url:)
  filename, bytes = bytes_from_url(cv_url).values_at(:filename, :bytes)
  parsed_http_post(
    headers: {
      'Authorization' => "Bearer #{erecruit_token}",
      'Content-Type' => "form-data"
    },
    url: "#{erecruit_platform_url}/Attachment",
    body: {
      aboutType: "Candidate",
      referenceID: candidate_id,
      attachmentTypeID: "Resume",
      name: filename,
      Resume: bytes
    }
  )
end

def update_candidate(erecruit_token:, erecruit_platform_url:, candidate_id:, candidate:)

def update_candidate(erecruit_token:, erecruit_platform_url:, candidate_id:, candidate:)
  parsed_http_put(
    headers: { "Authorization" => "Bearer #{erecruit_token}" },
    url: "#{erecruit_platform_url}/Candidate/#{candidate_id}",
    body: candidate,
    error_message: error_message,
    error_data: error_data,
  )
end

def update_candidate!(erecruit_token:, erecruit_platform_url:, candidate_id:, candidate:, error_message:, error_data: nil)

def update_candidate!(erecruit_token:, erecruit_platform_url:, candidate_id:, candidate:, error_message:, error_data: nil)
  response = safe_http_put(
    headers: { "Authorization" => "Bearer #{erecruit_token}" },
    url: "#{erecruit_platform_url}/Candidate/#{candidate_id}",
    body: candidate,
    error_message: error_message,
    error_data: error_data,
  )
  response.body
end