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.
-
#deleted_at ⇒ Object
readonly
Returns the value of attribute deleted_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.
-
#last_transfer_at ⇒ Object
readonly
Returns the value of attribute last_transfer_at.
-
#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:, last_transfer_at: nil, deleted_at: nil, client: nil) ⇒ AccountNumber
constructor
A new instance of AccountNumber.
- #refresh ⇒ Object
- #root? ⇒ Boolean
- #simulate_receive_transfer(amount:, currency: 'MXN', idempotency_key: nil) ⇒ Object
- #test_mode? ⇒ Boolean
- #to_s ⇒ Object
- #update(description: nil, status: nil, metadata: nil, idempotency_key: nil) ⇒ Object
Constructor Details
#initialize(id:, object:, description:, number:, created_at:, updated_at:, mode:, status:, is_root:, account_id:, metadata:, last_transfer_at: nil, deleted_at: nil, client: nil) ⇒ AccountNumber
Returns a new instance of AccountNumber.
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 35 36 37 38 39 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 8 def initialize( id:, object:, description:, number:, created_at:, updated_at:, mode:, status:, is_root:, account_id:, metadata:, last_transfer_at: nil, deleted_at: nil, 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 = @last_transfer_at = last_transfer_at @deleted_at = deleted_at @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 |
#deleted_at ⇒ Object (readonly)
Returns the value of attribute deleted_at.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def deleted_at @deleted_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 |
#last_transfer_at ⇒ Object (readonly)
Returns the value of attribute last_transfer_at.
4 5 6 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 4 def last_transfer_at @last_transfer_at 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
64 65 66 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 64 def disabled? @status == 'disabled' end |
#enabled? ⇒ Boolean
60 61 62 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 60 def enabled? @status == 'enabled' end |
#refresh ⇒ Object
45 46 47 48 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 45 def refresh fresh_account_number = @client.account_numbers.get(@id) refresh_from_account_number(fresh_account_number) end |
#root? ⇒ Boolean
68 69 70 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 68 def root? @is_root end |
#simulate_receive_transfer(amount:, currency: 'MXN', idempotency_key: nil) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 76 def simulate_receive_transfer(amount:, currency: 'MXN', idempotency_key: nil) 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:, idempotency_key: ) end |
#test_mode? ⇒ Boolean
72 73 74 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 72 def test_mode? @mode == 'test' end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 41 def to_s "🔢 #{@number} (#{@id}) - #{@description}" end |
#update(description: nil, status: nil, metadata: nil, idempotency_key: nil) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/fintoc/v2/resources/account_number.rb', line 50 def update(description: nil, status: nil, metadata: nil, idempotency_key: nil) params = {} params[:description] = description if description params[:status] = status if status params[:metadata] = if updated_account_number = @client.account_numbers.update(@id, idempotency_key:, **params) refresh_from_account_number(updated_account_number) end |