Class: Fintoc::V2::AccountNumber

Inherits:
Object
  • Object
show all
Defined in:
lib/fintoc/v2/resources/account_number.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 = 
  @metadata = 
  @last_transfer_at = last_transfer_at
  @deleted_at = deleted_at
  @client = client
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



4
5
6
# File 'lib/fintoc/v2/resources/account_number.rb', line 4

def 
  @account_id
end

#created_atObject (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_atObject (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

#descriptionObject (readonly)

Returns the value of attribute description.



4
5
6
# File 'lib/fintoc/v2/resources/account_number.rb', line 4

def description
  @description
end

#idObject (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_rootObject (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_atObject (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

#metadataObject (readonly)

Returns the value of attribute metadata.



4
5
6
# File 'lib/fintoc/v2/resources/account_number.rb', line 4

def 
  @metadata
end

#modeObject (readonly)

Returns the value of attribute mode.



4
5
6
# File 'lib/fintoc/v2/resources/account_number.rb', line 4

def mode
  @mode
end

#numberObject (readonly)

Returns the value of attribute number.



4
5
6
# File 'lib/fintoc/v2/resources/account_number.rb', line 4

def number
  @number
end

#objectObject (readonly)

Returns the value of attribute object.



4
5
6
# File 'lib/fintoc/v2/resources/account_number.rb', line 4

def object
  @object
end

#statusObject (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_atObject (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

Returns:

  • (Boolean)


64
65
66
# File 'lib/fintoc/v2/resources/account_number.rb', line 64

def disabled?
  @status == 'disabled'
end

#enabled?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/fintoc/v2/resources/account_number.rb', line 60

def enabled?
  @status == 'enabled'
end

#refreshObject



45
46
47
48
# File 'lib/fintoc/v2/resources/account_number.rb', line 45

def refresh
   = @client..get(@id)
  ()
end

#root?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


72
73
74
# File 'lib/fintoc/v2/resources/account_number.rb', line 72

def test_mode?
  @mode == 'test'
end

#to_sObject



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 

   = @client..update(@id, idempotency_key:, **params)
  ()
end