Class: Bamboozled::API::Employee
- Inherits:
-
Base
- Object
- Base
- Bamboozled::API::Employee
show all
- Defined in:
- lib/bamboozled/api/employee.rb
Instance Attribute Summary
Attributes inherited from Base
#api_key, #subdomain
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#all(fields = nil) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/bamboozled/api/employee.rb', line 5
def all(fields = nil)
response = request(:get, "employees/directory")
if fields.nil? || fields == :default
Array(response['employees'])
else
employees = []
response['employees'].map{|e| e['id']}.each do |id|
employees << find(id, fields)
end
employees
end
end
|
#all_fields ⇒ Object
38
39
40
|
# File 'lib/bamboozled/api/employee.rb', line 38
def all_fields
%w(address1 address2 age bestEmail birthday city country dateOfBirth department division eeo employeeNumber employmentHistoryStatus ethnicity exempt firstName flsaCode fullName1 fullName2 fullName3 fullName4 fullName5 displayName gender hireDate homeEmail homePhone id jobTitle lastChanged lastName location maritalStatus middleName mobilePhone nickname payChangeReason payGroup payGroupId payRate payRateEffectiveDate payType ssn sin state stateCode status supervisor supervisorId supervisorEId terminationDate workEmail workPhone workPhonePlusExtension workPhoneExtension zipcode photoUploaded rehireDate standardHoursPerWeek bonusDate bonusAmount bonusReason bonusComment commissionDate commisionDate commissionAmount commissionComment).join(',')
end
|
#find(employee_id, fields = nil) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/bamboozled/api/employee.rb', line 19
def find(employee_id, fields = nil)
fields = all_fields if fields == :all
fields = fields.join(',') if fields.is_a?(Array)
request(:get, "employees/#{employee_id}?fields=#{fields}")
end
|
#photo_binary(employee_id) ⇒ Object
42
43
44
|
# File 'lib/bamboozled/api/employee.rb', line 42
def photo_binary(employee_id)
request(:get, "employees/#{employee_id}/photo/small")
end
|
#photo_url(employee) ⇒ Object
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/bamboozled/api/employee.rb', line 46
def photo_url(employee)
if (Float(employee) rescue false)
e = find(employee, ['workEmail', 'homeEmail'])
employee = e['workEmail'].nil? ? e['homeEmail'] : e['workEmail']
end
digest = Digest::MD5.new
digest.update(employee.strip.downcase)
"http://#{@subdomain}.bamboohr.com/employees/photos/?h=#{digest}"
end
|
#time_off_estimate(employee_id, end_date) ⇒ Object
33
34
35
36
|
# File 'lib/bamboozled/api/employee.rb', line 33
def time_off_estimate(employee_id, end_date)
end_date = end_date.strftime("%F") unless end_date.is_a?(String)
request(:get, "employees/#{employee_id}/time_off/calculator?end=#{end_date}")
end
|