Class: PinPayment::BankAccount

Inherits:
Base
  • Object
show all
Defined in:
lib/pin_payment/bank_account.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from PinPayment::Base

Instance Attribute Details

#bank_nameObject

Returns the value of attribute bank_name.



4
5
6
# File 'lib/pin_payment/bank_account.rb', line 4

def bank_name
  @bank_name
end

#bsbObject

Returns the value of attribute bsb.



4
5
6
# File 'lib/pin_payment/bank_account.rb', line 4

def bsb
  @bsb
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/pin_payment/bank_account.rb', line 4

def name
  @name
end

#numberObject

Returns the value of attribute number.



4
5
6
# File 'lib/pin_payment/bank_account.rb', line 4

def number
  @number
end

#tokenObject

Returns the value of attribute token.



4
5
6
# File 'lib/pin_payment/bank_account.rb', line 4

def token
  @token
end

Class Method Details

.create(bank_account_data) ⇒ PinPayment::BankAccount

Uses the pin API to create a bank account.

Parameters:

  • bank_account_data (Hash)

Options Hash (bank_account_data):

  • :name (String)

    required

  • :bsb (String)

    required

  • :number (String)

    required

Returns:



14
15
16
17
18
19
# File 'lib/pin_payment/bank_account.rb', line 14

def self.create 
  attributes = self.attributes - [:token,:bank_name] # fix attributes allowed by POST API
  options    = parse_options_for_request(attributes, )
  response   = post(URI.parse(PinPayment.api_url).tap{|uri| uri.path = '/1/bank_accounts' }, options)
  new(response.delete('token'), response)
end

Instance Method Details

#to_hashHash

Returns:

  • (Hash)


23
24
25
# File 'lib/pin_payment/bank_account.rb', line 23

def to_hash
  {}.tap{|h| self.class.attributes.each{|k| v = send(k) ; h[k] = v if v }}
end