Class: NewStoreApi::InjectedOrderShippingOption
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::InjectedOrderShippingOption
- Defined in:
- lib/new_store_api/models/injected_order_shipping_option.rb
Overview
InjectedOrderShippingOption 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.
-
#service_level_identifier ⇒ String
Service level identifier of the shipping option.
-
#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, service_level_identifier = nil, tax = nil, discount_info = SKIP, routing_strategy = SKIP) ⇒ InjectedOrderShippingOption
constructor
A new instance of InjectedOrderShippingOption.
-
#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, service_level_identifier = nil, tax = nil, discount_info = SKIP, routing_strategy = SKIP) ⇒ InjectedOrderShippingOption
Returns a new instance of InjectedOrderShippingOption.
64 65 66 67 68 69 70 71 |
# File 'lib/new_store_api/models/injected_order_shipping_option.rb', line 64 def initialize(price = nil, service_level_identifier = 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 @service_level_identifier = service_level_identifier @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_option.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 and the price_method property.
19 20 21 |
# File 'lib/new_store_api/models/injected_order_shipping_option.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_option.rb', line 25 def routing_strategy @routing_strategy end |
#service_level_identifier ⇒ String
Service level identifier of the shipping option. Set it to IN_STORE_HANDOVER in case of injecting an in-store purchase order. The order will be soft-routed on injection unless config order_injection/skip_soft_routing_on_injection is enabled. Note that this option will NOT work if there are multiple shipments. In which case, use the other payload that requires a shipping option token.
34 35 36 |
# File 'lib/new_store_api/models/injected_order_shipping_option.rb', line 34 def service_level_identifier @service_level_identifier end |
#tax ⇒ Float
The tax applied to the shipping option.
38 39 40 |
# File 'lib/new_store_api/models/injected_order_shipping_option.rb', line 38 def tax @tax end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/new_store_api/models/injected_order_shipping_option.rb', line 74 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. price = hash.key?('price') ? hash['price'] : nil service_level_identifier = hash.key?('service_level_identifier') ? hash['service_level_identifier'] : 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. InjectedOrderShippingOption.new(price, service_level_identifier, tax, discount_info, routing_strategy) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 |
# File 'lib/new_store_api/models/injected_order_shipping_option.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['discount_info'] = 'discount_info' @_hash['price'] = 'price' @_hash['routing_strategy'] = 'routing_strategy' @_hash['service_level_identifier'] = 'service_level_identifier' @_hash['tax'] = 'tax' @_hash end |
.nullables ⇒ Object
An array for nullable fields
60 61 62 |
# File 'lib/new_store_api/models/injected_order_shipping_option.rb', line 60 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
52 53 54 55 56 57 |
# File 'lib/new_store_api/models/injected_order_shipping_option.rb', line 52 def self.optionals %w[ discount_info routing_strategy ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/new_store_api/models/injected_order_shipping_option.rb', line 99 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.service_level_identifier, ->(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['service_level_identifier'], ->(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.
132 133 134 135 136 137 |
# File 'lib/new_store_api/models/injected_order_shipping_option.rb', line 132 def inspect class_name = self.class.name.split('::').last "<#{class_name} discount_info: #{@discount_info.inspect}, price: #{@price.inspect},"\ " routing_strategy: #{@routing_strategy.inspect}, service_level_identifier:"\ " #{@service_level_identifier.inspect}, tax: #{@tax.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
124 125 126 127 128 129 |
# File 'lib/new_store_api/models/injected_order_shipping_option.rb', line 124 def to_s class_name = self.class.name.split('::').last "<#{class_name} discount_info: #{@discount_info}, price: #{@price}, routing_strategy:"\ " #{@routing_strategy}, service_level_identifier: #{@service_level_identifier}, tax:"\ " #{@tax}>" end |