Class: Edi::MiraklSeller::Castorama::ProductDataPresenter

Inherits:
BaseMiraklPresenter show all
Defined in:
app/services/edi/mirakl_seller/castorama/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

#bar_shape_twObject



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 223

def bar_shape_tw
  # Circular 6
  # Curved 1
  # Flat 2
  # Half moon 8
  # Oval 5
  # Rectangular 4
  # Square 3
  # Triangular 7
  bar_shape = item.spec_value(:bar_shape)
  case bar_shape
  when 'Round'
    6
  when 'Square'
    3
  else
    @error_list << "TW Tube shape #{bar_shape} not mapped for item #{item.sku}."
  end
end

#colorObject



330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 330

def color
  # Beige 1
  # Black 20
  # Blue 2
  # Bronze 3
  # Brown 4
  # Copper 6
  # Cream 191
  # Gold 8
  # Green 9
  # Grey 10
  # Multicolour 11
  # Natural 190
  # Orange 13
  # Pink 14
  # Purple 15
  # Red 16
  # Silver 17
  # Transparent 32
  # White 18
  # Yellow 19
  fetched_color = spec_value(:finish) || spec_value(:color)
  case fetched_color
  when /Polished|Brushed|Stainless|Steel/i
    17
  when /Bronze/i
    3
  when /Gold/i
    8
  when /Black/i
    20
  when /White/i
    18
  when /Mirror|Glass/i
    11
  else
    @error_list << "Color #{fetched_color} not mapped for item #{item.sku}."
  end
end

#connectivity_radiant_panelObject



398
399
400
401
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 398

def connectivity_radiant_panel
  # Not connected object 16
  16
end

#connectivity_twObject



243
244
245
246
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 243

def connectivity_tw
  # Not connected object 16
  16
end

#core_packObject



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

def core_pack
  # Each 3
  # Pack 6
  # Pair 65
  # Set 4
  3
end

#core_product_typeObject



211
212
213
214
215
216
217
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 211

def core_product_type
  if item.is_radiant_panel?
    12_912
  elsif item.is_towel_warmer?
    13_120
  end
end

#depthObject



421
422
423
424
425
426
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 421

def depth
  depth = item.spec_value(:depth, output_unit: 'mm')
  return nil unless depth.present?

  depth.to_i
end

#display_radiant_panelObject



295
296
297
298
299
300
301
302
303
304
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 295

def display_radiant_panel
  # Backlit LCD 65
  # Digital 5
  # Digital display 125
  # LCD 15
  # LED 113
  # Touchscreen 72
  # Without display 86
  86
end

#display_twObject



248
249
250
251
252
253
254
255
256
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 248

def display_tw
  # Digital 5
  # LCD colour display 12
  # LCD touchscreen colour display 143
  # LED colour 10
  # LED touchscreen colour display 144
  # No display 75
  75
end

#facet_radiant_panelObject

RADIANT PANEL RELATED METHODS



275
276
277
278
279
280
281
282
283
284
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 275

def facet_radiant_panel
  # Boîtier connectable pour radiateur 10976
  # Panneau rayonnant 4822
  # Radiateur inertie sèche 13399
  # Radiateur électrique double cœur de chauffe 13396
  # Radiateur électrique inertie fluide 14262
  # Radiateur électrique inertie sèche 14263
  # Radiateur électrique rayonnant 13397
  13_397
end

#facet_twObject



203
204
205
206
207
208
209
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 203

def facet_tw
  # Sèche-serviettes eau chaude non soufflant 13608
  # Sèche-serviettes eau chaude soufflant 13609
  # Sèche-serviettes non soufflant 6121
  # Sèche-serviettes mixte 16594
  6121
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
36
37
38
39
40
41
42
43
44
45
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 3

def generic_data
  {
    required: {
      category: mirakl_product_category,
      shop_sku: ean13,
      name: name(locale: :fr),
      image_main_1: images[0],
      ean: ean13,
      'Acquisition brand': 10_375,
      Guarantee: guarantee,
      'Body Copy': detailed_description_html(locale: :fr)
    },
    optional: {
      image_secondary_1: images[1],
      image_secondary_2: images[2],
      image_secondary_3: images[3],
      image_secondary_4: images[4],
      image_secondary_5: images[5],
      image_secondary_6: images[6],
      image_secondary_7: images[7],
      image_secondary_8: images[8],
      image_back_of_pack: nil,
      video: video&.cms_url,
      pdf_product_guide: nil,
      pdf_product_instruction_manual: nil,
      pdf_safety_manual: nil,
      pdf_sds_document: nil,
      pdf_dop_document: nil,
      pdf_ids_document: nil,
      pdf_repairabilty_index_document: nil,
      Mirakl_ProductGroup_ID: nil,
      MIRAKL_Legal_notices: nil,
      'Unique Selling Point 01': feature_1(locale: :fr),
      'Unique Selling Point 02': feature_2(locale: :fr),
      'Unique Selling Point 03': feature_3(locale: :fr),
      'Unique Selling Point 04': feature_4(locale: :fr),
      'Unique Selling Point 05': feature_5(locale: :fr),
      'Core_Pack quantity': 1,
      'Core_Pack type': core_pack,
      'Selling Copy': short_description(locale: :fr)
    }
  }
end

#guaranteeObject



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
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 155

def guarantee
  return unless w = item.spec_output(:warranty)

  y = w.match(/\d+/)[0].to_i
  {
    1 => 76,
    2 => 78,
    3 => 79,
    4 => 80,
    5 => 81,
    6 => 82,
    7 => 83,
    8 => 84,
    9 => 85,
    10 => 86,
    11 => 110,
    12 => 97,
    13 => 123,
    14 => 124,
    15 => 87,
    16 => 125,
    17 => 126,
    18 => 127,
    19 => 128,
    20 => 88,
    21 => 129,
    22 => 130,
    23 => 131,
    25 => 89
  }[y]
end

#heat_outputObject

This is expressed in kilowatt hours



408
409
410
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 408

def heat_output
  item.spec_value(:thermal_power)
end

#heater_product_type_twObject

TOWEL WARMER RELATED METHODS



198
199
200
201
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 198

def heater_product_type_tw
  # Heating Wire
  36
end

#heater_radiant_panelObject



286
287
288
289
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 286

def heater_radiant_panel
  # Infrared 21
  15
end

#heating_areaObject



438
439
440
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 438

def heating_area
  item.spec_value(:heating_area)
end

#heightObject

END RADIANT PANEL RELATED METHODS



316
317
318
319
320
321
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 316

def height
  height = item.spec_value(:height, output_unit: 'mm')
  return nil unless height.present?

  height.to_i
end

#ip_ratingObject



137
138
139
140
141
142
143
144
145
146
147
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 137

def ip_rating
  return unless ir = item.spec_output(:ingress_protection_ipxx_rating)

  {
    IP20: '3',
    IP44: '1', # Towel warmers
    IP55: '89',
    IP65: '7', # Radiant panels
    IP66: '12'
  }.with_indifferent_access[ir]
end

#materialObject



370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 370

def material
  # ABS plastic, aluminium, copper & sheet metal 11998
  # Aluminium 6039
  # Aluminium & plastic 7575
  # Aluminium, glass & steel 10785
  # Cast iron 11448
  # Ceramic 6789
  # Glass 8078
  # Glass & steel 7727
  # Low carbon steel 10680
  # Metal & plastic 7803
  # Metal & steel 7802
  # Mild steel 7813
  # Plastic 6441
  # Stainless steel 6793
  # Steel 6016

  material = item.rendered_product_specifications.dig(:material, :raw)
  case material
  when /Steel/i
    6793
  when /Glass/i
    8078
  else
    @error_list << "Material #{material} not mapped for item #{item.sku}."
  end
end

#mirakl_product_categoryObject



129
130
131
132
133
134
135
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 129

def mirakl_product_category
  if item.is_radiant_panel?
    'PIM_10550'
  elsif item.is_towel_warmer?
    'PIM_10552'
  end
end

#mounting_orientationObject



306
307
308
309
310
311
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 306

def mounting_orientation
  # Horizontal 1
  # Horizontal or vertical 2
  # Vertical 3
  2
end

#product_weightObject



412
413
414
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 412

def product_weight
  item.base_weight_converted(unit: 'kg').round(2)
end

#programmableObject



433
434
435
436
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 433

def programmable
  # Non-programmable 11
  11
end

#publicationObject



149
150
151
152
153
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 149

def publication
  Item::PublicationRetriever.new.process(item.sku, locale: :fr, publication_category_paths: LtreePaths::PC_PUBLICATIONS_INSTALLATION).all_publications&.first&.publication_url
rescue StandardError
  ''
end

#radiant_panel_dataObject



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
118
119
120
121
122
123
124
125
126
127
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 87

def radiant_panel_data
  {
    required: {
      Facet_product_type: facet_radiant_panel,
      Heater_product_type: heater_radiant_panel,
      Type_Range: range_radiant_panel,
      'Tech_Heating surface area': heating_area,
      Product_height: height,
      Product_width: width,
      'Vdesc_Colour group': color,
      Tech_Material: 6039,
      Tech_Connectivity: connectivity_radiant_panel,
      Heat_output: heat_output,
      Product_weight: product_weight,
      Tech_Wattage: watts,
      pdf_product_guide: publication,
      'Tech_Room use': room_use_radiant_panel,
      'Core_Product type': core_product_type
    },
    optional: {
      pdf_product_guide: nil,
      Heating_element_type: nil,
      Product_depth: depth,
      'Std_IP rating': nil,
      Std_Standard: nil,
      'Vdesc_Product shape': shape_radiant_panel,
      Programme_facility: programmable,
      'Tech_Fittings & fixings included': nil,
      'Function(s)': nil,
      'Tech_Maximum heat output': watts,
      'Tech_Model name/number': item.sku,
      Mounting_orientation: mounting_orientation,
      Open_window_detection: 'No',
      Presence_sensor: 'No',
      Tech_Programmes: nil,
      Remote_controlled: 'No',
      Smart: 'No',
      Smartphone_compatibility: nil
    }
  }
end

#range_radiant_panelObject



291
292
293
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 291

def range_radiant_panel
  'Electric Radiant Panel'
end

#range_twObject



219
220
221
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 219

def range_tw
  'Electric Towel Warmers'
end

#room_use_radiant_panelObject



416
417
418
419
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 416

def room_use_radiant_panel
  # Bathroom, bedroom, kitchen & living room 76
  76
end

#shape_radiant_panelObject



428
429
430
431
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 428

def shape_radiant_panel
  # Flat 582
  582
end

#thermostat_twObject



258
259
260
261
262
263
264
265
266
267
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 258

def thermostat_tw
  # Digital 5
  # Manual 2
  # No thermostat control 7
  # Thermostat temperature control 6
  # Thermostatic 1
  # With thermostat 3
  # Without thermostat 4
  4
end

#towel_warmer_dataObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 47

def towel_warmer_data
  {
    required: {
      Facet_product_type: facet_tw,
      Heater_product_type: heater_product_type_tw,
      Type_Range: range_tw,
      'Tech_Heating surface area': heating_area,
      Product_height: height,
      Product_width: width,
      'Vdesc_Colour group': color,
      Tech_Material: material,
      Heat_output: watts,
      Product_weight: product_weight,
      Tech_Wattage: watts,
      'Core_Product type': core_product_type,
      pdf_product_guide: publication,
      IEC_protection_class: 1
    },
    optional: {
      pdf_product_guide: nil,
      Product_depth: depth,
      'Std_IP rating': ip_rating,
      Bar_shape: bar_shape_tw,
      Programme_facility: programmable,
      Child_protection: 'No',
      Tech_Connectivity: connectivity_tw,
      Tech_Display: display_tw,
      'Tech_Fittings & fixings included': nil,
      'Tech_Maximum heat output': watts,
      'Tech_Maximum timer time': nil,
      'Tech_Model name/number': sku,
      Motion_sensor: 'No',
      Open_window_detection: 'No',
      Presence_sensor: 'No',
      Remote_controlled: 'No',
      'Tech_Thermostatic control': thermostat_tw
    }
  }
end

#wattsObject



403
404
405
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 403

def watts
  item.spec_value(:watts)
end

#widthObject



323
324
325
326
327
328
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 323

def width
  width = item.spec_value(:width, output_unit: 'mm')
  return nil unless width.present?

  width.to_i
end