Class: Pike13::CLI::Commands::Desk::Appointment

Inherits:
Base
  • Object
show all
Defined in:
lib/pike13/cli/commands/desk/appointment.rb

Instance Method Summary collapse

Methods inherited from Base

base_usage, format_options, handle_argument_error, printable_commands

Methods included from ThorNestedSubcommand

included

Instance Method Details

#available(service_id) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pike13/cli/commands/desk/appointment.rb', line 13

def available(service_id)
  # Validate date format
  validate_date_format(options[:date], "date")

  handle_error do
    params = { date: options[:date] }
    params[:location_ids] = options[:location_ids] if options[:location_ids]
    params[:staff_member_ids] = options[:staff_member_ids] if options[:staff_member_ids]

    result = with_progress("Fetching available slots") do
      Pike13::Desk::Appointment.find_available_slots(service_id: service_id, **params)
    end
    output(result)
  end
end

#summary(service_id) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/pike13/cli/commands/desk/appointment.rb', line 35

def summary(service_id)
  # Validate date formats
  validate_date_format(options[:from], "from")
  validate_date_format(options[:to], "to")

  handle_error do
    params = {
      from: options[:from],
      to: options[:to]
    }
    params[:location_ids] = options[:location_ids] if options[:location_ids]
    params[:staff_member_ids] = options[:staff_member_ids] if options[:staff_member_ids]

    result = with_progress("Fetching availability summary") do
      Pike13::Desk::Appointment.available_slots_summary(service_id: service_id, **params)
    end
    output(result)
  end
end