Class: NewStoreApi::AtpInsightsResponse
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::AtpInsightsResponse
- Defined in:
- lib/new_store_api/models/atp_insights_response.rb
Overview
Limited response of valid request for fetching allocations by ATP keys.
Instance Attribute Summary collapse
-
#allocations ⇒ Array[Allocation]
Allocations for the product with given product_id at the fulfillment node with given fulfillment_node_id.
-
#fulfillment_node_id ⇒ String
The fulfillment node ID of the store/warehouse.
-
#future_allocations ⇒ Array[FutureAllocation]
Future allocations for the product with given product_id at the fulfillment node with given fulfillment_node_id.
-
#product_id ⇒ String
The product ID of the item.
-
#reservations ⇒ Array[Reservation]
Reservations for the product with given product_id at the fulfillment node with given fulfillment_node_id.
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(allocations = nil, fulfillment_node_id = nil, product_id = nil, future_allocations = SKIP, reservations = SKIP) ⇒ AtpInsightsResponse
constructor
A new instance of AtpInsightsResponse.
-
#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(allocations = nil, fulfillment_node_id = nil, product_id = nil, future_allocations = SKIP, reservations = SKIP) ⇒ AtpInsightsResponse
Returns a new instance of AtpInsightsResponse.
62 63 64 65 66 67 68 69 70 |
# File 'lib/new_store_api/models/atp_insights_response.rb', line 62 def initialize(allocations = nil, fulfillment_node_id = nil, product_id = nil, future_allocations = SKIP, reservations = SKIP) @allocations = allocations @fulfillment_node_id = fulfillment_node_id @future_allocations = future_allocations unless future_allocations == SKIP @product_id = product_id @reservations = reservations unless reservations == SKIP end |
Instance Attribute Details
#allocations ⇒ Array[Allocation]
Allocations for the product with given product_id at the fulfillment node with given fulfillment_node_id. This request will limit the response to a maximum of 2000 allocations.
16 17 18 |
# File 'lib/new_store_api/models/atp_insights_response.rb', line 16 def allocations @allocations end |
#fulfillment_node_id ⇒ String
The fulfillment node ID of the store/warehouse.
20 21 22 |
# File 'lib/new_store_api/models/atp_insights_response.rb', line 20 def fulfillment_node_id @fulfillment_node_id end |
#future_allocations ⇒ Array[FutureAllocation]
Future allocations for the product with given product_id at the fulfillment node with given fulfillment_node_id. This request will limit the response to a maximum of 2000 allocations.
26 27 28 |
# File 'lib/new_store_api/models/atp_insights_response.rb', line 26 def future_allocations @future_allocations end |
#product_id ⇒ String
The product ID of the item.
30 31 32 |
# File 'lib/new_store_api/models/atp_insights_response.rb', line 30 def product_id @product_id end |
#reservations ⇒ Array[Reservation]
Reservations for the product with given product_id at the fulfillment node with given fulfillment_node_id. This request will limit the response to a maximum of 2000 reservations.
36 37 38 |
# File 'lib/new_store_api/models/atp_insights_response.rb', line 36 def reservations @reservations end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
73 74 75 76 77 78 79 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 |
# File 'lib/new_store_api/models/atp_insights_response.rb', line 73 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 allocations = nil unless hash['allocations'].nil? allocations = [] hash['allocations'].each do |structure| allocations << (Allocation.from_hash(structure) if structure) end end allocations = nil unless hash.key?('allocations') fulfillment_node_id = hash.key?('fulfillment_node_id') ? hash['fulfillment_node_id'] : nil product_id = hash.key?('product_id') ? hash['product_id'] : nil # Parameter is an array, so we need to iterate through it future_allocations = nil unless hash['future_allocations'].nil? future_allocations = [] hash['future_allocations'].each do |structure| future_allocations << (FutureAllocation.from_hash(structure) if structure) end end future_allocations = SKIP unless hash.key?('future_allocations') # Parameter is an array, so we need to iterate through it reservations = nil unless hash['reservations'].nil? reservations = [] hash['reservations'].each do |structure| reservations << (Reservation.from_hash(structure) if structure) end end reservations = SKIP unless hash.key?('reservations') # Create object from extracted values. AtpInsightsResponse.new(allocations, fulfillment_node_id, product_id, future_allocations, reservations) 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/atp_insights_response.rb', line 39 def self.names @_hash = {} if @_hash.nil? @_hash['allocations'] = 'allocations' @_hash['fulfillment_node_id'] = 'fulfillment_node_id' @_hash['future_allocations'] = 'future_allocations' @_hash['product_id'] = 'product_id' @_hash['reservations'] = 'reservations' @_hash end |
.nullables ⇒ Object
An array for nullable fields
58 59 60 |
# File 'lib/new_store_api/models/atp_insights_response.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/atp_insights_response.rb', line 50 def self.optionals %w[ future_allocations reservations ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
128 129 130 131 132 133 |
# File 'lib/new_store_api/models/atp_insights_response.rb', line 128 def inspect class_name = self.class.name.split('::').last "<#{class_name} allocations: #{@allocations.inspect}, fulfillment_node_id:"\ " #{@fulfillment_node_id.inspect}, future_allocations: #{@future_allocations.inspect},"\ " product_id: #{@product_id.inspect}, reservations: #{@reservations.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
120 121 122 123 124 125 |
# File 'lib/new_store_api/models/atp_insights_response.rb', line 120 def to_s class_name = self.class.name.split('::').last "<#{class_name} allocations: #{@allocations}, fulfillment_node_id: #{@fulfillment_node_id},"\ " future_allocations: #{@future_allocations}, product_id: #{@product_id}, reservations:"\ " #{@reservations}>" end |