lib/supersaas-api-client/api/appointments.rb in supersaas-api-client-1.0.0 vs lib/supersaas-api-client/api/appointments.rb in supersaas-api-client-1.1.0
- old
+ new
@@ -115,25 +115,23 @@
path = "/bookings/#{validate_id(appointment_id)}"
params = {schedule_id: validate_id(schedule_id)}
client.delete(path, nil, params)
end
- def changes(schedule_id, from_time)
+ def changes(schedule_id, from_time=nil, to=nil, slot=false)
path = "/changes/#{validate_id(schedule_id)}"
- params = { from: validate_datetime(from_time) }
+ params = build_param({}, from_time, to, slot)
res = client.get(path, params)
map_slots_or_bookings(res)
end
- def changes_slots(schedule_id, from_time)
- path = "/changes/#{validate_id(schedule_id)}"
- params = {
- from: validate_datetime(from_time),
- slot: true
- }
+ def range(schedule_id, today=false, from_time=nil, to=nil, slot=false)
+ path = "/range/#{validate_id(schedule_id)}"
+ params = {}; params.merge!(today: true) if today
+ params = build_param(params, from_time, to, slot)
res = client.get(path, params)
- map_slots_or_bookings(res, true)
+ map_slots_or_bookings(res)
end
private
def map_slots_or_bookings(obj, slot=false)
@@ -146,8 +144,15 @@
elsif obj['bookings']
obj['bookings'].map { |attributes| Supersaas::Appointment.new(attributes) }
else
[]
end
+ end
+
+ def build_param(params, from_time, to, slot)
+ params.merge!(from: validate_datetime(from_time)) if from_time
+ params.merge!(to: validate_datetime(to)) if to
+ params.merge!(slot: true) if slot
+ params
end
end
end
\ No newline at end of file