Class: OnlinePayments::SDK::Domain::Surcharge

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OnlinePayments::SDK::DataObject

new_from_hash

Instance Attribute Details

#net_amountOnlinePayments::SDK::Domain::AmountOfMoney

Returns the current value of net_amount.

Returns:



17
18
19
# File 'lib/onlinepayments/sdk/domain/surcharge.rb', line 17

def net_amount
  @net_amount
end

#payment_product_idInteger

Returns the current value of payment_product_id.

Returns:

  • (Integer)

    the current value of payment_product_id



17
18
19
# File 'lib/onlinepayments/sdk/domain/surcharge.rb', line 17

def payment_product_id
  @payment_product_id
end

#resultString

Returns the current value of result.

Returns:

  • (String)

    the current value of result



17
18
19
# File 'lib/onlinepayments/sdk/domain/surcharge.rb', line 17

def result
  @result
end

#surcharge_amountOnlinePayments::SDK::Domain::AmountOfMoney

Returns the current value of surcharge_amount.

Returns:



17
18
19
# File 'lib/onlinepayments/sdk/domain/surcharge.rb', line 17

def surcharge_amount
  @surcharge_amount
end

#surcharge_rateOnlinePayments::SDK::Domain::SurchargeRate

Returns the current value of surcharge_rate.

Returns:



17
18
19
# File 'lib/onlinepayments/sdk/domain/surcharge.rb', line 17

def surcharge_rate
  @surcharge_rate
end

#total_amountOnlinePayments::SDK::Domain::AmountOfMoney

Returns the current value of total_amount.

Returns:



17
18
19
# File 'lib/onlinepayments/sdk/domain/surcharge.rb', line 17

def total_amount
  @total_amount
end

Instance Method Details

#from_hash(hash) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/onlinepayments/sdk/domain/surcharge.rb', line 37

def from_hash(hash)
  super
  if hash.key? 'netAmount'
    raise TypeError, "value '%s' is not a Hash" % [hash['netAmount']] unless hash['netAmount'].is_a? Hash
    @net_amount = OnlinePayments::SDK::Domain::AmountOfMoney.new_from_hash(hash['netAmount'])
  end
  @payment_product_id = hash['paymentProductId'] if hash.key? 'paymentProductId'
  @result = hash['result'] if hash.key? 'result'
  if hash.key? 'surchargeAmount'
    raise TypeError, "value '%s' is not a Hash" % [hash['surchargeAmount']] unless hash['surchargeAmount'].is_a? Hash
    @surcharge_amount = OnlinePayments::SDK::Domain::AmountOfMoney.new_from_hash(hash['surchargeAmount'])
  end
  if hash.key? 'surchargeRate'
    raise TypeError, "value '%s' is not a Hash" % [hash['surchargeRate']] unless hash['surchargeRate'].is_a? Hash
    @surcharge_rate = OnlinePayments::SDK::Domain::SurchargeRate.new_from_hash(hash['surchargeRate'])
  end
  if hash.key? 'totalAmount'
    raise TypeError, "value '%s' is not a Hash" % [hash['totalAmount']] unless hash['totalAmount'].is_a? Hash
    @total_amount = OnlinePayments::SDK::Domain::AmountOfMoney.new_from_hash(hash['totalAmount'])
  end
end

#to_hHash

Returns:

  • (Hash)


26
27
28
29
30
31
32
33
34
35
# File 'lib/onlinepayments/sdk/domain/surcharge.rb', line 26

def to_h
  hash = super
  hash['netAmount'] = @net_amount.to_h if @net_amount
  hash['paymentProductId'] = @payment_product_id unless @payment_product_id.nil?
  hash['result'] = @result unless @result.nil?
  hash['surchargeAmount'] = @surcharge_amount.to_h if @surcharge_amount
  hash['surchargeRate'] = @surcharge_rate.to_h if @surcharge_rate
  hash['totalAmount'] = @total_amount.to_h if @total_amount
  hash
end