Class: Squall::Payment
Overview
OnApp Payment
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(user_id, options = {}) ⇒ Object
Public: Create a payment for a user.
-
#delete(user_id, id) ⇒ Object
Public: Delete a payment.
-
#edit(user_id, id, options = {}) ⇒ Object
Public: Edit a payment.
-
#list(user_id) ⇒ Object
Public: Lists all payments.
Methods inherited from Base
#check_config, #default_params, #key_for_class, #request
Instance Method Details
#create(user_id, options = {}) ⇒ Object
Public: Create a payment for a user.
user_id - ID of the user options - Params for creating the User:
:amount - Amount of the payment
:invoice_number - Number of the invoice
Example
create amount: 500, invoice_number: "01234"
Returns a Hash.
24 25 26 |
# File 'lib/squall/payment.rb', line 24 def create(user_id, = {}) request(:post, "/users/#{user_id}/payments.json", default_params()) end |
#delete(user_id, id) ⇒ Object
Public: Delete a payment
user_id - ID of the user id - ID of the payment
Returns a Hash.
45 46 47 |
# File 'lib/squall/payment.rb', line 45 def delete(user_id, id) request(:delete, "/users/#{user_id}/payments/#{id}.json") end |
#edit(user_id, id, options = {}) ⇒ Object
Public: Edit a payment
user_id - ID of the user id - ID of the payment options - Params for editing the payment, see ‘#create`
Returns a Hash.
35 36 37 |
# File 'lib/squall/payment.rb', line 35 def edit(user_id, id, = {}) request(:put, "/users/#{user_id}/payments/#{id}.json", default_params()) end |
#list(user_id) ⇒ Object
Public: Lists all payments.
Returns an Array.
7 8 9 10 |
# File 'lib/squall/payment.rb', line 7 def list(user_id) response = request(:get, "/users/#{user_id}/payments.json") response.collect { |user| user['payment'] } end |