Class: PaypalServerSdk::ShippingOption
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- PaypalServerSdk::ShippingOption
- Defined in:
- lib/paypal_server_sdk/models/shipping_option.rb
Overview
The options that the payee or merchant offers to the payer to ship or pick up their items.
Instance Attribute Summary collapse
-
#amount ⇒ Money
The currency and amount for a financial transaction, such as a balance or payment due.
-
#id ⇒ String
A unique ID that identifies a payer-selected shipping option.
-
#label ⇒ String
A description that the payer sees, which helps them choose an appropriate shipping option.
-
#selected ⇒ TrueClass | FalseClass
If the API request sets
selected = true, it represents the shipping option that the payee or merchant expects to be pre-selected for the payer when they first view theshipping.optionsin the PayPal Checkout experience. -
#type ⇒ ShippingType
A classification for the method of purchase fulfillment.
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(id:, label:, selected:, type: SKIP, amount: SKIP) ⇒ ShippingOption
constructor
A new instance of ShippingOption.
-
#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(id:, label:, selected:, type: SKIP, amount: SKIP) ⇒ ShippingOption
Returns a new instance of ShippingOption.
67 68 69 70 71 72 73 |
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 67 def initialize(id:, label:, selected:, type: SKIP, amount: SKIP) @id = id @label = label @type = type unless type == SKIP @amount = amount unless amount == SKIP @selected = selected end |
Instance Attribute Details
#amount ⇒ Money
The currency and amount for a financial transaction, such as a balance or payment due.
31 32 33 |
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 31 def amount @amount end |
#id ⇒ String
A unique ID that identifies a payer-selected shipping option.
15 16 17 |
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 15 def id @id end |
#label ⇒ String
A description that the payer sees, which helps them choose an appropriate
shipping option. For example, Free Shipping, USPS Priority Shipping,
Expédition prioritaire USPS, or USPS yōuxiān fā huò. Localize this
description to the payer's locale.
22 23 24 |
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 22 def label @label end |
#selected ⇒ TrueClass | FalseClass
If the API request sets selected = true, it represents the shipping
option that the payee or merchant expects to be pre-selected for the payer
when they first view the shipping.options in the PayPal Checkout
experience. As part of the response if a shipping.option contains
selected=true, it represents the shipping option that the payer selected
during the course of checkout with PayPal. Only one shipping.option can
be set to selected=true.
41 42 43 |
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 41 def selected @selected end |
#type ⇒ ShippingType
A classification for the method of purchase fulfillment.
26 27 28 |
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 26 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 76 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil label = hash.key?('label') ? hash['label'] : nil selected = hash.key?('selected') ? hash['selected'] : nil type = hash.key?('type') ? hash['type'] : SKIP amount = Money.from_hash(hash['amount']) if hash['amount'] # Create object from extracted values. ShippingOption.new(id: id, label: label, selected: selected, type: type, amount: amount) end |
.names ⇒ Object
A mapping from model property names to API property names.
44 45 46 47 48 49 50 51 52 |
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 44 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['label'] = 'label' @_hash['type'] = 'type' @_hash['amount'] = 'amount' @_hash['selected'] = 'selected' @_hash end |
.nullables ⇒ Object
An array for nullable fields
63 64 65 |
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 63 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
55 56 57 58 59 60 |
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 55 def self.optionals %w[ type amount ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
102 103 104 105 106 |
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 102 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, label: #{@label.inspect}, type: #{@type.inspect},"\ " amount: #{@amount.inspect}, selected: #{@selected.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
95 96 97 98 99 |
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 95 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, label: #{@label}, type: #{@type}, amount: #{@amount}, selected:"\ " #{@selected}>" end |