Class: PaypalServerSdk::ShippingOption

Inherits:
BaseModel
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#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

#amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



31
32
33
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 31

def amount
  @amount
end

#idString

A unique ID that identifies a payer-selected shipping option.

Returns:

  • (String)


15
16
17
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 15

def id
  @id
end

#labelString

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.

Returns:

  • (String)


22
23
24
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 22

def label
  @label
end

#selectedTrueClass | 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`.

Returns:

  • (TrueClass | FalseClass)


41
42
43
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 41

def selected
  @selected
end

#typeShippingType

A classification for the method of purchase fulfillment.

Returns:



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

.namesObject

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

.nullablesObject

An array for nullable fields



63
64
65
# File 'lib/paypal_server_sdk/models/shipping_option.rb', line 63

def self.nullables
  []
end

.optionalsObject

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