Class: WalmartApIs::WfsInventoryAge

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/walmart_ap_is/models/wfs_inventory_age.rb

Overview

Units grouped by storage duration. Used for long-term storage fee assessment. 7 buckets: days365Plus, days365To450, and days450Plus reflect the upstream split-aged-buckets feature — days365Plus is the pre-split total.

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(days0_to90: SKIP, days91_to180: SKIP, days181_to270: SKIP, days271_to365: SKIP, days365_plus: SKIP, days365_to450: SKIP, days450_plus: SKIP, additional_properties: nil) ⇒ WfsInventoryAge

Returns a new instance of WfsInventoryAge.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 74

def initialize(days0_to90: SKIP, days91_to180: SKIP, days181_to270: SKIP,
               days271_to365: SKIP, days365_plus: SKIP, days365_to450: SKIP,
               days450_plus: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @days0_to90 = days0_to90 unless days0_to90 == SKIP
  @days91_to180 = days91_to180 unless days91_to180 == SKIP
  @days181_to270 = days181_to270 unless days181_to270 == SKIP
  @days271_to365 = days271_to365 unless days271_to365 == SKIP
  @days365_plus = days365_plus unless days365_plus == SKIP
  @days365_to450 = days365_to450 unless days365_to450 == SKIP
  @days450_plus = days450_plus unless days450_plus == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#days0_to90Integer

TODO: Write general description for this method

Returns:

  • (Integer)


17
18
19
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 17

def days0_to90
  @days0_to90
end

#days181_to270Integer

TODO: Write general description for this method

Returns:

  • (Integer)


25
26
27
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 25

def days181_to270
  @days181_to270
end

#days271_to365Integer

TODO: Write general description for this method

Returns:

  • (Integer)


29
30
31
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 29

def days271_to365
  @days271_to365
end

#days365_plusInteger

TODO: Write general description for this method

Returns:

  • (Integer)


33
34
35
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 33

def days365_plus
  @days365_plus
end

#days365_to450Integer

TODO: Write general description for this method

Returns:

  • (Integer)


37
38
39
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 37

def days365_to450
  @days365_to450
end

#days450_plusInteger

TODO: Write general description for this method

Returns:

  • (Integer)


41
42
43
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 41

def days450_plus
  @days450_plus
end

#days91_to180Integer

TODO: Write general description for this method

Returns:

  • (Integer)


21
22
23
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 21

def days91_to180
  @days91_to180
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 91

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  days0_to90 = hash.key?('days0To90') ? hash['days0To90'] : SKIP
  days91_to180 = hash.key?('days91To180') ? hash['days91To180'] : SKIP
  days181_to270 = hash.key?('days181To270') ? hash['days181To270'] : SKIP
  days271_to365 = hash.key?('days271To365') ? hash['days271To365'] : SKIP
  days365_plus = hash.key?('days365Plus') ? hash['days365Plus'] : SKIP
  days365_to450 = hash.key?('days365To450') ? hash['days365To450'] : SKIP
  days450_plus = hash.key?('days450Plus') ? hash['days450Plus'] : SKIP

  # 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.
  WfsInventoryAge.new(days0_to90: days0_to90,
                      days91_to180: days91_to180,
                      days181_to270: days181_to270,
                      days271_to365: days271_to365,
                      days365_plus: days365_plus,
                      days365_to450: days365_to450,
                      days450_plus: days450_plus,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 44

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['days0_to90'] = 'days0To90'
  @_hash['days91_to180'] = 'days91To180'
  @_hash['days181_to270'] = 'days181To270'
  @_hash['days271_to365'] = 'days271To365'
  @_hash['days365_plus'] = 'days365Plus'
  @_hash['days365_to450'] = 'days365To450'
  @_hash['days450_plus'] = 'days450Plus'
  @_hash
end

.nullablesObject

An array for nullable fields



70
71
72
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 70

def self.nullables
  []
end

.optionalsObject

An array for optional fields



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 57

def self.optionals
  %w[
    days0_to90
    days91_to180
    days181_to270
    days271_to365
    days365_plus
    days365_to450
    days450_plus
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



131
132
133
134
135
136
137
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 131

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} days0_to90: #{@days0_to90.inspect}, days91_to180: #{@days91_to180.inspect},"\
  " days181_to270: #{@days181_to270.inspect}, days271_to365: #{@days271_to365.inspect},"\
  " days365_plus: #{@days365_plus.inspect}, days365_to450: #{@days365_to450.inspect},"\
  " days450_plus: #{@days450_plus.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



122
123
124
125
126
127
128
# File 'lib/walmart_ap_is/models/wfs_inventory_age.rb', line 122

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} days0_to90: #{@days0_to90}, days91_to180: #{@days91_to180}, days181_to270:"\
  " #{@days181_to270}, days271_to365: #{@days271_to365}, days365_plus: #{@days365_plus},"\
  " days365_to450: #{@days365_to450}, days450_plus: #{@days450_plus}, additional_properties:"\
  " #{@additional_properties}>"
end