Class: Edi::MiraklSeller::Castorama::ProductDataPresenter
- Inherits:
-
BaseMiraklPresenter
- Object
- SimpleDelegator
- BasePresenter
- BaseMiraklPresenter
- Edi::MiraklSeller::Castorama::ProductDataPresenter
- Defined in:
- app/services/edi/mirakl_seller/castorama/product_data_presenter.rb
Overview
Service object: product data presenter.
Instance Attribute Summary
Attributes inherited from BaseMiraklPresenter
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
- #bar_shape_tw ⇒ Object
- #color ⇒ Object
- #connectivity_infrared_heating_panel ⇒ Object
- #connectivity_tw ⇒ Object
- #core_pack ⇒ Object
- #core_product_type ⇒ Object
- #depth ⇒ Object
- #display_infrared_heating_panel ⇒ Object
- #display_tw ⇒ Object
-
#facet_infrared_heating_panel ⇒ Object
INFRARED HEATING PANEL RELATED METHODS.
- #facet_tw ⇒ Object
- #generic_data ⇒ Object
- #guarantee ⇒ Object
-
#heat_output ⇒ Object
This is expressed in kilowatt hours.
- #heater_infrared_heating_panel ⇒ Object
-
#heater_product_type_tw ⇒ Object
TOWEL WARMER RELATED METHODS.
- #heating_area ⇒ Object
-
#height ⇒ Object
END INFRARED HEATING PANEL RELATED METHODS.
- #infrared_heating_panel_data ⇒ Object
- #ip_rating ⇒ Object
- #material ⇒ Object
- #mirakl_product_category ⇒ Object
- #mounting_orientation ⇒ Object
- #product_weight ⇒ Object
- #programmable ⇒ Object
- #publication ⇒ Object
- #range_infrared_heating_panel ⇒ Object
- #range_tw ⇒ Object
- #room_use_infrared_heating_panel ⇒ Object
- #shape_infrared_heating_panel ⇒ Object
- #thermostat_tw ⇒ Object
- #towel_warmer_data ⇒ Object
- #watts ⇒ Object
- #width ⇒ Object
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_tw ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 226 def # Circular 6 # Curved 1 # Flat 2 # Half moon 8 # Oval 5 # Rectangular 4 # Square 3 # Triangular 7 = item.spec_value(:bar_shape) case when 'Round' 6 when 'Square' 3 else @error_list << "TW Tube shape #{} not mapped for item #{item.sku}." end end |
#color ⇒ Object
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 369 370 371 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 333 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_infrared_heating_panel ⇒ Object
401 402 403 404 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 401 def connectivity_infrared_heating_panel # Not connected object 16 16 end |
#connectivity_tw ⇒ Object
246 247 248 249 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 246 def connectivity_tw # Not connected object 16 16 end |
#core_pack ⇒ Object
190 191 192 193 194 195 196 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 190 def core_pack # Each 3 # Pack 6 # Pair 65 # Set 4 3 end |
#core_product_type ⇒ Object
214 215 216 217 218 219 220 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 214 def core_product_type if item.is_infrared_heating_panel? 12_912 elsif item.is_towel_warmer? 13_120 end end |
#depth ⇒ Object
424 425 426 427 428 429 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 424 def depth depth = item.spec_value(:depth, output_unit: 'mm') return nil if depth.blank? depth.to_i end |
#display_infrared_heating_panel ⇒ Object
298 299 300 301 302 303 304 305 306 307 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 298 def display_infrared_heating_panel # Backlit LCD 65 # Digital 5 # Digital display 125 # LCD 15 # LED 113 # Touchscreen 72 # Without display 86 86 end |
#display_tw ⇒ Object
251 252 253 254 255 256 257 258 259 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 251 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_infrared_heating_panel ⇒ Object
INFRARED HEATING PANEL RELATED METHODS
278 279 280 281 282 283 284 285 286 287 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 278 def facet_infrared_heating_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_tw ⇒ Object
206 207 208 209 210 211 212 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 206 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_data ⇒ Object
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 46 47 48 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 6 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 |
#guarantee ⇒ Object
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 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 158 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_output ⇒ Object
This is expressed in kilowatt hours
411 412 413 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 411 def heat_output item.spec_value(:thermal_power) end |
#heater_infrared_heating_panel ⇒ Object
289 290 291 292 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 289 def heater_infrared_heating_panel # Infrared 21 15 end |
#heater_product_type_tw ⇒ Object
TOWEL WARMER RELATED METHODS
201 202 203 204 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 201 def heater_product_type_tw # Heating Wire 36 end |
#heating_area ⇒ Object
441 442 443 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 441 def heating_area item.spec_value(:heating_area) end |
#height ⇒ Object
END INFRARED HEATING PANEL RELATED METHODS
319 320 321 322 323 324 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 319 def height height = item.spec_value(:height, output_unit: 'mm') return nil if height.blank? height.to_i end |
#infrared_heating_panel_data ⇒ Object
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 128 129 130 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 90 def infrared_heating_panel_data { required: { Facet_product_type: facet_infrared_heating_panel, Heater_product_type: heater_infrared_heating_panel, Type_Range: range_infrared_heating_panel, 'Tech_Heating surface area': heating_area, Product_height: height, Product_width: width, 'Vdesc_Colour group': color, Tech_Material: 6039, Tech_Connectivity: connectivity_infrared_heating_panel, Heat_output: heat_output, Product_weight: product_weight, Tech_Wattage: watts, pdf_product_guide: publication, 'Tech_Room use': room_use_infrared_heating_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_infrared_heating_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 |
#ip_rating ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 140 def return unless (ir = item.spec_output(:ingress_protection_ipxx_rating)) { IP20: '3', IP44: '1', # Towel warmers IP55: '89', IP65: '7', # Infrared heating panels IP66: '12' }.with_indifferent_access[ir] end |
#material ⇒ Object
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 373 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_category ⇒ Object
132 133 134 135 136 137 138 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 132 def mirakl_product_category if item.is_infrared_heating_panel? 'PIM_10550' elsif item.is_towel_warmer? 'PIM_10552' end end |
#mounting_orientation ⇒ Object
309 310 311 312 313 314 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 309 def mounting_orientation # Horizontal 1 # Horizontal or vertical 2 # Vertical 3 2 end |
#product_weight ⇒ Object
415 416 417 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 415 def product_weight item.base_weight_converted(unit: 'kg').round(2) end |
#programmable ⇒ Object
436 437 438 439 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 436 def programmable # Non-programmable 11 11 end |
#publication ⇒ Object
152 153 154 155 156 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 152 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 |
#range_infrared_heating_panel ⇒ Object
294 295 296 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 294 def range_infrared_heating_panel 'Electric Radiant Panel' end |
#range_tw ⇒ Object
222 223 224 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 222 def range_tw 'Electric Towel Warmers' end |
#room_use_infrared_heating_panel ⇒ Object
419 420 421 422 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 419 def room_use_infrared_heating_panel # Bathroom, bedroom, kitchen & living room 76 76 end |
#shape_infrared_heating_panel ⇒ Object
431 432 433 434 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 431 def shape_infrared_heating_panel # Flat 582 582 end |
#thermostat_tw ⇒ Object
261 262 263 264 265 266 267 268 269 270 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 261 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_data ⇒ Object
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 86 87 88 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 50 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': , Bar_shape: , 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 |
#watts ⇒ Object
406 407 408 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 406 def watts item.spec_value(:watts) end |
#width ⇒ Object
326 327 328 329 330 331 |
# File 'app/services/edi/mirakl_seller/castorama/product_data_presenter.rb', line 326 def width width = item.spec_value(:width, output_unit: 'mm') return nil if width.blank? width.to_i end |