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.
-
#items ⇒ Array[Item]
An array of items that the customer purchases from the merchant.
-
#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, items: 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, 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 = 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 |
#items ⇒ Array[Item]
An array of items that the customer purchases from the merchant.
32 33 34 |
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 32 def items @items 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.
37 38 39 |
# File 'lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb', line 37 def @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 = 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, items: items, shipping_options: ) end |
.names ⇒ Object
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 |
.nullables ⇒ Object
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 |
.optionals ⇒ Object
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
#inspect ⇒ Object
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_s ⇒ Object
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 |