Class: Pike13::CLI::Commands::Desk::PersonVisit

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

format_options, handle_argument_error, printable_commands

Methods included from ThorNestedSubcommand

included

Class Method Details

.base_usageObject

Override base_usage to match the actual subcommand registration



9
10
11
# File 'lib/pike13/cli/commands/desk/person_visit.rb', line 9

def self.base_usage
  "desk person_visits"
end

Instance Method Details

#list(person_id) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pike13/cli/commands/desk/person_visit.rb', line 18

def list(person_id)
  validate_date_format(options[:from], "from") if options[:from]
  validate_date_format(options[:to], "to") if options[:to]

  handle_error do
    params = {}
    params[:from] = options[:from] if options[:from]
    params[:to] = options[:to] if options[:to]
    params[:event_occurrence_id] = options[:event_occurrence_id] if options[:event_occurrence_id]

    result = with_progress("Fetching visits for person #{person_id}") do
      Pike13::Desk::PersonVisit.all(person_id: person_id, **params)
    end
    output(result)
  end
end