Class: PaypalServerSdk::ShippingOptionsPurchaseUnit

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

Overview

This would contain shipping option and amount data at purchase unit level.

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(reference_id: SKIP, amount: SKIP, shipping_options: SKIP) ⇒ ShippingOptionsPurchaseUnit

Returns a new instance of ShippingOptionsPurchaseUnit.



58
59
60
61
62
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 58

def initialize(reference_id: SKIP, amount: SKIP, shipping_options: SKIP)
  @reference_id = reference_id unless reference_id == SKIP
  @amount = amount unless amount == SKIP
  @shipping_options = shipping_options unless shipping_options == SKIP
end

Instance Attribute Details

#amountAmountWithBreakdown

The total order amount with an optional breakdown that provides details, such as the total item amount, total tax amount, shipping, handling, insurance, and discounts, if any. If you specify amount.breakdown, the amount equals item_total plus tax_total plus shipping plus handling plus insurance minus shipping_discount minus discount. The amount must be a positive number. For listed of supported currencies and decimal precision, see the PayPal REST APIs Currency Codes.

Returns:



28
29
30
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 28

def amount
  @amount
end

#reference_idString

The API caller-provided external ID for the purchase unit. Required for multiple purchase units when you must update the order through PATCH. If you omit this value and the order contains only one purchase unit, PayPal sets this value to default. Note: If there are multiple purchase units, reference_id is required for each purchase unit.

Returns:

  • (String)


18
19
20
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 18

def reference_id
  @reference_id
end

#shipping_optionsArray[ShippingOption]

An array of shipping options that the payee or merchant offers to the payer to ship or pick up their items.

Returns:



33
34
35
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 33

def shipping_options
  @shipping_options
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 65

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  reference_id = hash.key?('reference_id') ? hash['reference_id'] : SKIP
  amount = AmountWithBreakdown.from_hash(hash['amount']) if hash['amount']
  # Parameter is an array, so we need to iterate through it

  shipping_options = nil
  unless hash['shipping_options'].nil?
    shipping_options = []
    hash['shipping_options'].each do |structure|
      shipping_options << (ShippingOption.from_hash(structure) if structure)
    end
  end

  shipping_options = SKIP unless hash.key?('shipping_options')

  # Create object from extracted values.

  ShippingOptionsPurchaseUnit.new(reference_id: reference_id,
                                  amount: amount,
                                  shipping_options: shipping_options)
end

.namesObject

A mapping from model property names to API property names.



36
37
38
39
40
41
42
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 36

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['reference_id'] = 'reference_id'
  @_hash['amount'] = 'amount'
  @_hash['shipping_options'] = 'shipping_options'
  @_hash
end

.nullablesObject

An array for nullable fields



54
55
56
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 54

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
48
49
50
51
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 45

def self.optionals
  %w[
    reference_id
    amount
    shipping_options
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



96
97
98
99
100
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 96

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} reference_id: #{@reference_id.inspect}, amount: #{@amount.inspect},"\
  " shipping_options: #{@shipping_options.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



89
90
91
92
93
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 89

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} reference_id: #{@reference_id}, amount: #{@amount}, shipping_options:"\
  " #{@shipping_options}>"
end