Class: PaypalServerSdk::OneTimeCharge

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/paypal_server_sdk/models/one_time_charge.rb

Overview

The one-time charge info at the time of checkout.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(total_amount:, setup_fee: SKIP, shipping_amount: SKIP, taxes: SKIP, product_price: SKIP, subtotal: SKIP) ⇒ OneTimeCharge



70
71
72
73
74
75
76
77
78
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 70

def initialize(total_amount:, setup_fee: SKIP, shipping_amount: SKIP,
               taxes: SKIP, product_price: SKIP, subtotal: SKIP)
  @setup_fee = setup_fee unless setup_fee == SKIP
  @shipping_amount = shipping_amount unless shipping_amount == SKIP
  @taxes = taxes unless taxes == SKIP
  @product_price = product_price unless product_price == SKIP
  @subtotal = subtotal unless subtotal == SKIP
  @total_amount = total_amount
end

Instance Attribute Details

#product_priceMoney

The currency and amount for a financial transaction, such as a balance or payment due.



30
31
32
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 30

def product_price
  @product_price
end

#setup_feeMoney

The currency and amount for a financial transaction, such as a balance or payment due.



15
16
17
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 15

def setup_fee
  @setup_fee
end

#shipping_amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.



20
21
22
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 20

def shipping_amount
  @shipping_amount
end

#subtotalMoney

The currency and amount for a financial transaction, such as a balance or payment due.



35
36
37
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 35

def subtotal
  @subtotal
end

#taxesMoney

The currency and amount for a financial transaction, such as a balance or payment due.



25
26
27
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 25

def taxes
  @taxes
end

#total_amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.



40
41
42
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 40

def total_amount
  @total_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  total_amount = Money.from_hash(hash['total_amount']) if hash['total_amount']
  setup_fee = Money.from_hash(hash['setup_fee']) if hash['setup_fee']
  shipping_amount = Money.from_hash(hash['shipping_amount']) if hash['shipping_amount']
  taxes = Money.from_hash(hash['taxes']) if hash['taxes']
  product_price = Money.from_hash(hash['product_price']) if hash['product_price']
  subtotal = Money.from_hash(hash['subtotal']) if hash['subtotal']

  # Create object from extracted values.
  OneTimeCharge.new(total_amount: total_amount,
                    setup_fee: setup_fee,
                    shipping_amount: shipping_amount,
                    taxes: taxes,
                    product_price: product_price,
                    subtotal: subtotal)
end

.namesObject

A mapping from model property names to API property names.



43
44
45
46
47
48
49
50
51
52
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 43

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['setup_fee'] = 'setup_fee'
  @_hash['shipping_amount'] = 'shipping_amount'
  @_hash['taxes'] = 'taxes'
  @_hash['product_price'] = 'product_price'
  @_hash['subtotal'] = 'subtotal'
  @_hash['total_amount'] = 'total_amount'
  @_hash
end

.nullablesObject

An array for nullable fields



66
67
68
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 66

def self.nullables
  []
end

.optionalsObject

An array for optional fields



55
56
57
58
59
60
61
62
63
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 55

def self.optionals
  %w[
    setup_fee
    shipping_amount
    taxes
    product_price
    subtotal
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



110
111
112
113
114
115
116
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 110

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} setup_fee: #{@setup_fee.inspect}, shipping_amount:"\
  " #{@shipping_amount.inspect}, taxes: #{@taxes.inspect}, product_price:"\
  " #{@product_price.inspect}, subtotal: #{@subtotal.inspect}, total_amount:"\
  " #{@total_amount.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



102
103
104
105
106
107
# File 'lib/paypal_server_sdk/models/one_time_charge.rb', line 102

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} setup_fee: #{@setup_fee}, shipping_amount: #{@shipping_amount}, taxes:"\
  " #{@taxes}, product_price: #{@product_price}, subtotal: #{@subtotal}, total_amount:"\
  " #{@total_amount}>"
end