Class: Pin::Charges

Inherits:
Base
  • Object
show all
Defined in:
lib/pin_up/charge.rb

Overview

This class models Pin’s Charges API

Class Method Summary collapse

Methods inherited from Base

#initialize, #key, #uri

Constructor Details

This class inherits a constructor from Pin::Base

Class Method Details

.allObject

Lists all of the charges for your account returns: a collection of charge objects pin.net.au/docs/api/charges#get-charges



9
10
11
# File 'lib/pin_up/charge.rb', line 9

def self.all
  build_response(auth_get('charges'))
end

.create(options = {}) ⇒ Object

Create a charge given charge details and a card, a card_token or acustomer_token args: options (Hash) returns: a charge object pin.net.au/docs/api/charges#post-charges



38
39
40
# File 'lib/pin_up/charge.rb', line 38

def self.create(options = {})
  build_response(auth_post("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



18
19
20
# File 'lib/pin_up/charge.rb', line 18

def self.find(token)
  build_response(auth_get("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



26
27
28
29
30
31
32
# File 'lib/pin_up/charge.rb', line 26

def self.search(options = {})
  term = ""
  options.each do |key, option|
    term += "#{key.to_s}=#{URI::encode(option)}&"
  end
  build_response(auth_get("charges/search?#{term}"))
end