Class: Pike13::CLI::Commands::Desk::Note
- Inherits:
-
Base
- Object
- Thor
- Base
- Pike13::CLI::Commands::Desk::Note
show all
- Defined in:
- lib/pike13/cli/commands/desk/note.rb
Instance Method Summary
collapse
Methods inherited from Base
base_usage, format_options, handle_argument_error, printable_commands
included
Instance Method Details
#create(person_id) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/pike13/cli/commands/desk/note.rb', line 33
def create(person_id)
handle_error do
attributes = {
subject: options[:subject],
note: options[:note]
}
result = Pike13::Desk::Note.create(person_id: person_id, attributes: attributes)
output(result)
success_message "Note created successfully"
end
end
|
#delete(person_id, note_id) ⇒ Object
61
62
63
64
65
66
|
# File 'lib/pike13/cli/commands/desk/note.rb', line 61
def delete(person_id, note_id)
handle_error do
Pike13::Desk::Note.destroy(person_id: person_id, id: note_id)
success_message "Note #{note_id} deleted successfully"
end
end
|
#get(person_id, note_id) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/pike13/cli/commands/desk/note.rb', line 22
def get(person_id, note_id)
handle_error do
result = Pike13::Desk::Note.find(person_id: person_id, id: note_id)
output(result)
end
end
|
#list(person_id) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/pike13/cli/commands/desk/note.rb', line 11
def list(person_id)
handle_error do
result = with_progress("Fetching notes") do
Pike13::Desk::Note.all(person_id: person_id)
end
output(result)
end
end
|
#update(person_id, note_id) ⇒ Object
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/pike13/cli/commands/desk/note.rb', line 49
def update(person_id, note_id)
handle_error do
attributes = {}
attributes[:subject] = options[:subject] if options[:subject]
attributes[:note] = options[:note] if options[:note]
result = Pike13::Desk::Note.update(person_id: person_id, id: note_id, attributes: attributes)
output(result)
success_message "Note updated successfully"
end
end
|