Class: Pike13::CLI::Commands::Desk::EventOccurrenceNote

Inherits:
Base
  • Object
show all
Defined in:
lib/pike13/cli/commands/desk/event_occurrence_note.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/event_occurrence_note.rb', line 9

def self.base_usage
  "desk event_occurrence_notes"
end

Instance Method Details

#create(event_occurrence_id) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/pike13/cli/commands/desk/event_occurrence_note.rb', line 36

def create(event_occurrence_id)
  handle_error do
    attributes = {
      note: options[:note],
      subject: options[:subject]
    }
    result = with_progress("Creating event occurrence note") do
      Pike13::Desk::EventOccurrenceNote.create(event_occurrence_id: event_occurrence_id,
                                               attributes: attributes)
    end
    output(result)
  end
end

#delete(event_occurrence_id, id) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/pike13/cli/commands/desk/event_occurrence_note.rb', line 70

def delete(event_occurrence_id, id)
  handle_error do
    result = with_progress("Deleting event occurrence note") do
      Pike13::Desk::EventOccurrenceNote.destroy(event_occurrence_id: event_occurrence_id, id: id)
    end
    output(result)
  end
end

#get(event_occurrence_id, id) ⇒ Object



25
26
27
28
29
30
# File 'lib/pike13/cli/commands/desk/event_occurrence_note.rb', line 25

def get(event_occurrence_id, id)
  handle_error do
    result = Pike13::Desk::EventOccurrenceNote.find(event_occurrence_id: event_occurrence_id, id: id)
    output(result)
  end
end

#list(event_occurrence_id) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/pike13/cli/commands/desk/event_occurrence_note.rb', line 14

def list(event_occurrence_id)
  handle_error do
    result = with_progress("Fetching event occurrence notes") do
      Pike13::Desk::EventOccurrenceNote.all(event_occurrence_id: event_occurrence_id)
    end
    output(result)
  end
end

#update(event_occurrence_id, id) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/pike13/cli/commands/desk/event_occurrence_note.rb', line 54

def update(event_occurrence_id, id)
  handle_error do
    attributes = {}
    attributes[:note] = options[:note] if options[:note]
    attributes[:subject] = options[:subject] if options[:subject]

    result = with_progress("Updating event occurrence note") do
      Pike13::Desk::EventOccurrenceNote.update(event_occurrence_id: event_occurrence_id, id: id,
                                               attributes: attributes)
    end
    output(result)
  end
end