lib/bamboozled/api/time_off.rb in bamboozled-0.0.7 vs lib/bamboozled/api/time_off.rb in bamboozled-0.1.0
- old
+ new
@@ -1,21 +1,22 @@
module Bamboozled
module API
class TimeOff < Base
-
def requests(options = {})
- allowed_parameters = [:id, :action, :employeeId, :start, :end, :type, :status]
+ allowed_parameters = %i(id action employeeId start end type status)
options = options.keep_if { |k,_| allowed_parameters.include? k }
# Convert non string dates to strings.
[:start, :end].each do |action|
options[action] = options[action].strftime("%F") if options[action] && !options[action].is_a?(String)
end
# Make sure all statuses are allowed
if options[:status]
allowed_statuses = %w(approved denied superceded requested canceled)
- options[:status] = Array(options[:status]).keep_if { |v| allowed_statuses.include? v }.join(",")
+ 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