Class: Pluggy::Resources::Transaction
Constant Summary
Constants inherited
from PluggyObject
PluggyObject::ISO8601, PluggyObject::RESERVED, PluggyObject::TEMPORAL_KEYS
Instance Attribute Summary
Attributes inherited from PluggyObject
#client
Instance Method Summary
collapse
#==, #[], #as_json, declared_fields, define_field, #each_pair, fields, #hash, #initialize, #inspect, #key?, #keys, #method_missing, nested, nested_types, #read, #respond_to_missing?, #to_h, #to_json, #values
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Pluggy::PluggyObject
Instance Method Details
#account ⇒ Object
100
|
# File 'lib/pluggy/resources/transaction.rb', line 100
def account = ensure_client!.accounts.retrieve(self["accountId"])
|
#bill ⇒ Object
81
82
83
84
|
# File 'lib/pluggy/resources/transaction.rb', line 81
def bill
id = bill_id
id && ensure_client!.bills.retrieve(id)
end
|
#bill_id ⇒ Object
The bill this transaction belongs to. Since GET /v2/transactions dropped
the billId filter, this is the authoritative way to group card
transactions into statements.
79
|
# File 'lib/pluggy/resources/transaction.rb', line 79
def bill_id = credit_card_metadata&.[]("billId")
|
#boleto? ⇒ Boolean
88
|
# File 'lib/pluggy/resources/transaction.rb', line 88
def boleto? = payment_method == "BOLETO"
|
#counterparty ⇒ Object
Whoever was on the other side: the receiver of an outflow, the payer of
an inflow.
93
94
95
96
97
98
|
# File 'lib/pluggy/resources/transaction.rb', line 93
def counterparty
data = payment_data
return nil unless data
debit? ? data.receiver : data.payer
end
|
#credit? ⇒ Boolean
Also known as:
inflow?
57
|
# File 'lib/pluggy/resources/transaction.rb', line 57
def credit? = self["type"] == "CREDIT"
|
#credit_card? ⇒ Boolean
66
|
# File 'lib/pluggy/resources/transaction.rb', line 66
def credit_card? = !self["creditCardMetadata"].nil?
|
#debit? ⇒ Boolean
Also known as:
outflow?
Direction, from the account holder's point of view. Pluggy normalizes
the credit-card convention, so a card purchase is always DEBIT and a
payment towards the statement is always CREDIT.
56
|
# File 'lib/pluggy/resources/transaction.rb', line 56
def debit? = self["type"] == "DEBIT"
|
#installment? ⇒ Boolean
68
|
# File 'lib/pluggy/resources/transaction.rb', line 68
def installment? = credit_card_metadata&.installment? || false
|
#installment_label ⇒ Object
70
71
72
73
74
|
# File 'lib/pluggy/resources/transaction.rb', line 70
def installment_label
return nil unless installment?
"#{credit_card_metadata["installmentNumber"]}/#{credit_card_metadata["totalInstallments"]}"
end
|
#payment_method ⇒ Object
86
|
# File 'lib/pluggy/resources/transaction.rb', line 86
def payment_method = payment_data&.[]("paymentMethod")
|
#pending? ⇒ Boolean
Typical of card purchases not yet on a closed bill.
64
|
# File 'lib/pluggy/resources/transaction.rb', line 64
def pending? = self["status"] == "PENDING"
|
#pix? ⇒ Boolean
87
|
# File 'lib/pluggy/resources/transaction.rb', line 87
def pix? = payment_method == "PIX"
|
#posted? ⇒ Boolean
61
|
# File 'lib/pluggy/resources/transaction.rb', line 61
def posted? = self["status"] == "POSTED"
|
#recategorize(category_id) ⇒ Object
PATCH /transactions/id -- the only field Pluggy lets you change.
103
104
105
|
# File 'lib/pluggy/resources/transaction.rb', line 103
def recategorize(category_id)
ensure_client!.transactions.update(self["id"], category_id: category_id)
end
|
#transfer? ⇒ Boolean
89
|
# File 'lib/pluggy/resources/transaction.rb', line 89
def transfer? = %w[TED DOC TEV].include?(payment_method)
|