Class: Edi::MiraklSeller::Bricodepot::ProductDataPresenter

Inherits:
Edi::MiraklSeller::BaseMiraklPresenter show all
Defined in:
app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb

Overview

Service object: product data presenter.

Instance Attribute Summary

Attributes inherited from Edi::MiraklSeller::BaseMiraklPresenter

#image_locales

Attributes inherited from BasePresenter

#current_account, #options, #url_helper

Instance Method Summary collapse

Methods inherited from Edi::MiraklSeller::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



126
127
128
129
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 126

def bar_shape_tw
  # Redonda-Recta 5473
  5473
end

#brandObject



121
122
123
124
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 121

def brand
  # WarmlyYours 18092
  18_092
end

#colorObject



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 160

def color
  fetched_color = spec_value(:finish) || spec_value(:color)
  case fetched_color
  when /Polished|Brushed|Stainless|Steel/i
    16_918
  when /Bronze/i
    13_633
  when /Gold/i
    13_636
  when /Black/i
    2936
  when /White/i
    2930
  when /Mirror|Glass/i
    2940
  else
    @error_list << "Color #{fetched_color} not mapped for item #{item.sku}."
  end
end

#depthObject



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

def depth
  depth = spec_value(:depth, output_unit: 'cm')
  return nil if depth.blank?

  depth.to_i
end

#fix_type_panelObject



136
137
138
139
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 136

def fix_type_panel
  # Tornillos y tacos 5826
  5826
end

#generic_dataObject



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

def generic_data
  {
    required: {
      category: mirakl_product_category,
      shop_sku: ean13,
      name: public_short_name(locale: :es), # Short name because Bricodepot has a 75 character limit
      identifier_brand: brand,
      mirakl_image_1: images[0],
      identifier_ean: ean13,
      'advertising_descripcion_comercial-es_ES': detailed_description_html(locale: :es),
      gpsr_manufaturer_name: 'WarmlyYours B.V.',
      gpsr_2023_compliant: 'Yes',
      gpsr_digital_assets_1: 'No',
      gpsr_digital_assets_2: 'No',
      gpsr_digital_assets_3: 'No',
      gpsr_digital_assets_4: 'No',
      gpsr_digital_assets_5: 'No',
      gpsr_digital_assets_6: 'No',
      gpsr_digital_assets_7: 'No',
      gpsr_digital_assets_8: 'No',
      gpsr_digital_assets_9: 'No'

    },
    optional: {
      'name-pt_PT': public_short_name(locale: :pt),
      weight: product_weight,
      mirakl_image_2: images[1],
      mirakl_image_3: images[2],
      mirakl_image_4: images[3],
      mirakl_image_5: images[4],
      mirakl_image_6: images[5],
      'advertising_descripcion_comercial-pt_PT': detailed_description_html(locale: :pt),
      has_mirakl_offers: nil,
      technical_vendedor: nil,
      resources_marca: 'WarmlyYours'
    }
  }
end

#heating_areaObject



195
196
197
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 195

def heating_area
  spec_value(:heating_area)
end

#heightObject



146
147
148
149
150
151
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 146

def height
  height = spec_value(:height, output_unit: 'cm')
  return nil if height.blank?

  height.to_i
end

#infrared_heating_panel_dataObject



77
78
79
80
81
82
83
84
85
86
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
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 77

def infrared_heating_panel_data
  {
    optional: {
      advertising_modelo: primary_product_line.public_name(locale: :es),
      resources_grupo_color: finish,
      technical_clasificacion_eficiencia_energetica: nil,
      technical_control_temperatura: 'Yes',
      technical_funcion_ventanas_abiertas: 'No',
      technical_funciones: nil,
      technical_grado_proteccion_ip: nil,
      technical_incluye_mando_distancia: 'No',
      technical_material: spec_value(:material),
      technical_numero_elementos: nil,
      technical_opcion_wifi: 'No',
      technical_patas_incluidas: 'No',
      technical_potencia: nil,
      technical_proteccion_contra_sobrecalentamiento: 'Yes',
      technical_proteccion_contra_sobrecarga: 'Yes',
      technical_tamano_estancia: rendered_product_specifications.dig(:heating_area, :output),
      technical_tipo_pantalla: screen_type,
      technical_con_ruedas: 'No',
      technical_tipo_fijacion: fix_type_panel,
      marketplace_alto_producto: height,
      marketplace_ancho_producto: width,
      marketplace_diametro_producto: nil,
      marketplace_fondo_producto: depth,
      marketplace_longitud_producto: nil,
      technical_manual_instrucciones: nil,
      resources_color_producto: color,
      technical_incluye: nil,
      quality_normas: nil,
      quality_fichas_seguridad: nil
    }
  }
end

#instalation_type_twObject



131
132
133
134
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 131

def instalation_type_tw
  # Pared 5914
  5914
end

#mirakl_product_categoryObject



113
114
115
116
117
118
119
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 113

def mirakl_product_category
  if is_infrared_heating_panel?
    '6394'
  elsif is_towel_warmer?
    '6393'
  end
end

#product_weightObject



184
185
186
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 184

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

#screen_typeObject



141
142
143
144
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 141

def screen_type
  # sin pantalla 6007
  6007
end

#towel_warmer_dataObject



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

def towel_warmer_data
  {
    optional: {
      advertising_modelo: primary_product_line.public_name(locale: :es),
      resources_grupo_color: finish,
      technical_clasificacion_eficiencia_energetica: nil,
      technical_funciones: nil,
      technical_grado_proteccion_ip: nil,
      technical_longitud_cable: spec_value(:cord_length),
      technical_potencia: nil,
      technical_proteccion_contra_sobrecalentamiento: 'Yes',
      technical_rango_temperatura_funcionamiento: nil,
      technical_tension: spec_value(:voltage),
      technical_termostato_programable: 'No',
      technical_tipo_barra: bar_shape_tw,
      technical_tipo_instalacion: instalation_type_tw,
      technical_tipo_pantalla: screen_type,
      marketplace_alto_producto: height,
      marketplace_ancho_producto: width,
      marketplace_diametro_producto: nil,
      marketplace_fondo_producto: depth,
      marketplace_longitud_producto: nil,
      technical_manual_instrucciones: nil,
      resources_color_producto: color,
      technical_incluye: nil,
      quality_normas: nil,
      technical_categoria_complementaria: nil,
      quality_fichas_seguridad: nil
    }
  }
end

#wattsObject



180
181
182
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 180

def watts
  spec_value(:watts)
end

#widthObject



153
154
155
156
157
158
# File 'app/services/edi/mirakl_seller/bricodepot/product_data_presenter.rb', line 153

def width
  width = spec_value(:width, output_unit: 'cm')
  return nil if width.blank?

  width.to_i
end