Class: Bs2Api::Entities::Bank
- Inherits:
-
Object
- Object
- Bs2Api::Entities::Bank
- Defined in:
- lib/bs2_api/entities/bank.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#ispb ⇒ Object
Returns the value of attribute ispb.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Bank
constructor
A new instance of Bank.
- #to_hash ⇒ Object
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
#account ⇒ Object
Returns the value of attribute account.
6 7 8 |
# File 'lib/bs2_api/entities/bank.rb', line 6 def account @account end |
#customer ⇒ Object
Returns the value of attribute customer.
6 7 8 |
# File 'lib/bs2_api/entities/bank.rb', line 6 def customer @customer end |
#ispb ⇒ Object
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_hash ⇒ Object
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 |