Class: WalmartApIs::Item

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

Overview

Item Model.

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(item_id:, product_name:, product_url:, product_image_url:, sku_id:, current_price:, target_price:, shipping_price:, incentive_type:, base_referral_fee:, reduced_referral_fee:, enrollment_type:, enrollment_date:, incentive_status:, inventory_count:, start_date:, expiration_date:, incentive_id:, additional_properties: nil) ⇒ Item

Returns a new instance of Item.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/walmart_ap_is/models/item.rb', line 118

def initialize(item_id:, product_name:, product_url:, product_image_url:,
               sku_id:, current_price:, target_price:, shipping_price:,
               incentive_type:, base_referral_fee:, reduced_referral_fee:,
               enrollment_type:, enrollment_date:, incentive_status:,
               inventory_count:, start_date:, expiration_date:,
               incentive_id:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @item_id = item_id
  @product_name = product_name
  @product_url = product_url
  @product_image_url = product_image_url
  @sku_id = sku_id
  @current_price = current_price
  @target_price = target_price
  @shipping_price = shipping_price
  @incentive_type = incentive_type
  @base_referral_fee = base_referral_fee
  @reduced_referral_fee = reduced_referral_fee
  @enrollment_type = enrollment_type
  @enrollment_date = enrollment_date
  @incentive_status = incentive_status
  @inventory_count = inventory_count
  @start_date = start_date
  @expiration_date = expiration_date
  @incentive_id = incentive_id
  @additional_properties = additional_properties
end

Instance Attribute Details

#base_referral_feeInteger

TODO: Write general description for this method

Returns:

  • (Integer)


50
51
52
# File 'lib/walmart_ap_is/models/item.rb', line 50

def base_referral_fee
  @base_referral_fee
end

#current_priceFloat

TODO: Write general description for this method

Returns:

  • (Float)


34
35
36
# File 'lib/walmart_ap_is/models/item.rb', line 34

def current_price
  @current_price
end

#enrollment_dateString

TODO: Write general description for this method

Returns:

  • (String)


62
63
64
# File 'lib/walmart_ap_is/models/item.rb', line 62

def enrollment_date
  @enrollment_date
end

#enrollment_typeString

TODO: Write general description for this method

Returns:

  • (String)


58
59
60
# File 'lib/walmart_ap_is/models/item.rb', line 58

def enrollment_type
  @enrollment_type
end

#expiration_dateString

TODO: Write general description for this method

Returns:

  • (String)


78
79
80
# File 'lib/walmart_ap_is/models/item.rb', line 78

def expiration_date
  @expiration_date
end

#incentive_idString

TODO: Write general description for this method

Returns:

  • (String)


82
83
84
# File 'lib/walmart_ap_is/models/item.rb', line 82

def incentive_id
  @incentive_id
end

#incentive_statusString

TODO: Write general description for this method

Returns:

  • (String)


66
67
68
# File 'lib/walmart_ap_is/models/item.rb', line 66

def incentive_status
  @incentive_status
end

#incentive_typeString

TODO: Write general description for this method

Returns:

  • (String)


46
47
48
# File 'lib/walmart_ap_is/models/item.rb', line 46

def incentive_type
  @incentive_type
end

#inventory_countFloat

TODO: Write general description for this method

Returns:

  • (Float)


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

def inventory_count
  @inventory_count
end

#item_idString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/walmart_ap_is/models/item.rb', line 14

def item_id
  @item_id
end

#product_image_urlString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/walmart_ap_is/models/item.rb', line 26

def product_image_url
  @product_image_url
end

#product_nameString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/walmart_ap_is/models/item.rb', line 18

def product_name
  @product_name
end

#product_urlString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/walmart_ap_is/models/item.rb', line 22

def product_url
  @product_url
end

#reduced_referral_feeInteger

TODO: Write general description for this method

Returns:

  • (Integer)


54
55
56
# File 'lib/walmart_ap_is/models/item.rb', line 54

def reduced_referral_fee
  @reduced_referral_fee
end

#shipping_priceInteger

TODO: Write general description for this method

Returns:

  • (Integer)


42
43
44
# File 'lib/walmart_ap_is/models/item.rb', line 42

def shipping_price
  @shipping_price
end

#sku_idString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/walmart_ap_is/models/item.rb', line 30

def sku_id
  @sku_id
end

#start_dateString

TODO: Write general description for this method

Returns:

  • (String)


74
75
76
# File 'lib/walmart_ap_is/models/item.rb', line 74

def start_date
  @start_date
end

#target_priceInteger

TODO: Write general description for this method

Returns:

  • (Integer)


38
39
40
# File 'lib/walmart_ap_is/models/item.rb', line 38

def target_price
  @target_price
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/walmart_ap_is/models/item.rb', line 149

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  item_id = hash.key?('itemId') ? hash['itemId'] : nil
  product_name = hash.key?('productName') ? hash['productName'] : nil
  product_url = hash.key?('productUrl') ? hash['productUrl'] : nil
  product_image_url =
    hash.key?('productImageUrl') ? hash['productImageUrl'] : nil
  sku_id = hash.key?('skuId') ? hash['skuId'] : nil
  current_price = hash.key?('currentPrice') ? hash['currentPrice'] : nil
  target_price = hash.key?('targetPrice') ? hash['targetPrice'] : nil
  shipping_price = hash.key?('shippingPrice') ? hash['shippingPrice'] : nil
  incentive_type = hash.key?('incentiveType') ? hash['incentiveType'] : nil
  base_referral_fee =
    hash.key?('baseReferralFee') ? hash['baseReferralFee'] : nil
  reduced_referral_fee =
    hash.key?('reducedReferralFee') ? hash['reducedReferralFee'] : nil
  enrollment_type =
    hash.key?('enrollmentType') ? hash['enrollmentType'] : nil
  enrollment_date =
    hash.key?('enrollmentDate') ? hash['enrollmentDate'] : nil
  incentive_status =
    hash.key?('incentiveStatus') ? hash['incentiveStatus'] : nil
  inventory_count =
    hash.key?('inventoryCount') ? hash['inventoryCount'] : nil
  start_date = hash.key?('startDate') ? hash['startDate'] : nil
  expiration_date =
    hash.key?('expirationDate') ? hash['expirationDate'] : nil
  incentive_id = hash.key?('incentiveId') ? hash['incentiveId'] : nil

  # 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.
  Item.new(item_id: item_id,
           product_name: product_name,
           product_url: product_url,
           product_image_url: product_image_url,
           sku_id: sku_id,
           current_price: current_price,
           target_price: target_price,
           shipping_price: shipping_price,
           incentive_type: incentive_type,
           base_referral_fee: base_referral_fee,
           reduced_referral_fee: reduced_referral_fee,
           enrollment_type: enrollment_type,
           enrollment_date: enrollment_date,
           incentive_status: incentive_status,
           inventory_count: inventory_count,
           start_date: start_date,
           expiration_date: expiration_date,
           incentive_id: incentive_id,
           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/walmart_ap_is/models/item.rb', line 85

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['item_id'] = 'itemId'
  @_hash['product_name'] = 'productName'
  @_hash['product_url'] = 'productUrl'
  @_hash['product_image_url'] = 'productImageUrl'
  @_hash['sku_id'] = 'skuId'
  @_hash['current_price'] = 'currentPrice'
  @_hash['target_price'] = 'targetPrice'
  @_hash['shipping_price'] = 'shippingPrice'
  @_hash['incentive_type'] = 'incentiveType'
  @_hash['base_referral_fee'] = 'baseReferralFee'
  @_hash['reduced_referral_fee'] = 'reducedReferralFee'
  @_hash['enrollment_type'] = 'enrollmentType'
  @_hash['enrollment_date'] = 'enrollmentDate'
  @_hash['incentive_status'] = 'incentiveStatus'
  @_hash['inventory_count'] = 'inventoryCount'
  @_hash['start_date'] = 'startDate'
  @_hash['expiration_date'] = 'expirationDate'
  @_hash['incentive_id'] = 'incentiveId'
  @_hash
end

.nullablesObject

An array for nullable fields



114
115
116
# File 'lib/walmart_ap_is/models/item.rb', line 114

def self.nullables
  []
end

.optionalsObject

An array for optional fields



109
110
111
# File 'lib/walmart_ap_is/models/item.rb', line 109

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/walmart_ap_is/models/item.rb', line 224

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} item_id: #{@item_id.inspect}, product_name: #{@product_name.inspect},"\
  " product_url: #{@product_url.inspect}, product_image_url: #{@product_image_url.inspect},"\
  " sku_id: #{@sku_id.inspect}, current_price: #{@current_price.inspect}, target_price:"\
  " #{@target_price.inspect}, shipping_price: #{@shipping_price.inspect}, incentive_type:"\
  " #{@incentive_type.inspect}, base_referral_fee: #{@base_referral_fee.inspect},"\
  " reduced_referral_fee: #{@reduced_referral_fee.inspect}, enrollment_type:"\
  " #{@enrollment_type.inspect}, enrollment_date: #{@enrollment_date.inspect},"\
  " incentive_status: #{@incentive_status.inspect}, inventory_count:"\
  " #{@inventory_count.inspect}, start_date: #{@start_date.inspect}, expiration_date:"\
  " #{@expiration_date.inspect}, incentive_id: #{@incentive_id.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/walmart_ap_is/models/item.rb', line 210

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} item_id: #{@item_id}, product_name: #{@product_name}, product_url:"\
  " #{@product_url}, product_image_url: #{@product_image_url}, sku_id: #{@sku_id},"\
  " current_price: #{@current_price}, target_price: #{@target_price}, shipping_price:"\
  " #{@shipping_price}, incentive_type: #{@incentive_type}, base_referral_fee:"\
  " #{@base_referral_fee}, reduced_referral_fee: #{@reduced_referral_fee}, enrollment_type:"\
  " #{@enrollment_type}, enrollment_date: #{@enrollment_date}, incentive_status:"\
  " #{@incentive_status}, inventory_count: #{@inventory_count}, start_date: #{@start_date},"\
  " expiration_date: #{@expiration_date}, incentive_id: #{@incentive_id},"\
  " additional_properties: #{@additional_properties}>"
end