Class: Pike13::CLI::Commands::Front::FormOfPayment
- Inherits:
-
Base
- Object
- Thor
- Base
- Pike13::CLI::Commands::Front::FormOfPayment
show all
- Defined in:
- lib/pike13/cli/commands/front/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/front/form_of_payment.rb', line 9
def self.base_usage
"front forms_of_payment"
end
|
Instance Method Details
#create(person_id) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/pike13/cli/commands/front/form_of_payment.rb', line 46
def create(person_id)
handle_error do
attributes = {
type: options[:type],
token: options[:token],
is_default: options[:is_default]
}
result = Pike13::Front::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
73
74
75
76
77
78
|
# File 'lib/pike13/cli/commands/front/form_of_payment.rb', line 73
def delete(person_id, fop_id)
handle_error do
Pike13::Front::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
25
26
27
28
29
30
|
# File 'lib/pike13/cli/commands/front/form_of_payment.rb', line 25
def get(person_id, fop_id)
handle_error do
result = Pike13::Front::FormOfPayment.find(person_id: person_id, id: fop_id)
output(result)
end
end
|
#list(person_id) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/pike13/cli/commands/front/form_of_payment.rb', line 14
def list(person_id)
handle_error do
result = with_progress("Fetching forms of payment") do
Pike13::Front::FormOfPayment.all(person_id: person_id)
end
output(result)
end
end
|
#me(fop_id) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/pike13/cli/commands/front/form_of_payment.rb', line 34
def me(fop_id)
handle_error do
result = Pike13::Front::FormOfPayment.find_me(id: fop_id)
output(result)
end
end
|
#update(person_id, fop_id) ⇒ Object
62
63
64
65
66
67
68
69
70
|
# File 'lib/pike13/cli/commands/front/form_of_payment.rb', line 62
def update(person_id, fop_id)
handle_error do
attributes = {}
attributes[:is_default] = options[:is_default] if options.key?(:is_default)
result = Pike13::Front::FormOfPayment.update(person_id: person_id, id: fop_id, attributes: attributes)
output(result)
success_message "Form of payment updated successfully"
end
end
|