Sha256: 34ee4613800580379cd4a9b6e9fc48a4bd462faa7cfdf4a074a9e1badce5b21e

Contents?: true

Size: 1.43 KB

Versions: 7

Compression:

Stored size: 1.43 KB

Contents

require 'plaid/util'
module Plaid
  class Account
    include Plaid::Util
    # Define vars for user accounts
    attr_accessor(:available_balance, :current_balance, :institution_type, :meta, :transactions, :numbers, :name, :id, :type)

    # Instantiate a new account with the results of the successful API call
    # Build an array of nested transactions, and return self if successful
    def new(res)
      begin
        self.name = res['name'], self.available_balance = res['balance']['available'], self.current_balance = res['balance']['current'], self.institution_type = res['institution_type'], self.id = res['_id'], self.type = res['type']
        self.meta = res['meta'] if res['meta']
        res['numbers'] ? self.numbers = res['numbers'] : self.numbers = 'Upgrade user to access routing information for this account'
      rescue => e
        error_handler(e)
      else
        self
      end
    end

    def update_account(res)
      begin
        self.name = res['name'], self.available_balance = res['balance']['available'], self.current_balance = res['balance']['current'], self.institution_type = res['institution_type'], self.id = res['_id'], self.type = res['type']
        self.meta = res['meta'] if res['meta']
        res['numbers'] ? self.numbers = res['numbers'] : self.numbers = 'Upgrade user to access routing information for this account'
      rescue => e
        error_handler(e)
      else
        self
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
plaid-1.4.3 lib/plaid/user/account/account.rb
plaid-1.4.2 lib/plaid/user/account/account.rb
plaid-1.4.1 lib/plaid/user/account/account.rb
plaid-1.4.0 lib/plaid/user/account/account.rb
plaid-1.3.0 lib/plaid/user/account/account.rb
plaid-1.2.3 lib/plaid/user/account/account.rb
plaid-1.2.2 lib/plaid/user/account/account.rb