Class: PaypalServerSdk::ShippingOptionsPurchaseUnit
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- PaypalServerSdk::ShippingOptionsPurchaseUnit
- 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
-
#amount ⇒ AmountWithBreakdown
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.
-
#reference_id ⇒ String
The API caller-provided external ID for the purchase unit.
-
#shipping_options ⇒ Array[ShippingOption]
An array of shipping options that the payee or merchant offers to the payer to ship or pick up their items.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(reference_id: SKIP, amount: SKIP, shipping_options: SKIP) ⇒ ShippingOptionsPurchaseUnit
constructor
A new instance of ShippingOptionsPurchaseUnit.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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 = unless == SKIP end |
Instance Attribute Details
#amount ⇒ AmountWithBreakdown
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.
28 29 30 |
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 28 def amount @amount end |
#reference_id ⇒ String
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.
18 19 20 |
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 18 def reference_id @reference_id end |
#shipping_options ⇒ Array[ShippingOption]
An array of shipping options that the payee or merchant offers to the payer to ship or pick up their items.
33 34 35 |
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 33 def 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 = nil unless hash['shipping_options'].nil? = [] hash['shipping_options'].each do |structure| << (ShippingOption.from_hash(structure) if structure) end end = SKIP unless hash.key?('shipping_options') # Create object from extracted values. ShippingOptionsPurchaseUnit.new(reference_id: reference_id, amount: amount, shipping_options: ) end |
.names ⇒ Object
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 |
.nullables ⇒ Object
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 |
.optionals ⇒ Object
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
#inspect ⇒ Object
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_s ⇒ Object
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 |