class PinPayment::Transfer
Attributes
amount[RW]
currency[RW]
description[RW]
paid_at[RW]
recipient[RW]
status[RW]
token[RW]
total_credits[RW]
total_debits[RW]
Public Class Methods
all()
click to toggle source
Fetches all of your transfers using the pin API.
@return [Array<PinPayment::Transfer>] TODO: pagination
# File lib/pin_payment/transfer.rb, line 26 def self.all response = get(URI.parse(PinPayment.api_url).tap{|uri| uri.path = '/1/transfers' }) response.map{|x| new(x.delete('token'), x) } end
create(transfer_data)
click to toggle source
Uses the pin API to create a transfer.
@param [Hash] transfer_data @option transfer_data [String] :description required @option transfer_data [String] :amount required @option transfer_data [String] :currency required (Currenly only AUD is supported) @option transfer_data [String] :recipient required a token for a stored recipient @return [PinPayment::Transfer]
# File lib/pin_payment/transfer.rb, line 15 def self.create transfer_data attributes = self.attributes - [:token] # fix attributes allowed by POST API options = parse_options_for_request(attributes, transfer_data) response = post(URI.parse(PinPayment.api_url).tap{|uri| uri.path = '/1/transfers' }, options) new(response.delete('token'), response) end
find(token)
click to toggle source
Fetches a transfer using the pin API.
@param [String] token the recipient token @return [PinPayment::Transfer]
# File lib/pin_payment/transfer.rb, line 35 def self.find token response = get(URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/transfers/#{token}" }) new(response.delete('token'), response) end
Protected Class Methods
attributes()
click to toggle source
# File lib/pin_payment/transfer.rb, line 47 def self.attributes [:token, :description, :amount, :currency, :recipient, :status, :paid_at, :total_debits, :total_credits] end
Public Instance Methods
line_items()
click to toggle source
# File lib/pin_payment/transfer.rb, line 40 def line_items response = self.class.get(URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/transfers/#{token}/line_items" }) response.map{|hash| LineItem.new(hash.delete('token')) } end