Class: Edi::MiraklSeller::LeroymerlinAdeo::ProductDataPresenter

Inherits:
BaseMiraklPresenter show all
Defined in:
app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb

Instance Attribute Summary

Attributes inherited from BaseMiraklPresenter

#image_locales

Attributes inherited from BasePresenter

#current_account, #options, #url_helper

Instance Method Summary collapse

Methods inherited from BaseMiraklPresenter

#images, #initialize, #to_h, #video

Methods inherited from BasePresenter

#can?, #capture, #concat, #content_tag, #fa_icon, #h, #initialize, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u

Constructor Details

This class inherits a constructor from Edi::MiraklSeller::BaseMiraklPresenter

Instance Method Details

#brandObject



84
85
86
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 84

def brand
  'LOV_270934' # This is WARMLYYOURS
end

#colorObject

END TOWEL WARMER RELATED METHODS



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 239

def color
  # TODO: color could be nil
  # Beige LOV_002995
  # Purple LOV_004252
  # Black LOV_001063
  # Red LOV_004121
  # Grey / silver LOV_038355
  # Colorless / transparent LOV_067715
  # White LOV_001875
  # Blue LOV_001882
  # Orange / copper LOV_038755
  # Multicolour LOV_003647
  # Green LOV_003696
  # Brown LOV_004077
  # Pink LOV_004239
  # Yellow / golden LOV_038356
  # Transparent LOV_004139

  fetched_color = spec_value(:finish) || spec_value(:color)
  case fetched_color
  when /Polished|Brushed|Stainless|Steel/i
    'LOV_038355'
  when /Bronze/i
    'LOV_004077'
  when /Gold/i
    'LOV_038356'
  when /Black/i
    'LOV_001063'
  when /White/i
    'LOV_001875'
  when /Mirror|Glass/i
    'LOV_003647'
  else
    @error_list << ("Color #{fetched_color} not mapped for item #{item.sku}.")
  end
end

#energy_savingObject



352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 352

def energy_saving
  # Presence detector LOV_040467
  # Programmable LOV_031724
  # Consumption monitoring LOV_237230
  # Remotely controllable with smartphone LOV_237231
  # Weekly programmable LOV_259107
  # Daily programmable LOV_259108
  # Geolocalisation LOV_259109
  # Outdoor temperature sensor LOV_259110
  # With remote control (supplied) LOV_048607
  # Product without energy saving function LOV_259111
  # Timer LOV_001521
  'LOV_259111'
end

#generic_dataObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 3

def generic_data
  {
    required: {
      product_category: mirakl_product_category,
      shop_sku: ean13,
      i18n_fr_12963_title: name(locale: :fr),
      i18n_it_12963_title: name(locale: :it),
      i18n_es_12963_title: name(locale: :es),
      i18n_pt_12963_title: name(locale: :pt),
      feature_06575_brand: brand,
      gtin_EAN13: ean13,
      i18n_fr_01022_longdescription: detailed_description_html(locale: :fr),
      i18n_it_01022_longdescription: detailed_description_html(locale: :it),
      i18n_es_01022_longdescription: detailed_description_html(locale: :es),
      i18n_pt_01022_longdescription: detailed_description_html(locale: :pt)
    },
    optional: {
      product_administrative_code: item.sku,
      media_1: images[0],
      media_2: images[1],
      media_3: images[2],
      media_4: images[3],
      media_5: images[4],
      media_6: images[5],
      media_7: images[6],
      media_8: images[7],
      media_9: images[8],
      parentproductid: nil,
      feature_10837_main_color: color,
      feature_10840_main_material: nil
    }
  }
end

#height_rangeObject



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 299

def height_range
  # More than 80 LOV_037580
  # From 61 to 80 LOV_204116
  # From 40 to 60 LOV_039247
  # Less than 40 LOV_064242
  height = item.rendered_product_specifications.dig(:height, :raw)
  return nil unless height.present?

  height = height.to_i
  if height < 40
    'LOV_064242'
  elsif height >= 40 && height <= 60
    'LOV_039247'
  elsif height >= 61 && height <= 80
    'LOV_204116'
  elsif height > 80
    'LOV_037580'
  end
end

#height_range_twObject



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 149

def height_range_tw
  # More than 150 LOV_039104
  # Less than 100 LOV_037864
  # From 100 to 150 LOV_038230
  height = item.rendered_product_specifications.dig(:height, :raw)
  return nil unless height.present?

  height = height.to_i
  if height < 100
    'LOV_037864'
  elsif height >= 100 && height <= 150
    'LOV_038230'
  elsif height > 150
    'LOV_039104'
  end
end

#mirakl_product_categoryObject



76
77
78
79
80
81
82
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 76

def mirakl_product_category
  if item.is_radiant_panel?
    '200282|RADIATEUR_RAYONNANT|RADIATEUR_ELECTRIQUE|R08-004-001'
  elsif item.is_towel_warmer?
    '200280|SECHE-SERVIETTE_ELECTRIQUE_ENERGIE_SECHE|SECHE_SERVIETTE_ELECTRIQUE|R08-004-002'
  end
end

#more_info_twObject



111
112
113
114
115
116
117
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 111

def more_info_tw
  # Fluid inertia type LOV_043680
  # Heating cable LOV_217097
  # Dry inertia type LOV_043679
  # With radiation LOV_043677
  'LOV_217097'
end

#power_rangeObject



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 276

def power_range
  # From 1,001 to 1,500 LOV_037856
  # More than 2000 LOV_037569
  # Less than 750 LOV_037568
  # From 750 to 1000 LOV_037572
  # From 1501 to 2000 LOV_037857

  watts = item.watts
  return nil unless watts.present?

  if watts < 750
    'LOV_037568'
  elsif watts >= 750 && watts <= 1000
    'LOV_037572'
  elsif watts >= 1001 && watts <= 1500
    'LOV_037856'
  elsif watts >= 1501 && watts <= 2000
    'LOV_037857'
  elsif watts > 2000
    'LOV_037569'
  end
end

#product_name_twObject



105
106
107
108
109
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 105

def product_name_tw
  # Not concerned LOV_037418
  # Electric towel rail LOV_044694
  'LOV_044694'
end

#programmable_twObject



186
187
188
189
190
191
192
193
194
195
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 186

def programmable_tw
  # Daily LOV_202389
  # Weekly LOV_001513
  # No LOV_000002
  # Without LOV_000129
  # Daily LOV_001517
  # Pre-programmed LOV_043647
  # Free weekly LOV_043648
  'LOV_000002'
end

#radiant_panel_dataObject



68
69
70
71
72
73
74
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 68

def radiant_panel_data
  {
    required: {
      ATT_15344: 'No'
    }
  }
end

#remote_control_twObject



172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 172

def remote_control_tw
  # Wi-Fi LOV_068287
  # Remote control not included LOV_251956
  # Radio-frequency LOV_210204
  # Remote control not needed LOV_251958
  # Infrared LOV_002050
  # Code Hopping LOV_221905
  # With cable LOV_227636
  # With motion detection LOV_064238
  # Fixed code LOV_282176
  # Quartzite LOV_282177
  'LOV_251958'
end

#shape_formatObject



343
344
345
346
347
348
349
350
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 343

def shape_format
  # Vertical LOV_001197
  # Square LOV_000900
  # Plinth LOV_000635
  # Horizontal LOV_001189
  # Base unit LOV_007631
  'LOV_001197'
end

#smart_homeObject



336
337
338
339
340
341
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 336

def smart_home
  # Control my heating remotely LOV_257542
  # Control my energy consumption LOV_257553
  # The product is not a connected device LOV_257288
  'LOV_257288'
end

#towel_warmer_dataObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 37

def towel_warmer_data
  {
    required: {
      ATT_15344: 'No'
    },
    optional: {
      'feature_10774_200280|SECHE-SERVIETTE_ELECTRIQUE_ENERGIE_SECHE|SECHE_SERVIETTE_ELECTRIQUE|R08-004-002': width_range_tw,
      'feature_08547_200280|SECHE-SERVIETTE_ELECTRIQUE_ENERGIE_SECHE|SECHE_SERVIETTE_ELECTRIQUE|R08-004-002': product_name_tw,
      'feature_01181_200280|SECHE-SERVIETTE_ELECTRIQUE_ENERGIE_SECHE|SECHE_SERVIETTE_ELECTRIQUE|R08-004-002': more_info_tw,
      'feature_22088_200280|SECHE-SERVIETTE_ELECTRIQUE_ENERGIE_SECHE|SECHE_SERVIETTE_ELECTRIQUE|R08-004-002': type_of_product,
      'feature_10021_200280|SECHE-SERVIETTE_ELECTRIQUE_ENERGIE_SECHE|SECHE_SERVIETTE_ELECTRIQUE|R08-004-002': tube_shape,
      'feature_10777_200280|SECHE-SERVIETTE_ELECTRIQUE_ENERGIE_SECHE|SECHE_SERVIETTE_ELECTRIQUE|R08-004-002': height_range_tw,
      'feature_00773_200280|SECHE-SERVIETTE_ELECTRIQUE_ENERGIE_SECHE|SECHE_SERVIETTE_ELECTRIQUE|R08-004-002': 'No',
      'feature_13174_200280|SECHE-SERVIETTE_ELECTRIQUE_ENERGIE_SECHE|SECHE_SERVIETTE_ELECTRIQUE|R08-004-002': tw_shape,
      'feature_00040_200280|SECHE-SERVIETTE_ELECTRIQUE_ENERGIE_SECHE|SECHE_SERVIETTE_ELECTRIQUE|R08-004-002': tw_use,
      'feature_12925_200280|SECHE-SERVIETTE_ELECTRIQUE_ENERGIE_SECHE|SECHE_SERVIETTE_ELECTRIQUE|R08-004-002': programmable_tw,
      'feature_10355_200280|SECHE-SERVIETTE_ELECTRIQUE_ENERGIE_SECHE|SECHE_SERVIETTE_ELECTRIQUE|R08-004-002': watts_tw,
      ATT_14317: item.spec_value(:watts),
      ATT_00052: item.sku,
      ATT_00053: item.spec_value(:width),
      ATT_00054: item.spec_value(:height),
      ATT_05885: item.spec_value(:finish),
      ATT_02178: 'No',
      ATT_06139: 'No',
      ATT_22040: remote_control_tw,
      ATT_00055: item.spec_value(:depth),
      ATT_26844: 'No'
    }
  }
end

#tube_shapeObject



127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 127

def tube_shape
  # Rectangular LOV_000971
  # Round LOV_004325
  # Square LOV_000900
  # Flat LOV_003790
  bar_shape = item.spec_value(:bar_shape)
  case bar_shape
  when 'Round'
    'LOV_004325'
  when 'Square'
    'LOV_000900'
  end
end

#tw_shapeObject



141
142
143
144
145
146
147
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 141

def tw_shape
  tw_shape = item.spec_value(:overall_towel_warmer_shape)
  case tw_shape
  when 'Rectangular'
    'LOV_001495'
  end
end

#tw_useObject



166
167
168
169
170
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 166

def tw_use
  # Dry towels LOV_237144
  # Heat the bathroom LOV_237143
  'LOV_237144'
end

#type_of_productObject



119
120
121
122
123
124
125
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 119

def type_of_product
  # Dry inertia type LOV_043679
  # Electric towel rail LOV_044694
  # Electric towel rail with fan LOV_044695
  # Dry inertia electric towel dryer LOV_280736
  'LOV_280736'
end

#watts_twObject



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 197

def watts_tw
  # 100 LOV_000184
  # 500 + 800 LOV_064557
  # 600 LOV_000879
  # 800 LOV_037919
  # 900 LOV_056573
  # 750 + 1000 LOV_064554
  # 250 LOV_000215
  # 500 + 1000 LOV_064553
  # 700 LOV_064552
  # 350 LOV_041775
  # 1000 + 1000 LOV_064555
  # 1500 LOV_066823
  # 630 LOV_063151
  # 300+1000 LOV_255538
  # 160 LOV_040661
  # 80 LOV_035325
  # 120 LOV_037369
  # 1,750 LOV_066822
  # 1,600 LOV_066826
  # 300 LOV_037918
  # 500 LOV_037988
  # 60 LOV_000073
  # 750 LOV_064548
  # 2000 LOV_041047
  # 1000 LOV_042376
  # 1300 LOV_066824
  # 700 + 800 LOV_204121
  # 400 LOV_032241
  # 280 LOV_001004
  # 150 LOV_031515
  # 740 LOV_064550
  watts = item.spec_value(:watts)
  case watts
  when 150
    'LOV_031515'
  end
end

#width_rangeObject



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 319

def width_range
  # From 81 to 100 LOV_204115
  # More than 100 LOV_037622
  # From 60 to 80 LOV_038586
  # Less than 60 LOV_047987
  width = item.rendered_product_specifications.dig(:width, :raw)
  if width < 60
    'LOV_047987'
  elsif width >= 60 && width <= 80
    'LOV_038586'
  elsif width >= 81 && width <= 100
    'LOV_204115'
  elsif width > 100
    'LOV_037622'
  end
end

#width_range_twObject

TOWEL WARMER RELATED METHODS



91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'app/services/edi/mirakl_seller/leroymerlin_adeo/product_data_presenter.rb', line 91

def width_range_tw
  # More than 50 LOV_037242
  # 50 LOV_034152
  # Less than 50 LOV_037595
  width = item.rendered_product_specifications.dig(:width, :raw)
  if width < 50
    'LOV_037595'
  elsif width == 50
    'LOV_034152'
  elsif width > 50
    'LOV_037242'
  end
end