Class: WalmartApIs::PlacementOption
- Defined in:
- lib/walmart_ap_is/models/placement_option.rb
Overview
Contains information pertaining to the placement of the contents of an inbound plan and the related costs.
Instance Attribute Summary collapse
-
#discounts ⇒ Array[Incentive]
Discount for the offered option.
-
#expiration ⇒ DateTime
The expiration date of the placement option.
-
#fees ⇒ Array[Incentive]
The fee for the offered option.
-
#placement_option_id ⇒ String
The identifier of a placement option.
-
#shipment_ids ⇒ Array[String]
Shipment IDs.
-
#status ⇒ String
The status of a placement 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.
Instance Method Summary collapse
-
#initialize(discounts:, fees:, placement_option_id:, shipment_ids:, status:, expiration: SKIP, additional_properties: nil) ⇒ PlacementOption
constructor
A new instance of PlacementOption.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_expiration ⇒ Object
-
#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(discounts:, fees:, placement_option_id:, shipment_ids:, status:, expiration: SKIP, additional_properties: nil) ⇒ PlacementOption
Returns a new instance of PlacementOption.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 65 def initialize(discounts:, fees:, placement_option_id:, shipment_ids:, status:, expiration: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @discounts = discounts @expiration = expiration unless expiration == SKIP @fees = fees @placement_option_id = placement_option_id @shipment_ids = shipment_ids @status = status @additional_properties = additional_properties end |
Instance Attribute Details
#discounts ⇒ Array[Incentive]
Discount for the offered option.
16 17 18 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 16 def discounts @discounts end |
#expiration ⇒ DateTime
The expiration date of the placement option. In ISO 8601 datetime format
with pattern yyyy-MM-ddTHH:mm:ss.sssZ.
21 22 23 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 21 def expiration @expiration end |
#fees ⇒ Array[Incentive]
The fee for the offered option.
25 26 27 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 25 def fees @fees end |
#placement_option_id ⇒ String
The identifier of a placement option. A placement option represents the shipment splits and destinations of SKUs.
30 31 32 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 30 def placement_option_id @placement_option_id end |
#shipment_ids ⇒ Array[String]
Shipment IDs.
34 35 36 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 34 def shipment_ids @shipment_ids end |
#status ⇒ String
The status of a placement option. Possible values: OFFERED, ACCEPTED,
EXPIRED.
39 40 41 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 39 def status @status end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
80 81 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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 80 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it discounts = nil unless hash['discounts'].nil? discounts = [] hash['discounts'].each do |structure| discounts << (Incentive.from_hash(structure) if structure) end end discounts = nil unless hash.key?('discounts') # Parameter is an array, so we need to iterate through it fees = nil unless hash['fees'].nil? fees = [] hash['fees'].each do |structure| fees << (Incentive.from_hash(structure) if structure) end end fees = nil unless hash.key?('fees') placement_option_id = hash.key?('placementOptionId') ? hash['placementOptionId'] : nil shipment_ids = hash.key?('shipmentIds') ? hash['shipmentIds'] : nil status = hash.key?('status') ? hash['status'] : nil expiration = if hash.key?('expiration') (DateTimeHelper.from_rfc3339(hash['expiration']) if hash['expiration']) else SKIP end # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. PlacementOption.new(discounts: discounts, fees: fees, placement_option_id: placement_option_id, shipment_ids: shipment_ids, status: status, expiration: expiration, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 42 def self.names @_hash = {} if @_hash.nil? @_hash['discounts'] = 'discounts' @_hash['expiration'] = 'expiration' @_hash['fees'] = 'fees' @_hash['placement_option_id'] = 'placementOptionId' @_hash['shipment_ids'] = 'shipmentIds' @_hash['status'] = 'status' @_hash end |
.nullables ⇒ Object
An array for nullable fields
61 62 63 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 61 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 54 def self.optionals %w[ expiration ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
144 145 146 147 148 149 150 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 144 def inspect class_name = self.class.name.split('::').last "<#{class_name} discounts: #{@discounts.inspect}, expiration: #{@expiration.inspect}, fees:"\ " #{@fees.inspect}, placement_option_id: #{@placement_option_id.inspect}, shipment_ids:"\ " #{@shipment_ids.inspect}, status: #{@status.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_custom_expiration ⇒ Object
131 132 133 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 131 def to_custom_expiration DateTimeHelper.to_rfc3339(expiration) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
136 137 138 139 140 141 |
# File 'lib/walmart_ap_is/models/placement_option.rb', line 136 def to_s class_name = self.class.name.split('::').last "<#{class_name} discounts: #{@discounts}, expiration: #{@expiration}, fees: #{@fees},"\ " placement_option_id: #{@placement_option_id}, shipment_ids: #{@shipment_ids}, status:"\ " #{@status}, additional_properties: #{@additional_properties}>" end |