Class: Fintoc::V2::Transfer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, object:, amount:, currency:, status:, mode:, counterparty:, direction: nil, post_date: nil, transaction_date: nil, comment: nil, reference_id: nil, receipt_url: nil, tracking_key: nil, return_reason: nil, account_number: nil, metadata: {}, created_at: nil, client: nil) ⇒ Transfer

rubocop:disable Metrics/MethodLength



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
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fintoc/v2/resources/transfer.rb', line 11

def initialize( # rubocop:disable Metrics/MethodLength
  id:,
  object:,
  amount:,
  currency:,
  status:,
  mode:,
  counterparty:,
  direction: nil,
  post_date: nil,
  transaction_date: nil,
  comment: nil,
  reference_id: nil,
  receipt_url: nil,
  tracking_key: nil,
  return_reason: nil,
  account_number: nil,
  metadata: {},
  created_at: nil,
  client: nil,
  **
)
  @id = id
  @object = object
  @amount = amount
  @currency = currency
  @direction = direction
  @status = status
  @mode = mode
  @post_date = 
  @transaction_date = transaction_date
  @comment = comment
  @reference_id = reference_id
  @receipt_url = receipt_url
  @tracking_key = tracking_key
  @return_reason = return_reason
  @counterparty = counterparty
  @account_number = 
   =  || {}
  @created_at = created_at
  @client = client
end

Instance Attribute Details

#account_numberObject (readonly)

Returns the value of attribute account_number.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def 
  @account_number
end

#amountObject (readonly)

Returns the value of attribute amount.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def amount
  @amount
end

#commentObject (readonly)

Returns the value of attribute comment.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def comment
  @comment
end

#counterpartyObject (readonly)

Returns the value of attribute counterparty.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def counterparty
  @counterparty
end

#created_atObject (readonly)

Returns the value of attribute created_at.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def currency
  @currency
end

#directionObject (readonly)

Returns the value of attribute direction.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def direction
  @direction
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def 
  
end

#modeObject (readonly)

Returns the value of attribute mode.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def mode
  @mode
end

#objectObject (readonly)

Returns the value of attribute object.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def object
  @object
end

#post_dateObject (readonly)

Returns the value of attribute post_date.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def 
  @post_date
end

#receipt_urlObject (readonly)

Returns the value of attribute receipt_url.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def receipt_url
  @receipt_url
end

#reference_idObject (readonly)

Returns the value of attribute reference_id.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def reference_id
  @reference_id
end

#return_reasonObject (readonly)

Returns the value of attribute return_reason.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def return_reason
  @return_reason
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def status
  @status
end

#tracking_keyObject (readonly)

Returns the value of attribute tracking_key.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def tracking_key
  @tracking_key
end

#transaction_dateObject (readonly)

Returns the value of attribute transaction_date.



6
7
8
# File 'lib/fintoc/v2/resources/transfer.rb', line 6

def transaction_date
  @transaction_date
end

Instance Method Details

#failed?Boolean



78
79
80
# File 'lib/fintoc/v2/resources/transfer.rb', line 78

def failed?
  @status == 'failed'
end

#inbound?Boolean



94
95
96
# File 'lib/fintoc/v2/resources/transfer.rb', line 94

def inbound?
  @direction == 'inbound'
end

#outbound?Boolean



98
99
100
# File 'lib/fintoc/v2/resources/transfer.rb', line 98

def outbound?
  @direction == 'outbound'
end

#pending?Boolean



70
71
72
# File 'lib/fintoc/v2/resources/transfer.rb', line 70

def pending?
  @status == 'pending'
end

#refreshObject



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

def refresh
  fresh_transfer = @client.transfers.get(@id)
  refresh_from_transfer(fresh_transfer)
end

#rejected?Boolean



90
91
92
# File 'lib/fintoc/v2/resources/transfer.rb', line 90

def rejected?
  @status == 'rejected'
end

#return_pending?Boolean



86
87
88
# File 'lib/fintoc/v2/resources/transfer.rb', line 86

def return_pending?
  @status == 'return_pending'
end

#return_transfer(idempotency_key: nil) ⇒ Object



65
66
67
68
# File 'lib/fintoc/v2/resources/transfer.rb', line 65

def return_transfer(idempotency_key: nil)
  returned_transfer = @client.transfers.return(@id, idempotency_key:)
  refresh_from_transfer(returned_transfer)
end

#returned?Boolean



82
83
84
# File 'lib/fintoc/v2/resources/transfer.rb', line 82

def returned?
  @status == 'returned'
end

#succeeded?Boolean



74
75
76
# File 'lib/fintoc/v2/resources/transfer.rb', line 74

def succeeded?
  @status == 'succeeded'
end

#to_sObject



54
55
56
57
58
# File 'lib/fintoc/v2/resources/transfer.rb', line 54

def to_s
  amount_str = Money.from_cents(@amount, @currency).format
  direction_icon = inbound? ? '⬇️' : '⬆️'
  "#{direction_icon} #{amount_str} (#{@id}) - #{@status}"
end