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

.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]

pin.net.au/docs/api/charges#get-charges



14
15
16
# File 'lib/pin_up/charge.rb', line 14

def self.all(page=nil, pagination=false)
  build_collection_response(auth_get("charges?page=#{page}"),pagination)
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



43
44
45
# File 'lib/pin_up/charge.rb', line 43

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



23
24
25
# File 'lib/pin_up/charge.rb', line 23

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



31
32
33
34
35
36
37
# File 'lib/pin_up/charge.rb', line 31

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