Class: NewStoreApi::ServiceLevelRate
- Defined in:
- lib/new_store_api/models/service_level_rate.rb
Overview
ServiceLevelRate Model.
Instance Attribute Summary collapse
-
#delivery_time ⇒ String
An estimation of the time it will take to deliver the goods.
-
#display_name ⇒ String
A human readable name of the service level.
-
#fulfillment_assignments ⇒ Array[FulfillmentAssignment]
Describes which goods can be fulfilled to which location, for the service level and given stocks at different locations as well as tenant's configuration.
-
#service_level_id ⇒ String
The service level id that correspond to a choice the user/customer can make, to then generate a real option.
-
#total_price ⇒ String
The total estimated shipping cost.
-
#total_price_currency ⇒ TotalPriceCurrencyEnum
The total estimated shipping cost currency.
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(delivery_time = nil, display_name = nil, fulfillment_assignments = nil, service_level_id = nil, total_price = SKIP, total_price_currency = SKIP) ⇒ ServiceLevelRate
constructor
A new instance of ServiceLevelRate.
-
#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(delivery_time = nil, display_name = nil, fulfillment_assignments = nil, service_level_id = nil, total_price = SKIP, total_price_currency = SKIP) ⇒ ServiceLevelRate
Returns a new instance of ServiceLevelRate.
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 70 def initialize(delivery_time = nil, display_name = nil, fulfillment_assignments = nil, service_level_id = nil, total_price = SKIP, total_price_currency = SKIP) @delivery_time = delivery_time @display_name = display_name @fulfillment_assignments = fulfillment_assignments @service_level_id = service_level_id @total_price = total_price unless total_price == SKIP @total_price_currency = total_price_currency unless total_price_currency == SKIP end |
Instance Attribute Details
#delivery_time ⇒ String
An estimation of the time it will take to deliver the goods
14 15 16 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 14 def delivery_time @delivery_time end |
#display_name ⇒ String
A human readable name of the service level
18 19 20 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 18 def display_name @display_name end |
#fulfillment_assignments ⇒ Array[FulfillmentAssignment]
Describes which goods can be fulfilled to which location, for the service level and given stocks at different locations as well as tenant's configuration
24 25 26 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 24 def fulfillment_assignments @fulfillment_assignments end |
#service_level_id ⇒ String
The service level id that correspond to a choice the user/customer can make, to then generate a real option.
29 30 31 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 29 def service_level_id @service_level_id end |
#total_price ⇒ String
The total estimated shipping cost. This can be different than the addition of all assignments prices as it is driven by configuration. Do not use if either total_price or total_currency field is null.
35 36 37 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 35 def total_price @total_price end |
#total_price_currency ⇒ TotalPriceCurrencyEnum
The total estimated shipping cost currency. Do not use if either total_price or total_currency field is null.
40 41 42 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 40 def total_price_currency @total_price_currency end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 82 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. delivery_time = hash.key?('delivery_time') ? hash['delivery_time'] : nil display_name = hash.key?('display_name') ? hash['display_name'] : nil # Parameter is an array, so we need to iterate through it fulfillment_assignments = nil unless hash['fulfillment_assignments'].nil? fulfillment_assignments = [] hash['fulfillment_assignments'].each do |structure| fulfillment_assignments << (FulfillmentAssignment.from_hash(structure) if structure) end end fulfillment_assignments = nil unless hash.key?('fulfillment_assignments') service_level_id = hash.key?('service_level_id') ? hash['service_level_id'] : nil total_price = hash.key?('total_price') ? hash['total_price'] : SKIP total_price_currency = hash.key?('total_price_currency') ? hash['total_price_currency'] : SKIP # Create object from extracted values. ServiceLevelRate.new(delivery_time, display_name, fulfillment_assignments, service_level_id, total_price, total_price_currency) end |
.names ⇒ Object
A mapping from model property names to API property names.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 43 def self.names @_hash = {} if @_hash.nil? @_hash['delivery_time'] = 'delivery_time' @_hash['display_name'] = 'display_name' @_hash['fulfillment_assignments'] = 'fulfillment_assignments' @_hash['service_level_id'] = 'service_level_id' @_hash['total_price'] = 'total_price' @_hash['total_price_currency'] = 'total_price_currency' @_hash end |
.nullables ⇒ Object
An array for nullable fields
63 64 65 66 67 68 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 63 def self.nullables %w[ total_price total_price_currency ] end |
.optionals ⇒ Object
An array for optional fields
55 56 57 58 59 60 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 55 def self.optionals %w[ total_price total_price_currency ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
123 124 125 126 127 128 129 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 123 def inspect class_name = self.class.name.split('::').last "<#{class_name} delivery_time: #{@delivery_time.inspect}, display_name:"\ " #{@display_name.inspect}, fulfillment_assignments: #{@fulfillment_assignments.inspect},"\ " service_level_id: #{@service_level_id.inspect}, total_price: #{@total_price.inspect},"\ " total_price_currency: #{@total_price_currency.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
114 115 116 117 118 119 120 |
# File 'lib/new_store_api/models/service_level_rate.rb', line 114 def to_s class_name = self.class.name.split('::').last "<#{class_name} delivery_time: #{@delivery_time}, display_name: #{@display_name},"\ " fulfillment_assignments: #{@fulfillment_assignments}, service_level_id:"\ " #{@service_level_id}, total_price: #{@total_price}, total_price_currency:"\ " #{@total_price_currency}>" end |