Class: Bs2Api::Entities::Bank

Inherits:
Object
  • Object
show all
Defined in:
lib/bs2_api/entities/bank.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Bank

Returns a new instance of Bank.



8
9
10
11
12
# File 'lib/bs2_api/entities/bank.rb', line 8

def initialize(args = {})
  @ispb     = args.fetch(:ispb, nil)
  @account  = args.fetch(:account, nil)
  @customer = args.fetch(:customer, nil)
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



6
7
8
# File 'lib/bs2_api/entities/bank.rb', line 6

def 
  @account
end

#customerObject

Returns the value of attribute customer.



6
7
8
# File 'lib/bs2_api/entities/bank.rb', line 6

def customer
  @customer
end

#ispbObject

Returns the value of attribute ispb.



6
7
8
# File 'lib/bs2_api/entities/bank.rb', line 6

def ispb
  @ispb
end

Class Method Details

.from_response(hash_payload) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/bs2_api/entities/bank.rb', line 24

def self.from_response(hash_payload)
  return if hash_payload.blank?
  hash = ActiveSupport::HashWithIndifferentAccess.new(hash_payload)

  Bs2Api::Entities::Bank.new(
    ispb: hash["ispb"],
    account: Bs2Api::Entities::Account.from_response(hash["conta"]),
    customer: Bs2Api::Entities::Customer.from_response(hash["pessoa"])
  )
end

Instance Method Details

#to_hashObject



14
15
16
17
18
19
20
21
22
# File 'lib/bs2_api/entities/bank.rb', line 14

def to_hash
  ActiveSupport::HashWithIndifferentAccess.new(
    {
      "ispb": @ispb,
      "conta": @account.to_hash,
      "pessoa": @customer.to_hash
    }
  )
end