Class: Pin::Charges
Overview
This class models Pin’s Charges API
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.all(page = nil, pagination = false) ⇒ Object
Lists all of the charges for your account args: page (Fixnum), pagination (Boolean) returns: a collection of charge objects.
-
.capture(token) ⇒ Object
Captures a previously authorised charge and returns its details.
-
.create(options = {}) ⇒ Object
Create a charge given charge details and a card, a card_token or a customer_token args: options (Hash) returns: a charge object pin.net.au/docs/api/charges#post-charges.
-
.find(token) ⇒ Object
Find a charge for your account given a token args: token (String) returns: a charge object pin.net.au/docs/api/charges#get-charge.
-
.search(options = {}) ⇒ Object
Find a charge(s) for your account given a search term or set of terms args: options (Hash) returns: a collection of charge objects pin.net.au/docs/api/charges#search-charges.
Methods inherited from Base
#base_uri, build_collection_response, build_response, #initialize, make_request
Constructor Details
This class inherits a constructor from Pin::Base
Class Method Details
.all(page = nil, pagination = false) ⇒ Object
Lists all of the charges for your account args: page (Fixnum), pagination (Boolean) returns: a collection of charge objects
if pagination is passed, access the response hash with [:response] and the pagination hash with [:pagination]
14 15 16 |
# File 'lib/pin_up/charge.rb', line 14 def self.all(page = nil, pagination = false) build_collection_response(make_request(:get, { url: "charges?page=#{page}" }), pagination) end |
.capture(token) ⇒ Object
Captures a previously authorised charge and returns its details. args: charge-token (String) returns: charge object pin.net.au/docs/api/charges#put-charges
52 53 54 |
# File 'lib/pin_up/charge.rb', line 52 def self.capture(token) build_response(make_request(:put, { url: "/charges/#{token}/capture" } )) end |
.create(options = {}) ⇒ Object
Create a charge given charge details and a card, a card_token or a customer_token args: options (Hash) returns: a charge object pin.net.au/docs/api/charges#post-charges
44 45 46 |
# File 'lib/pin_up/charge.rb', line 44 def self.create( = {}) build_response(make_request(:post, {url: 'charges', options: } )) end |
.find(token) ⇒ Object
Find a charge for your account given a token args: token (String) returns: a charge object pin.net.au/docs/api/charges#get-charge
23 24 25 |
# File 'lib/pin_up/charge.rb', line 23 def self.find(token) build_response(make_request(:get, {url: "charges/#{token}" } )) end |
.search(options = {}) ⇒ Object
Find a charge(s) for your account given a search term or set of terms args: options (Hash) returns: a collection of charge objects pin.net.au/docs/api/charges#search-charges
31 32 33 34 35 36 37 |
# File 'lib/pin_up/charge.rb', line 31 def self.search( = {}) term = '' .each do |key, option| term += "#{key.to_s}=#{URI.encode(option)}&" end build_response(make_request(:get, {url: "charges/search?#{term}" } )) end |