Class: PinPayment::Transfer
Defined Under Namespace
Classes: LineItem
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#paid_at ⇒ Object
readonly
Returns the value of attribute paid_at.
-
#recipient ⇒ Object
readonly
Returns the value of attribute recipient.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#total_credits ⇒ Object
readonly
Returns the value of attribute total_credits.
-
#total_debits ⇒ Object
readonly
Returns the value of attribute total_debits.
Class Method Summary collapse
-
.all ⇒ Array<PinPayment::Transfer>
Fetches all of your transfers using the pin API.
-
.create(transfer_data) ⇒ PinPayment::Transfer
Uses the pin API to create a transfer.
-
.find(token) ⇒ PinPayment::Transfer
Fetches a transfer using the pin API.
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from PinPayment::Base
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
4 5 6 |
# File 'lib/pin_payment/transfer.rb', line 4 def amount @amount end |
#currency ⇒ Object
Returns the value of attribute currency.
4 5 6 |
# File 'lib/pin_payment/transfer.rb', line 4 def currency @currency end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/pin_payment/transfer.rb', line 4 def description @description end |
#paid_at ⇒ Object
Returns the value of attribute paid_at.
4 5 6 |
# File 'lib/pin_payment/transfer.rb', line 4 def paid_at @paid_at end |
#recipient ⇒ Object
Returns the value of attribute recipient.
4 5 6 |
# File 'lib/pin_payment/transfer.rb', line 4 def recipient @recipient end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/pin_payment/transfer.rb', line 4 def status @status end |
#token ⇒ Object
Returns the value of attribute token.
4 5 6 |
# File 'lib/pin_payment/transfer.rb', line 4 def token @token end |
#total_credits ⇒ Object
Returns the value of attribute total_credits.
4 5 6 |
# File 'lib/pin_payment/transfer.rb', line 4 def total_credits @total_credits end |
#total_debits ⇒ Object
Returns the value of attribute total_debits.
4 5 6 |
# File 'lib/pin_payment/transfer.rb', line 4 def total_debits @total_debits end |
Class Method Details
.all ⇒ Array<PinPayment::Transfer>
Fetches all of your transfers using the pin API.
TODO: pagination
26 27 28 29 |
# 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) ⇒ PinPayment::Transfer
Uses the pin API to create a transfer.
15 16 17 18 19 20 |
# File 'lib/pin_payment/transfer.rb', line 15 def self.create transfer_data attributes = self.attributes - [:token] # fix attributes allowed by POST API = (attributes, transfer_data) response = post(URI.parse(PinPayment.api_url).tap{|uri| uri.path = '/1/transfers' }, ) new(response.delete('token'), response) end |
.find(token) ⇒ PinPayment::Transfer
Fetches a transfer using the pin API.
35 36 37 38 |
# 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 |
Instance Method Details
#line_items ⇒ Object
40 41 42 43 |
# 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 |