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 the `shipping.options` in 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.
Methods inherited from BaseModel
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 |