Class: Bs2Api::Entities::Account
- Inherits:
-
Object
- Object
- Bs2Api::Entities::Account
- Defined in:
- lib/bs2_api/entities/account.rb
Constant Summary collapse
- TYPES =
{ checking: 'ContaCorrente', salary: 'ContaSalario', saving: 'Poupanca' }
Instance Attribute Summary collapse
-
#agency ⇒ Object
Returns the value of attribute agency.
-
#bank_code ⇒ Object
Returns the value of attribute bank_code.
-
#bank_name ⇒ Object
Returns the value of attribute bank_name.
-
#number ⇒ Object
Returns the value of attribute number.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #checking? ⇒ Boolean
-
#initialize(args = {}) ⇒ Account
constructor
A new instance of Account.
- #salary? ⇒ Boolean
- #saving? ⇒ Boolean
- #to_hash ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Account
Returns a new instance of Account.
14 15 16 17 18 19 20 |
# File 'lib/bs2_api/entities/account.rb', line 14 def initialize(args = {}) @bank_code = args.fetch(:bank_code, nil) @bank_name = args.fetch(:bank_name, nil) @agency = args.fetch(:agency, nil) @number = args.fetch(:number, nil) @type = args.fetch(:type, nil) end |
Instance Attribute Details
#agency ⇒ Object
Returns the value of attribute agency.
6 7 8 |
# File 'lib/bs2_api/entities/account.rb', line 6 def agency @agency end |
#bank_code ⇒ Object
Returns the value of attribute bank_code.
6 7 8 |
# File 'lib/bs2_api/entities/account.rb', line 6 def bank_code @bank_code end |
#bank_name ⇒ Object
Returns the value of attribute bank_name.
6 7 8 |
# File 'lib/bs2_api/entities/account.rb', line 6 def bank_name @bank_name end |
#number ⇒ Object
Returns the value of attribute number.
6 7 8 |
# File 'lib/bs2_api/entities/account.rb', line 6 def number @number end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/bs2_api/entities/account.rb', line 6 def type @type end |
Class Method Details
.from_response(hash_payload) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bs2_api/entities/account.rb', line 34 def self.from_response(hash_payload) hash = ActiveSupport::HashWithIndifferentAccess.new(hash_payload) Bs2Api::Entities::Account.new( bank_code: hash["banco"], bank_name: hash["bancoNome"], agency: hash["agencia"], number: hash["numero"], type: hash["tipo"] ) end |
Instance Method Details
#checking? ⇒ Boolean
46 47 48 |
# File 'lib/bs2_api/entities/account.rb', line 46 def checking? @type == TYPES[:checking] end |
#salary? ⇒ Boolean
50 51 52 |
# File 'lib/bs2_api/entities/account.rb', line 50 def salary? @type == TYPES[:salary] end |
#saving? ⇒ Boolean
54 55 56 |
# File 'lib/bs2_api/entities/account.rb', line 54 def saving? @type == TYPES[:saving] end |
#to_hash ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bs2_api/entities/account.rb', line 22 def to_hash ActiveSupport::HashWithIndifferentAccess.new( { "banco": @bank_code, "bancoNome": @bank_name, "agencia": @agency, "numero": @number, "tipo": @type } ) end |