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:, 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 = 
  @metadata = 
  @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

#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

#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)


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

def disabled?
  @status == 'disabled'
end

#enabled?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/fintoc/v2/resources/account_number.rb', line 55

def enabled?
  @status == 'enabled'
end

#refreshObject



40
41
42
43
# File 'lib/fintoc/v2/resources/account_number.rb', line 40

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

#root?Boolean

Returns:

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

Returns:

  • (Boolean)


67
68
69
# File 'lib/fintoc/v2/resources/account_number.rb', line 67

def test_mode?
  @mode == 'test'
end

#to_sObject



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 

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