Class: Edi::MiraklSeller::Leclerc::ProductDataPresenter

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

Overview

Service object: product data presenter.

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

#brand ⇒ Object



133
134
135
136
# File 'app/services/edi/mirakl_seller/leclerc/product_data_presenter.rb', line 133

def brand
  # WarmlyYours 18092
  'warmlyyours'
end

#color ⇒ Object



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'app/services/edi/mirakl_seller/leclerc/product_data_presenter.rb', line 172

def color
  fetched_color = spec_value(:finish) || spec_value(:color)
  case fetched_color
  when /Polished|Brushed|Stainless|Steel/i
    'inox-15'
  when /Bronze/i
    'bronze-14'
  when /Gold/i
    'dore-14'
  when /Black/i
    'noir-01'
  when /White/i
    'blanc-02'
  when /Mirror|Glass/i
    'argent-15'
  else
    @error_list << "Color #{fetched_color} not mapped for item #{item.sku}."
  end
end

#control_type ⇒ Object



127
128
129
130
131
# File 'app/services/edi/mirakl_seller/leclerc/product_data_presenter.rb', line 127

def control_type
  return unless spec_value(:on_off_switch).to_b

  'bouton_poussoir'
end

#cord_length ⇒ Object



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

def cord_length
  spec_value(:cord_length)
end

#depth ⇒ Object



192
193
194
195
196
197
# File 'app/services/edi/mirakl_seller/leclerc/product_data_presenter.rb', line 192

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

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

def generic_data
  {
    required: {
      categorie: mirakl_product_category,
      shop_sku: sku,
      libelle: name(locale: :fr),
      description: detailed_description_html(locale: :fr),
      ean: ean13,
      image1: images[0]
    },
    optional: {
      image2: images[1],
      image3: images[2],
      image4: images[3],
      image5: images[4],
      image6: images[5],
      image7: images[6],
      url_video: nil,
      reference_fabricant: sku,
      hauteur_emballe: nil,
      largeur_emballe: nil,
      nombre_de_colis: nil,
      poids_emballe: nil,
      unite_poids_emballe: nil,
      unite_mesure_emballe: nil,
      profondeur_emballe: nil,
      plus_produit: nil,
      google_product_category: nil,
      codelec: nil
    }
  }
end

#height ⇒ Object



158
159
160
161
162
163
# File 'app/services/edi/mirakl_seller/leclerc/product_data_presenter.rb', line 158

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

  height.to_i
end

#infrared_heating_panel_data ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
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
# File 'app/services/edi/mirakl_seller/leclerc/product_data_presenter.rb', line 66

def infrared_heating_panel_data
  {
    required: {
      marque: brand
    },
    optional: {
      disponibilite_pieces_detachees: nil,
      details_concernant_garantie: nil,
      puissance_watts: watts,
      notice_utilisation: nil,
      poids: weight,
      unite_poids: weight_unit,
      accessoires_inclus: nil,
      alimentation: volts,
      unite_alimentation: power_unit,
      type_alimentation: power_type,
      arret_automatique: 'No',
      autres_informations: nil,
      part_number: sku,
      fabricant: brand,
      interrupteur_marche_arret: 'No',
      largeur_produit: width,
      hauteur_produit: height,
      unite_mesure_dimension_produit: measure_unit,
      longueur_produit: depth,
      frequence: nil,
      longueur_cordon: cord_length,
      matiere_principale: nil,
      securite: nil,
      label_liste: nil,
      compatible_internet_des_objets: nil,
      garantie_texte: warranty_text,
      garantie_constructeur: warranty_text,
      reprise_des_dechets: nil,
      url_image1_leclerc: nil,
      url_image2_leclerc: nil,
      url_image3_leclerc: nil,
      url_image4_leclerc: nil,
      url_image5_leclerc: nil,
      url_image6_leclerc: nil,
      url_image7_leclerc: nil
    }
  }
end

#measure_unit ⇒ Object



146
147
148
# File 'app/services/edi/mirakl_seller/leclerc/product_data_presenter.rb', line 146

def measure_unit
  'centimetre'
end

#mirakl_product_category ⇒ Object



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

def mirakl_product_category
  if is_infrared_heating_panel?
    'chauffage_panneaux_rayonnant'
  elsif is_towel_warmer?
    'seche_serviette'
  end
end

#power_type ⇒ Object



154
155
156
# File 'app/services/edi/mirakl_seller/leclerc/product_data_presenter.rb', line 154

def power_type
  'secteur'
end

#power_unit ⇒ Object



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

def power_unit
  'volts'
end

#size ⇒ Object



123
124
125
# File 'app/services/edi/mirakl_seller/leclerc/product_data_presenter.rb', line 123

def size
  spec_value(:size, output_unit: 'cm')
end

#towel_warmer_data ⇒ Object



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

def towel_warmer_data
  {
    required: {
      marque: brand,
      couleur: color,
      technologie_de_chauffage: tw_technology,
      puissance_watts: watts,
      dimensions: size
    },
    optional: {
      label_liste: nil,
      reprise_des_dechets: nil,
      idparent: nil,
      type_de_produit_categorie: mirakl_product_category,
      norme_ou_certification: nil,
      garantie_constructeur: warranty_text,
      details_concernant_garantie: nil,
      disponibilite_pieces_detachees: nil,
      garantie_texte: warranty_text,
      programmable: 'No',
      type_commande: control_type,
      classe_protection_electrique: nil,
      securite: nil
    }
  }
end

#tw_technology ⇒ Object



119
120
121
# File 'app/services/edi/mirakl_seller/leclerc/product_data_presenter.rb', line 119

def tw_technology
  'rayonnant'
end

#warranty_text ⇒ Object



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

def warranty_text
  if is_refurbished?
    'La garantie pour les produits reconditionnés est de 1 an à partir de la date d’achat.'
  else
    'Garantie de 3 ans à compter de la date d’achat.'
  end
end

#weight ⇒ Object



138
139
140
# File 'app/services/edi/mirakl_seller/leclerc/product_data_presenter.rb', line 138

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

#weight_unit ⇒ Object



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

def weight_unit
  'kg'
end

#width ⇒ Object



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

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

  width.to_i
end