lib/squall/payment.rb in squall-1.3.0 vs lib/squall/payment.rb in squall-1.3.1

- old
+ new

@@ -1,59 +1,49 @@ module Squall # OnApp Payment class Payment < Base - - # Return a list of all payments + # Public: Lists all payments. + # + # Returns an Array. def list(user_id) response = request(:get, "/users/#{user_id}/payments.json") response.collect { |user| user['payment'] } end - # Create a payment for a user + # Public: Create a payment for a user. # - # ==== Params + # user_id - ID of the user + # options - Params for creating the User: + # :amount - Amount of the payment + # :invoice_number - Number of the invoice # - # * +user_id*+ - ID of the user - # * +options+ - Params for creating the User + # Example # - # ==== Options + # create amount: 500, invoice_number: "01234" # - # * +amount*+ - Amount of the payment - # * +invoice_number+ - Number of the invoice - # - # ==== Example - # - # create :amount => 500, - # :invoice_number => "01234", - def create(user_id, options={}) - params.required(:amount).accepts(:invoice_number).validate!(options) + # Returns a Hash. + def create(user_id, options = {}) request(:post, "/users/#{user_id}/payments.json", default_params(options)) end - # Edit a payment + # Public: Edit a payment # - # ==== Params + # user_id - ID of the user + # id - ID of the payment + # options - Params for editing the payment, see `#create` # - # * +user_id*+ - ID of the user - # * +id*+ - ID of the payment - # * +options+ - Params for editing the payment - # - # ==== Options - # - # See #create - def edit(user_id, id, options={}) - params.accepts(:amount, :invoice_number).validate!(options) + # Returns a Hash. + def edit(user_id, id, options = {}) request(:put, "/users/#{user_id}/payments/#{id}.json", default_params(options)) end - # Delete a payment + # Public: Delete a payment # - # ==== Params + # user_id - ID of the user + # id - ID of the payment # - # * +user_id*+ - ID of the user - # * +id*+ - ID of the payment + # Returns a Hash. def delete(user_id, id) request(:delete, "/users/#{user_id}/payments/#{id}.json") end - end end