Class: OnlinePayments::SDK::Domain::Transaction

Inherits:
OnlinePayments::SDK::DataObject show all
Defined in:
lib/onlinepayments/sdk/domain/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OnlinePayments::SDK::DataObject

new_from_hash

Instance Attribute Details

#amountOnlinePayments::SDK::Domain::AmountOfMoney

Returns the current value of amount.

Returns:



11
12
13
# File 'lib/onlinepayments/sdk/domain/transaction.rb', line 11

def amount
  @amount
end

Instance Method Details

#from_hash(hash) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/onlinepayments/sdk/domain/transaction.rb', line 21

def from_hash(hash)
  super
  if hash.key? 'amount'
    raise TypeError, "value '%s' is not a Hash" % [hash['amount']] unless hash['amount'].is_a? Hash
    @amount = OnlinePayments::SDK::Domain::AmountOfMoney.new_from_hash(hash['amount'])
  end
end

#to_hHash

Returns:

  • (Hash)


15
16
17
18
19
# File 'lib/onlinepayments/sdk/domain/transaction.rb', line 15

def to_h
  hash = super
  hash['amount'] = @amount.to_h if @amount
  hash
end