Class: Bamboozled::API::TimeOff
- Inherits:
-
Base
- Object
- Base
- Bamboozled::API::TimeOff
show all
- Defined in:
- lib/bamboozled/api/time_off.rb
Instance Attribute Summary
Attributes inherited from Base
#api_key, #subdomain
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#requests(options = {}) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/bamboozled/api/time_off.rb', line 4
def requests(options = {})
allowed_parameters = %i[id action employeeId start end type status]
options = options.keep_if { |k, _| allowed_parameters.include? k }
%i[start end].each do |action|
if options[action] && !options[action].is_a?(String)
options[action] = options[action].strftime("%F")
end
end
if options[:status]
allowed_statuses = %w[approved denied superceded requested canceled]
options[:status] = Array(options[:status])
.keep_if { |v| allowed_statuses.include? v }
.join(",")
end
request(:get, "time_off/requests?#{URI.encode_www_form(options)}")
end
|
#whos_out(start_date, end_date = nil) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/bamboozled/api/time_off.rb', line 26
def whos_out(start_date, end_date = nil)
start_date = start_date.strftime("%F") unless start_date.is_a?(String)
end_date = end_date.strftime("%F") unless end_date.nil? ||
end_date.is_a?(String)
request(:get, "time_off/whos_out?start=#{start_date}&end=#{end_date}")
end
|