Class: Bob::Employees
- Inherits:
-
API
- Object
- API
- Bob::Employees
show all
- Defined in:
- lib/bob/api/employees.rb
Constant Summary
Constants inherited
from API
API::BASE_URL
Class Method Summary
collapse
Methods inherited from API
build_url, content_headers, create_csv, delete, get, headers, post, put
Class Method Details
.all(params = { includeHumanReadable: true }) ⇒ Object
12
13
14
15
|
# File 'lib/bob/api/employees.rb', line 12
def self.all(params = { includeHumanReadable: true })
response = get('people', params)
EmployeeParser.new(response).employees
end
|
.all_people_managers(params = { includeHumanReadable: true }) ⇒ Object
17
18
19
20
|
# File 'lib/bob/api/employees.rb', line 17
def self.all_people_managers(params = { includeHumanReadable: true })
response = get('people', params)
EmployeeParser.new(response).managers
end
|
.find(employee_id_or_email, params: { includeHumanReadable: true }) ⇒ Object
22
23
24
25
|
# File 'lib/bob/api/employees.rb', line 22
def self.find(employee_id_or_email, params: { includeHumanReadable: true })
response = get("people/#{employee_id_or_email}", params)
EmployeeParser.new(response).employee
end
|
.find_by(field:, value:, params: { includeHumanReadable: true }) ⇒ Object
27
28
29
30
31
|
# File 'lib/bob/api/employees.rb', line 27
def self.find_by(field:, value:, params: { includeHumanReadable: true })
all(params).find do |employee|
employee.send(field) == value
end
end
|
.update_email(employee_id, email) ⇒ Object
38
39
40
|
# File 'lib/bob/api/employees.rb', line 38
def self.update_email(employee_id, email)
put("people/#{employee_id}/email", { email: email })
end
|
.update_start_date(employee_id, start_date) ⇒ Object
start date needs to be in ISO format
34
35
36
|
# File 'lib/bob/api/employees.rb', line 34
def self.update_start_date(employee_id, start_date)
post("employees/#{employee_id}", { startDate: start_date })
end
|