Class: NewStoreApi::InjectedOrderShippingOption1
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::InjectedOrderShippingOption1
- Defined in:
- lib/new_store_api/models/injected_order_shipping_option1.rb
Overview
InjectedOrderShippingOption1 Model.
Instance Attribute Summary collapse
-
#discount_info ⇒ Array[Object]
Information about shipping discounts applied to the shipment.
-
#price ⇒ Float
The price of the shipping option before discounts.
-
#routing_strategy ⇒ Object
The strategy used to route the order.
-
#shipping_offer_token ⇒ String
The shipping option token ('shipping_offer_token') obtained from the [Get routing options method](https://docs.newstore.net/newstore-cloud/catalog/sfcc-integration. html#tag/Checkout-Options).
-
#tax ⇒ Float
The tax applied to the shipping option.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(price = nil, shipping_offer_token = nil, tax = nil, discount_info = SKIP, routing_strategy = SKIP) ⇒ InjectedOrderShippingOption1
constructor
A new instance of InjectedOrderShippingOption1.
-
#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(price = nil, shipping_offer_token = nil, tax = nil, discount_info = SKIP, routing_strategy = SKIP) ⇒ InjectedOrderShippingOption1
Returns a new instance of InjectedOrderShippingOption1.
62 63 64 65 66 67 68 69 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 62 def initialize(price = nil, shipping_offer_token = nil, tax = nil, discount_info = SKIP, routing_strategy = SKIP) @discount_info = discount_info unless discount_info == SKIP @price = price @routing_strategy = routing_strategy unless routing_strategy == SKIP @shipping_offer_token = shipping_offer_token @tax = tax end |
Instance Attribute Details
#discount_info ⇒ Array[Object]
Information about shipping discounts applied to the shipment.
14 15 16 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 14 def discount_info @discount_info end |
#price ⇒ Float
The price of the shipping option before discounts. It might include taxes depending on the tax method.
19 20 21 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 19 def price @price end |
#routing_strategy ⇒ Object
The strategy used to route the order. If no value is specified, the default strategy is used and the order is routed to the best location based on the fulfillment configuration.
25 26 27 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 25 def routing_strategy @routing_strategy end |
#shipping_offer_token ⇒ String
The shipping option token ('shipping_offer_token') obtained from the [Get routing options method](https://docs.newstore.net/newstore-cloud/catalog/sfcc-integration. html#tag/Checkout-Options).
32 33 34 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 32 def shipping_offer_token @shipping_offer_token end |
#tax ⇒ Float
The tax applied to the shipping option.
36 37 38 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 36 def tax @tax end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 72 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. price = hash.key?('price') ? hash['price'] : nil shipping_offer_token = hash.key?('shipping_offer_token') ? hash['shipping_offer_token'] : nil tax = hash.key?('tax') ? hash['tax'] : nil discount_info = hash.key?('discount_info') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:InjectedOrderDiscountInfo2), hash['discount_info'] ) : SKIP routing_strategy = hash.key?('routing_strategy') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:InjectedOrderRoutingStrategy3), hash['routing_strategy'] ) : SKIP # Create object from extracted values. InjectedOrderShippingOption1.new(price, shipping_offer_token, tax, discount_info, routing_strategy) end |
.names ⇒ Object
A mapping from model property names to API property names.
39 40 41 42 43 44 45 46 47 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 39 def self.names @_hash = {} if @_hash.nil? @_hash['discount_info'] = 'discount_info' @_hash['price'] = 'price' @_hash['routing_strategy'] = 'routing_strategy' @_hash['shipping_offer_token'] = 'shipping_offer_token' @_hash['tax'] = 'tax' @_hash end |
.nullables ⇒ Object
An array for nullable fields
58 59 60 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 58 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
50 51 52 53 54 55 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 50 def self.optionals %w[ discount_info routing_strategy ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 97 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.price, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.shipping_offer_token, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.tax, ->(val) { val.instance_of? Float }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['price'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['shipping_offer_token'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['tax'], ->(val) { val.instance_of? Float }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
129 130 131 132 133 134 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 129 def inspect class_name = self.class.name.split('::').last "<#{class_name} discount_info: #{@discount_info.inspect}, price: #{@price.inspect},"\ " routing_strategy: #{@routing_strategy.inspect}, shipping_offer_token:"\ " #{@shipping_offer_token.inspect}, tax: #{@tax.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
122 123 124 125 126 |
# File 'lib/new_store_api/models/injected_order_shipping_option1.rb', line 122 def to_s class_name = self.class.name.split('::').last "<#{class_name} discount_info: #{@discount_info}, price: #{@price}, routing_strategy:"\ " #{@routing_strategy}, shipping_offer_token: #{@shipping_offer_token}, tax: #{@tax}>" end |