class Recruitee::API::Candidates

Public Class Methods

new(client) click to toggle source
Calls superclass method
# File lib/recruitee/api/candidates.rb, line 6
def initialize(client)
  super(client, Candidate)
end

Public Instance Methods

create(offers: [], **candidate) click to toggle source
Calls superclass method
# File lib/recruitee/api/candidates.rb, line 10
def create(offers: [], **candidate)
  super({ offers: offers, candidate: candidate })
end
find_by_email(email) click to toggle source
# File lib/recruitee/api/candidates.rb, line 14
def find_by_email(email)
  hits = search_for_email(email)
  # Recruitee's search is very fuzzy, so we need to find the real match
  match = hits.find { |hit| hit['emails'].include?(email) }

  match ? find(match['id']) : nil
end

Private Instance Methods

search_for(email) click to toggle source
# File lib/recruitee/api/candidates.rb, line 24
def search_for(email)
  search = {
    query: email, limit: 100, only: 'candidates', with_emails: true
  }
  res = request(:get, '/search/new/quick', params: search)

  res.dig('candidates', 'hits')
end