Class: Pike13::CLI::Commands::Desk::FormOfPayment
- Inherits:
-
Base
- Object
- Thor
- Base
- Pike13::CLI::Commands::Desk::FormOfPayment
show all
- Defined in:
- lib/pike13/cli/commands/desk/form_of_payment.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
format_options, handle_argument_error, printable_commands
included
Class Method Details
.base_usage ⇒ Object
Override base_usage to match the actual subcommand registration
9
10
11
|
# File 'lib/pike13/cli/commands/desk/form_of_payment.rb', line 9
def self.base_usage
"desk forms_of_payment"
end
|
Instance Method Details
#create(person_id) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/pike13/cli/commands/desk/form_of_payment.rb', line 38
def create(person_id)
handle_error do
attributes = {
type: options[:type],
token: options[:token],
is_default: options[:is_default]
}
result = Pike13::Desk::FormOfPayment.create(person_id: person_id, attributes: attributes)
output(result)
success_message "Form of payment created successfully"
end
end
|
#delete(person_id, fop_id) ⇒ Object
65
66
67
68
69
70
|
# File 'lib/pike13/cli/commands/desk/form_of_payment.rb', line 65
def delete(person_id, fop_id)
handle_error do
Pike13::Desk::FormOfPayment.destroy(person_id: person_id, id: fop_id)
success_message "Form of payment #{fop_id} deleted successfully"
end
end
|
#get(person_id, fop_id) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/pike13/cli/commands/desk/form_of_payment.rb', line 26
def get(person_id, fop_id)
handle_error do
result = Pike13::Desk::FormOfPayment.find(person_id: person_id, id: fop_id)
output(result)
end
end
|
#list(person_id) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/pike13/cli/commands/desk/form_of_payment.rb', line 15
def list(person_id)
handle_error do
result = with_progress("Fetching forms of payment") do
Pike13::Desk::FormOfPayment.all(person_id: person_id)
end
output(result)
end
end
|
#update(person_id, fop_id) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/pike13/cli/commands/desk/form_of_payment.rb', line 54
def update(person_id, fop_id)
handle_error do
attributes = {}
attributes[:is_default] = options[:is_default] if options.key?(:is_default)
result = Pike13::Desk::FormOfPayment.update(person_id: person_id, id: fop_id, attributes: attributes)
output(result)
success_message "Form of payment updated successfully"
end
end
|