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, items: SKIP, shipping_options: SKIP) ⇒ ShippingOptionsPurchaseUnit

Returns a new instance of ShippingOptionsPurchaseUnit.



64
65
66
67
68
69
70
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 64

def initialize(reference_id: SKIP, amount: SKIP, items: SKIP,
               shipping_options: SKIP)
  @reference_id = reference_id unless reference_id == SKIP
  @amount = amount unless amount == SKIP
  @items = items unless items == 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

#itemsArray[Item]

An array of items that the customer purchases from the merchant.

Returns:



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

def items
  @items
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:



37
38
39
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 37

def shipping_options
  @shipping_options
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 73

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
  items = nil
  unless hash['items'].nil?
    items = []
    hash['items'].each do |structure|
      items << (Item.from_hash(structure) if structure)
    end
  end

  items = SKIP unless hash.key?('items')
  # 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,
                                  items: items,
                                  shipping_options: shipping_options)
end

.namesObject

A mapping from model property names to API property names.



40
41
42
43
44
45
46
47
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 40

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

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
57
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 50

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



115
116
117
118
119
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 115

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

#to_sObject

Provides a human-readable string representation of the object.



108
109
110
111
112
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 108

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