Class: Zohoho::Recruit

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/zohoho/recruit.rb

Instance Method Summary collapse

Constructor Details

#initialize(username, password, apikey, type = 'json') ⇒ Recruit

Returns a new instance of Recruit.



9
10
11
12
# File 'lib/zohoho/recruit.rb', line 9

def initialize(username, password, apikey, type = 'json')
  @type = type
  @conn = Zohoho::Connection.new 'zohopeople', username, password, apikey
end

Instance Method Details

#auth_urlObject



14
15
16
# File 'lib/zohoho/recruit.rb', line 14

def auth_url
  @conn.ticket_url
end

#candidates(conditions = {}) ⇒ Object



26
27
28
# File 'lib/zohoho/recruit.rb', line 26

def candidates(conditions = {})
  @candidates ||= get_candidates(conditions)
end

#candidates_url(type = @type) ⇒ Object



18
19
20
# File 'lib/zohoho/recruit.rb', line 18

def candidates_url(type = @type)
  "http://recruit.zoho.com/ats/private/#{type}/Candidates/getRecords?apikey=#{@conn.api_key}&ticket=#{@conn.ticket}"
end

#get_candidates(conditions = {}) ⇒ Object



22
23
24
# File 'lib/zohoho/recruit.rb', line 22

def get_candidates(conditions = {})
  (@type == 'json' ? JSON.parse(self.class.get(candidates_url+"&#{conditions.to_params}")) : Nokogiri::XML.parse(self.class.get(candidates_url, conditions)))
end

#get_parsed_candidates(conditions = {:fromIndex => 1, :toIndex => 200}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/zohoho/recruit.rb', line 30

def get_parsed_candidates(conditions = {:fromIndex => 1, :toIndex => 200})
  raw_candidates = candidates(conditions)
  @candidates = raw_candidates["response"]["result"]["Candidates"]["row"]
  
  #extracts the relevant data
  @candidates.collect! do |candidate|
    @hash = {}
    candidate["FL"].collect do |pair|
      pair = pair.to_a
      @hash[pair.last.last.to_s] = pair.first.last
    end
    @hash
  end
  @candidates
end