Class: Pluggy::Resources::Account

Inherits:
APIResource show all
Defined in:
lib/pluggy/resources/account.rb

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

Methods inherited from PluggyObject

#==, #[], #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

Constructor Details

This class inherits a constructor from Pluggy::PluggyObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Pluggy::PluggyObject

Instance Method Details

#bank?Boolean

Returns:

  • (Boolean)


51
# File 'lib/pluggy/resources/account.rb', line 51

def bank? = self["type"] == "BANK"

#bills(**filters) ⇒ Object

Credit-card statements. Only CREDIT accounts have them, so say so clearly rather than returning a confusing empty list.



63
64
65
66
67
68
69
70
71
# File 'lib/pluggy/resources/account.rb', line 63

def bills(**filters)
  unless credit?
    raise Error,
      "account #{self["id"]} has type #{self["type"].inspect}, not \"CREDIT\"; " \
      "bills exist only for credit-card accounts"
  end

  ensure_client!.bills.list(account_id: self["id"], **filters)
end

#checking?Boolean

Returns:

  • (Boolean)


54
# File 'lib/pluggy/resources/account.rb', line 54

def checking? = self["subtype"] == "CHECKING_ACCOUNT"

#credit?Boolean

Returns:

  • (Boolean)


52
# File 'lib/pluggy/resources/account.rb', line 52

def credit? = self["type"] == "CREDIT"

#credit_card?Boolean

Returns:

  • (Boolean)


53
# File 'lib/pluggy/resources/account.rb', line 53

def credit_card? = self["subtype"] == "CREDIT_CARD"

#itemObject



79
# File 'lib/pluggy/resources/account.rb', line 79

def item = ensure_client!.items.retrieve(self["itemId"])

#live_balanceObject

GET /accounts/id/balance -- fetched live from the institution rather than from the last sync, so it is slower and can 429 or 502.



75
# File 'lib/pluggy/resources/account.rb', line 75

def live_balance = ensure_client!.accounts.balance(self["id"])

#refreshObject



81
# File 'lib/pluggy/resources/account.rb', line 81

def refresh = ensure_client!.accounts.retrieve(self["id"])

#savings?Boolean

Returns:

  • (Boolean)


55
# File 'lib/pluggy/resources/account.rb', line 55

def savings? = self["subtype"] == "SAVINGS_ACCOUNT"

#statementsObject



77
# File 'lib/pluggy/resources/account.rb', line 77

def statements = ensure_client!.accounts.statements(self["id"])

#transactions(**filters) ⇒ Object



57
58
59
# File 'lib/pluggy/resources/account.rb', line 57

def transactions(**filters)
  ensure_client!.transactions.list(account_id: self["id"], **filters)
end