Class: NewStoreApi::AtpInsightsResponse

Inherits:
BaseModel
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#allocationsArray[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.

Returns:



16
17
18
# File 'lib/new_store_api/models/atp_insights_response.rb', line 16

def allocations
  @allocations
end

#fulfillment_node_idString

The fulfillment node ID of the store/warehouse.

Returns:

  • (String)


20
21
22
# File 'lib/new_store_api/models/atp_insights_response.rb', line 20

def fulfillment_node_id
  @fulfillment_node_id
end

#future_allocationsArray[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.

Returns:



26
27
28
# File 'lib/new_store_api/models/atp_insights_response.rb', line 26

def future_allocations
  @future_allocations
end

#product_idString

The product ID of the item.

Returns:

  • (String)


30
31
32
# File 'lib/new_store_api/models/atp_insights_response.rb', line 30

def product_id
  @product_id
end

#reservationsArray[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.

Returns:



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

.namesObject

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

.nullablesObject

An array for nullable fields



58
59
60
# File 'lib/new_store_api/models/atp_insights_response.rb', line 58

def self.nullables
  []
end

.optionalsObject

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

#inspectObject

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_sObject

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