Class: Tinker::Model::Dto::CallbackDataDto

Inherits:
Object
  • Object
show all
Defined in:
lib/tinker/model/dto/callback_data_dto.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ CallbackDataDto

Returns a new instance of CallbackDataDto.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tinker/model/dto/callback_data_dto.rb', line 9

def initialize(data)
  @id = data['id']
  status_value = data['status'] || 'pending'
  @status = begin
    Tinker::Enum::PaymentStatus.const_get(status_value.upcase)
  rescue NameError
    Tinker::Enum::PaymentStatus::PENDING
  end
  @reference = data['reference']
  @amount = data['amount'].to_f
  @currency = data['currency']
  @paid_at = data['paid_at']
  @created_at = data['created_at']
  @channel = data['channel']
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



7
8
9
# File 'lib/tinker/model/dto/callback_data_dto.rb', line 7

def amount
  @amount
end

#channelObject (readonly)

Returns the value of attribute channel.



7
8
9
# File 'lib/tinker/model/dto/callback_data_dto.rb', line 7

def channel
  @channel
end

#created_atObject (readonly)

Returns the value of attribute created_at.



7
8
9
# File 'lib/tinker/model/dto/callback_data_dto.rb', line 7

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



7
8
9
# File 'lib/tinker/model/dto/callback_data_dto.rb', line 7

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/tinker/model/dto/callback_data_dto.rb', line 7

def id
  @id
end

Returns the value of attribute paid_at.



7
8
9
# File 'lib/tinker/model/dto/callback_data_dto.rb', line 7

def paid_at
  @paid_at
end

#referenceObject (readonly)

Returns the value of attribute reference.



7
8
9
# File 'lib/tinker/model/dto/callback_data_dto.rb', line 7

def reference
  @reference
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/tinker/model/dto/callback_data_dto.rb', line 7

def status
  @status
end

Instance Method Details

#to_hashObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/tinker/model/dto/callback_data_dto.rb', line 25

def to_hash
  {
    id: @id,
    status: @status,
    reference: @reference,
    amount: @amount,
    currency: @currency,
    paid_at: @paid_at,
    created_at: @created_at,
    channel: @channel
  }
end