Class: Zohoho::Recruit
- Inherits:
-
Object
- Object
- Zohoho::Recruit
- Includes:
- HTTParty
- Defined in:
- lib/zohoho/recruit.rb
Instance Method Summary collapse
- #auth_url ⇒ Object
- #candidates(conditions = {}) ⇒ Object
- #candidates_url(type = @type) ⇒ Object
- #get_candidates(conditions = {:fromIndex => 1, :toIndex => 100}) ⇒ Object
- #get_parsed_candidates(conditions) ⇒ Object
-
#initialize(username, password, apikey, type = 'json') ⇒ Recruit
constructor
A new instance of Recruit.
- #set_default_timeout(t) ⇒ Object
Constructor Details
#initialize(username, password, apikey, type = 'json') ⇒ Recruit
Returns a new instance of Recruit.
13 14 15 16 |
# File 'lib/zohoho/recruit.rb', line 13 def initialize(username, password, apikey, type = 'json') @type = type @conn = Zohoho::Connection.new 'zohopeople', username, password, apikey end |
Instance Method Details
#auth_url ⇒ Object
18 19 20 |
# File 'lib/zohoho/recruit.rb', line 18 def auth_url @conn.ticket_url end |
#candidates(conditions = {}) ⇒ Object
30 31 32 |
# File 'lib/zohoho/recruit.rb', line 30 def candidates(conditions = {}) @candidates = get_candidates(conditions) end |
#candidates_url(type = @type) ⇒ Object
22 23 24 |
# File 'lib/zohoho/recruit.rb', line 22 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 = {:fromIndex => 1, :toIndex => 100}) ⇒ Object
26 27 28 |
# File 'lib/zohoho/recruit.rb', line 26 def get_candidates(conditions = {:fromIndex => 1, :toIndex => 100}) (@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) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/zohoho/recruit.rb', line 34 def get_parsed_candidates(conditions) 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 |
#set_default_timeout(t) ⇒ Object
9 10 11 |
# File 'lib/zohoho/recruit.rb', line 9 def set_default_timeout(t) default_timeout t end |