Class: Fintoc::V2::AccountNumber
- Inherits:
-
Object
- Object
- Fintoc::V2::AccountNumber
- Defined in:
- lib/fintoc/v2/resources/account_number.rb
Instance Attribute Summary collapse
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_root ⇒ Object
readonly
Returns the value of attribute is_root.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #disabled? ⇒ Boolean
- #enabled? ⇒ Boolean
-
#initialize(id:, object:, description:, number:, created_at:, updated_at:, mode:, status:, is_root:, account_id:, metadata:, client: nil) ⇒ AccountNumber
constructor
A new instance of AccountNumber.
- #refresh ⇒ Object
- #root? ⇒ Boolean
- #simulate_receive_transfer(amount:, currency: 'MXN') ⇒ Object
- #test_mode? ⇒ Boolean
- #to_s ⇒ Object
- #update(description: nil, status: nil, metadata: nil) ⇒ Object
Constructor Details
#initialize(id:, object:, description:, number:, created_at:, updated_at:, mode:, status:, is_root:, account_id:, metadata:, client: nil) ⇒ AccountNumber
Returns a new instance of AccountNumber.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 7 def initialize( id:, object:, description:, number:, created_at:, updated_at:, mode:, status:, is_root:, account_id:, metadata:, client: nil, ** ) @id = id @object = object @description = description @number = number @created_at = created_at @updated_at = updated_at @mode = mode @status = status @is_root = is_root @account_id = account_id @metadata = @client = client end |
Instance Attribute Details
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def account_id @account_id end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def id @id end |
#is_root ⇒ Object (readonly)
Returns the value of attribute is_root.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def is_root @is_root end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def @metadata end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def mode @mode end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def number @number end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def object @object end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def status @status end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def updated_at @updated_at end |
Instance Method Details
#disabled? ⇒ Boolean
59 60 61 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 59 def disabled? @status == 'disabled' end |
#enabled? ⇒ Boolean
55 56 57 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 55 def enabled? @status == 'enabled' end |
#refresh ⇒ Object
40 41 42 43 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 40 def refresh fresh_account_number = @client.account_numbers.get(@id) refresh_from_account_number(fresh_account_number) end |
#root? ⇒ Boolean
63 64 65 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 63 def root? @is_root end |
#simulate_receive_transfer(amount:, currency: 'MXN') ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 71 def simulate_receive_transfer(amount:, currency: 'MXN') unless test_mode? raise Fintoc::Errors::InvalidRequestError, 'Simulation is only available in test mode' end @client.simulate.receive_transfer( account_number_id: @id, amount:, currency: ) end |
#test_mode? ⇒ Boolean
67 68 69 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 67 def test_mode? @mode == 'test' end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 36 def to_s "🔢 #{@number} (#{@id}) - #{@description}" end |
#update(description: nil, status: nil, metadata: nil) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 45 def update(description: nil, status: nil, metadata: nil) params = {} params[:description] = description if description params[:status] = status if status params[:metadata] = if updated_account_number = @client.account_numbers.update(@id, **params) refresh_from_account_number(updated_account_number) end |