Skip to content

Commit

Permalink
Only translate query periods when they are passed as options
Browse files Browse the repository at this point in the history
  • Loading branch information
CronofyMatt committed Jul 27, 2023
1 parent c953a9d commit 27fa83a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/cronofy/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,10 @@ def resources
# each must specify a start and end Time.
# :start_interval - An Integer representing the start interval
# of minutes for the availability query.
# :buffer - An Hash containing the buffer to apply to
# :buffer - A Hash containing the buffer to apply to
# the availability query.
# :query_slots - A Hash containing the query slots to be
# used in the availability query.
#
# Returns an Array of AvailablePeriods.
#
Expand All @@ -861,10 +863,12 @@ def availability(options = {})
options[:buffer] = map_availability_buffer(buffer)
end

translate_available_periods(options[:query_periods] || options[:available_periods])
if query_periods = options[:query_periods] || options[:available_periods]
translate_available_periods(query_periods)
end

if query_slots = options[:query_slots]
translate_query_slots(options:[:query_slots])
translate_query_slots(query_slots)
end

response = availability_post("/v1/availability", options)
Expand Down Expand Up @@ -1722,7 +1726,7 @@ def translate_available_periods(periods)
end

def translate_query_slots(query_slots)
periods.each do |params|
query_slots.each do |params|
QUERY_SLOTS_TIME_PARAMS.select { |tp| params.key?(tp) }.each do |tp|
params[tp] = to_iso8601(params[tp])
end
Expand Down

0 comments on commit 27fa83a

Please sign in to comment.