@bytebrand/export-cars 1.21.7 → 1.21.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +8 -8
- package/.eslintignore +1 -1
- package/.eslintrc.js +24 -24
- package/.prettierrc.js +7 -7
- package/README.md +65 -65
- package/dist/configs/index.d.ts +1 -0
- package/dist/configs/index.js +1 -0
- package/dist/configs/index.js.map +1 -1
- package/dist/configs/santander.config.d.ts +5 -0
- package/dist/configs/santander.config.js +18 -0
- package/dist/configs/santander.config.js.map +1 -0
- package/dist/enums/export-type.enum.d.ts +1 -0
- package/dist/enums/export-type.enum.js +1 -0
- package/dist/enums/export-type.enum.js.map +1 -1
- package/dist/export.command.js +1 -1
- package/dist/export.command.js.map +1 -1
- package/dist/export.schema.d.ts +6 -2
- package/dist/export.schema.js +4 -0
- package/dist/export.schema.js.map +1 -1
- package/dist/exporters/index.d.ts +1 -0
- package/dist/exporters/index.js +1 -0
- package/dist/exporters/index.js.map +1 -1
- package/dist/exporters/santander.exporter.d.ts +12 -0
- package/dist/exporters/santander.exporter.js +63 -0
- package/dist/exporters/santander.exporter.js.map +1 -0
- package/dist/formats/auto24-xml.builder.js +2 -2
- package/dist/formats/google-xml.builder.js +3 -3
- package/dist/formats/modix-xml.builder.js +2 -2
- package/dist/formats/ooyyo-xml.builder.js +1 -1
- package/dist/formats/santander-csv.builder.d.ts +6 -0
- package/dist/formats/santander-csv.builder.js +17 -0
- package/dist/formats/santander-csv.builder.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/nest-cli.json +5 -5
- package/package.json +61 -61
- package/src/app.module.ts +38 -38
- package/src/configs/alleskralle.config.ts +15 -15
- package/src/configs/as24.config.ts +13 -13
- package/src/configs/auto24.config.ts +15 -15
- package/src/configs/autoboerse.config.ts +16 -16
- package/src/configs/autouncle.config.ts +14 -14
- package/src/configs/awin.config.ts +15 -15
- package/src/configs/by-owner.config.ts +14 -14
- package/src/configs/config.ts +83 -83
- package/src/configs/criteo.config.ts +17 -17
- package/src/configs/dasparking.config.ts +15 -15
- package/src/configs/eauto.config.ts +15 -15
- package/src/configs/evium.config.ts +18 -18
- package/src/configs/facebook-shop.config.ts +16 -16
- package/src/configs/fb.config.ts +16 -16
- package/src/configs/google.config.ts +14 -14
- package/src/configs/index.ts +22 -21
- package/src/configs/kleinanzeigeFocus.config.ts +14 -14
- package/src/configs/marktde.config.ts +18 -18
- package/src/configs/meinstadt.config.ts +15 -15
- package/src/configs/mitula.config.ts +14 -14
- package/src/configs/ooyyo.config.ts +15 -15
- package/src/configs/santander.config.ts +15 -0
- package/src/configs/trovit.config.ts +14 -14
- package/src/configs/yescar.config.ts +17 -17
- package/src/constants/autouncle.contants.ts +4 -4
- package/src/constants/fb.constants.ts +7 -7
- package/src/constants/index.ts +1 -1
- package/src/constants/modix/body-color-name.constant.ts +20 -20
- package/src/constants/modix/category.constant.ts +14 -14
- package/src/constants/modix/fuel.constant.ts +14 -14
- package/src/constants/modix/index.ts +7 -7
- package/src/constants/modix/manufacturers.constant.ts +7498 -7498
- package/src/constants/modix/transmission.constant.ts +8 -8
- package/src/constants/modix/usage-type.constant.ts +13 -13
- package/src/constants/modix/vehicle-class.constant.ts +17 -17
- package/src/enums/environment.enum.ts +5 -5
- package/src/enums/export-type.enum.ts +33 -32
- package/src/enums/file-types.enum.ts +8 -8
- package/src/enums/image-type.enum.ts +4 -4
- package/src/enums/index.ts +4 -4
- package/src/export.command.ts +37 -37
- package/src/export.schema.ts +134 -128
- package/src/exporters/as24.exporter.ts +69 -69
- package/src/exporters/auto24.exporter.ts +48 -48
- package/src/exporters/autouncle.exporter.ts +60 -60
- package/src/exporters/awin.exporter.ts +47 -47
- package/src/exporters/by-owner.exporter.ts +44 -44
- package/src/exporters/facebook-shop.exporter.ts +51 -51
- package/src/exporters/fb.exporter.ts +52 -52
- package/src/exporters/google.exporter.ts +45 -45
- package/src/exporters/index.ts +15 -14
- package/src/exporters/meinstadt.exporter.ts +55 -55
- package/src/exporters/mobile.exporter.ts +64 -64
- package/src/exporters/modix.exporter.ts +56 -56
- package/src/exporters/ooyyo.exporter.ts +48 -48
- package/src/exporters/rubrikk.exporter.ts +53 -53
- package/src/exporters/santander.exporter.ts +50 -0
- package/src/exporters/trovit.exporter.ts +51 -51
- package/src/formats/auto24-xml.builder.ts +54 -54
- package/src/formats/autouncle-json.builder.ts +20 -20
- package/src/formats/awin-csv.builder.ts +16 -16
- package/src/formats/facebook-shop.builder.ts +69 -69
- package/src/formats/fb-xml.builder.ts +71 -71
- package/src/formats/google-xml.builder.ts +35 -35
- package/src/formats/index.ts +5 -5
- package/src/formats/meinstadt-json.builder.ts +19 -19
- package/src/formats/modix-xml.builder.ts +180 -180
- package/src/formats/ooyyo-xml.builder.ts +48 -48
- package/src/formats/rubrikk-xml.builder.ts +27 -27
- package/src/formats/santander-csv.builder.ts +15 -0
- package/src/formats/trovit-xml.builder.ts +44 -44
- package/src/interfaces/atributes-wrap-item.intreface.ts +6 -6
- package/src/interfaces/dealers-mapping.interface.ts +7 -7
- package/src/interfaces/description.interface.ts +24 -24
- package/src/interfaces/export-item.interface.ts +366 -366
- package/src/interfaces/exporter.interface.ts +3 -3
- package/src/interfaces/index.ts +3 -3
- package/src/interfaces/input.interface.ts +6 -6
- package/src/interfaces/mapping-rules.interface.ts +11 -11
- package/src/interfaces/modix/index.ts +1 -1
- package/src/interfaces/modix/modix-item-list.interface.ts +5 -5
- package/src/interfaces/params.interface.ts +13 -13
- package/src/interfaces/rule-parser.interface.ts +3 -3
- package/src/main.ts +14 -14
- package/src/rules/abstract.rule.ts +37 -37
- package/src/rules/date.rule.ts +19 -19
- package/src/rules/number.rule.ts +15 -15
- package/src/rules/string.rule.ts +8 -8
- package/src/services/car.service.ts +49 -49
- package/src/services/config.service.ts +15 -15
- package/src/services/images.service.ts +207 -207
- package/src/services/index.ts +9 -9
- package/src/services/loader.service.ts +29 -29
- package/src/services/mapping.service.ts +91 -91
- package/src/services/request.service.ts +44 -44
- package/src/services/rules.service.ts +61 -61
- package/src/services/transformer.service.ts +129 -129
- package/src/services/user.service.ts +57 -57
- package/src/transformers/as24.transformer.ts +253 -253
- package/src/transformers/auto24.transfomer.ts +155 -155
- package/src/transformers/autouncle.transformer.ts +236 -236
- package/src/transformers/awin.transformer.ts +193 -193
- package/src/transformers/by-owner.transformer.ts +354 -354
- package/src/transformers/facebook-shop.transformer.ts +93 -93
- package/src/transformers/fb-description.transformer.ts +316 -316
- package/src/transformers/fb-equipment.transformer.ts +161 -161
- package/src/transformers/fb.transformer.ts +655 -655
- package/src/transformers/google.transformer.ts +169 -169
- package/src/transformers/index.ts +5 -5
- package/src/transformers/meinstadt.transformer.ts +92 -92
- package/src/transformers/mobile.transformer.ts +482 -482
- package/src/transformers/modix.transformer.ts +227 -227
- package/src/transformers/ooyyo.transformer.ts +109 -109
- package/src/transformers/rubrikk.transformer.ts +200 -200
- package/src/transformers/trovit.transformer.ts +63 -63
- package/src/utils/converter.utils.ts +15 -15
- package/src/utils/index.ts +2 -2
- package/src/utils/validator.utils.ts +7 -7
- package/tsconfig.build.json +4 -4
- package/tsconfig.json +29 -29
|
@@ -1,354 +1,354 @@
|
|
|
1
|
-
import { get, toString, trim, toSafeInteger, toNumber, isString } from 'lodash';
|
|
2
|
-
import { Translator, TranslatorExtended } from '@bytebrand/schema-tools';
|
|
3
|
-
import { de, deVehicleDetailsPage, deVehicleProps } from '@bytebrand/i18n-dictionaries';
|
|
4
|
-
import { DataSchemes } from '@bytebrand/car-schema';
|
|
5
|
-
import { Injectable } from '@nestjs/common';
|
|
6
|
-
import * as moment from 'moment';
|
|
7
|
-
|
|
8
|
-
type transformFn = (car: DataSchemes.Car, translator: TranslatorExtended) => string;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated 02.03.2022
|
|
12
|
-
*/
|
|
13
|
-
@Injectable()
|
|
14
|
-
export class ByOwnerTransformer {
|
|
15
|
-
private readonly translator: TranslatorExtended = new TranslatorExtended({
|
|
16
|
-
...de,
|
|
17
|
-
...deVehicleProps,
|
|
18
|
-
...deVehicleDetailsPage,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
transform(car: DataSchemes.Car, index: number): unknown {
|
|
22
|
-
const mapping = {
|
|
23
|
-
UID: '',
|
|
24
|
-
ID: '_id',
|
|
25
|
-
autode_ID: 'metaData.vehicleId',
|
|
26
|
-
|
|
27
|
-
price: 'price.currentSalesPrice',
|
|
28
|
-
'(old price) strike price': 'price.wasPrice',
|
|
29
|
-
rate: (car: DataSchemes.Car) => car.rate.monthlyInstallment,
|
|
30
|
-
'discount in %': this.mapToNumber('price.historyPriceDifferencePerCent', 1, 0),
|
|
31
|
-
'discount in €': this.mapToNumber('price.historyPriceDifference', 1, 0),
|
|
32
|
-
'first_installment in €': (car: DataSchemes.Car) => car.rate.firstInstallment,
|
|
33
|
-
'amount of month': (car: DataSchemes.Car) => car.rate.paybackPeriod,
|
|
34
|
-
|
|
35
|
-
Name: (car: DataSchemes.Car): string => {
|
|
36
|
-
const make = toString(get(car, 'mainData.make', ''));
|
|
37
|
-
const model = toString(get(car, 'mainData.model', ''));
|
|
38
|
-
const subModel = toString(get(car, 'mainData.subModel', ''));
|
|
39
|
-
return trim([make, model, subModel].join(' '));
|
|
40
|
-
},
|
|
41
|
-
make: 'mainData.make',
|
|
42
|
-
model: 'mainData.model',
|
|
43
|
-
Name_Sonderserie: 'mainData.subModel',
|
|
44
|
-
PS: 'engineData.powerPS',
|
|
45
|
-
EngineVolume: this.mapToNumber('engineData.cubicCapacity'),
|
|
46
|
-
|
|
47
|
-
consumptioncombined_Benzin: this.mapToValueDependOnPath(
|
|
48
|
-
'consumption.consumptionCombined',
|
|
49
|
-
'consumption.fuel',
|
|
50
|
-
'selector_fuel_petrol',
|
|
51
|
-
),
|
|
52
|
-
consumptioncombined_Diesel: this.mapToValueDependOnPath(
|
|
53
|
-
'consumption.consumptionCombined',
|
|
54
|
-
'consumption.fuel',
|
|
55
|
-
'selector_fuel_diesel',
|
|
56
|
-
),
|
|
57
|
-
'consumptioncombined_Hybrid(Elektro/Benzin)': this.mapToValueDependOnPath(
|
|
58
|
-
'consumption.consumptionCombined',
|
|
59
|
-
'consumption.fuel',
|
|
60
|
-
'selector_fuel_hybridElectricalPetrol',
|
|
61
|
-
),
|
|
62
|
-
'consumptioncombined_Hybrid(Elektro/Diesel)': this.mapToValueDependOnPath(
|
|
63
|
-
'consumption.consumptionCombined',
|
|
64
|
-
'consumption.fuel',
|
|
65
|
-
'selector_fuel_hybridElectricalDiesel',
|
|
66
|
-
),
|
|
67
|
-
consumptioncombined_Gemisch: this.mapToValueDependOnPath(
|
|
68
|
-
'consumption.consumptionCombined',
|
|
69
|
-
'consumption.fuel',
|
|
70
|
-
'selector_fuel_ethanol',
|
|
71
|
-
),
|
|
72
|
-
consumptioncombined_Erdgas: this.mapToValueDependOnPath(
|
|
73
|
-
'consumption.consumptionCombined',
|
|
74
|
-
'consumption.fuel',
|
|
75
|
-
'selector_fuel_naturalGas',
|
|
76
|
-
),
|
|
77
|
-
consumptioncombined_Elektro: this.mapToValueDependOnPath(
|
|
78
|
-
'consumption.consumptionCombined',
|
|
79
|
-
'consumption.fuel',
|
|
80
|
-
'selector_fuel_electrical',
|
|
81
|
-
),
|
|
82
|
-
consumptioncombined_Autogas: this.mapToValueDependOnPath(
|
|
83
|
-
'consumption.consumptionCombined',
|
|
84
|
-
'consumption.fuel',
|
|
85
|
-
'selector_fuel_carGas',
|
|
86
|
-
),
|
|
87
|
-
consumptioncombined_Ethanol: this.mapToValueDependOnPath(
|
|
88
|
-
'consumption.consumptionCombined',
|
|
89
|
-
'consumption.fuel',
|
|
90
|
-
'selector_fuel_hydrogen',
|
|
91
|
-
),
|
|
92
|
-
consumptioncombined_Wasserstoff: '',
|
|
93
|
-
|
|
94
|
-
constructionYear: 'mainData.constructionYear',
|
|
95
|
-
first_registration: (car: DataSchemes.Car) => {
|
|
96
|
-
const val = get(car, 'mainData.firstRegistration');
|
|
97
|
-
return moment(toSafeInteger(val) * 1000).format('MM/YYYY');
|
|
98
|
-
},
|
|
99
|
-
Condition_New: this.mapToValue('mainData.condition', 'selector_condition_new', 'Neuwagen'),
|
|
100
|
-
Condition_Used: this.mapToValue('mainData.condition', 'selector_condition_used', 'Gebraucht'),
|
|
101
|
-
Mileage: 'mainData.mileage',
|
|
102
|
-
Amount_Owner: this.mapToNumber('mainData.numberOfPreviousOwners', 1, 0),
|
|
103
|
-
highSpeed: 'engineData.highSpeed',
|
|
104
|
-
cylinders: 'engineData.cylinders',
|
|
105
|
-
|
|
106
|
-
cylinders_word: (car: DataSchemes.Car) => {
|
|
107
|
-
const map = {
|
|
108
|
-
1: 'Ein',
|
|
109
|
-
2: 'Zwei',
|
|
110
|
-
3: 'Drei',
|
|
111
|
-
4: 'Vier',
|
|
112
|
-
5: 'Fünf',
|
|
113
|
-
6: 'Sechs',
|
|
114
|
-
7: 'Sieben',
|
|
115
|
-
8: 'Acht',
|
|
116
|
-
9: 'Neun',
|
|
117
|
-
10: 'Zehn',
|
|
118
|
-
12: 'Zwölf',
|
|
119
|
-
14: 'Vierzehn',
|
|
120
|
-
16: 'Sechzehn',
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const cylinders = get(car, 'engineData.cylinders');
|
|
124
|
-
if (!cylinders) {
|
|
125
|
-
return '';
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return map[toSafeInteger(cylinders)];
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
Drivetype_Heckantrieb: this.mapToValue(
|
|
132
|
-
'driveSuspension.driveType',
|
|
133
|
-
'selector_driveType_rearWheelDrive',
|
|
134
|
-
'Heckantrieb',
|
|
135
|
-
),
|
|
136
|
-
Drivetype_Frontantrieb: this.mapToValue(
|
|
137
|
-
'driveSuspension.driveType',
|
|
138
|
-
'selector_driveType_frontWheelDrive',
|
|
139
|
-
'Frontantrieb',
|
|
140
|
-
),
|
|
141
|
-
Drivetype_allrad: this.mapToValue('driveSuspension.driveType', 'selector_driveType_allWheelDrive', 'Allrad'),
|
|
142
|
-
weight: this.mapToNumber('sizeVolumeWeight.emptyWeight'),
|
|
143
|
-
length: this.mapToNumber('sizeVolumeWeight.length', 10, 1),
|
|
144
|
-
gearbox_manuell: this.mapToValue('driveSuspension.gearbox', 'selector_gearbox_manualShift', 'Handschaltung'),
|
|
145
|
-
gearbox_automatik: this.mapToValue('driveSuspension.gearbox', 'selector_gearbox_automatic', 'Automatik'),
|
|
146
|
-
gearbox_semiAutomatik: this.mapToValue(
|
|
147
|
-
'driveSuspension.gearbox',
|
|
148
|
-
'selector_gearbox_semiAutomatic',
|
|
149
|
-
'Semi Automatik',
|
|
150
|
-
),
|
|
151
|
-
gearbox_unknown: this.mapToValue('driveSuspension.gearbox', 'selector_unknown', 'unknown'),
|
|
152
|
-
|
|
153
|
-
acceleration100: 'engineData.acceleration100',
|
|
154
|
-
|
|
155
|
-
gears_automatik: (car: DataSchemes.Car) => {
|
|
156
|
-
const box = get(car, 'driveSuspension.gearbox');
|
|
157
|
-
if (box === 'selector_gearbox_automatic' || box === 'selector_gearbox_semiAutomatic') {
|
|
158
|
-
return get(car, 'driveSuspension.gears');
|
|
159
|
-
}
|
|
160
|
-
return '';
|
|
161
|
-
},
|
|
162
|
-
gears_Manuell: (car: DataSchemes.Car) => {
|
|
163
|
-
const box = get(car, 'driveSuspension.gearbox');
|
|
164
|
-
if (box === 'selector_gearbox_manualShift') {
|
|
165
|
-
return get(car, 'driveSuspension.gears');
|
|
166
|
-
}
|
|
167
|
-
return '';
|
|
168
|
-
},
|
|
169
|
-
fuel_Benzin: this.mapToValue('consumption.fuel', 'selector_fuel_petrol', 'Benzin'),
|
|
170
|
-
fuel_Diesel: this.mapToValue('consumption.fuel', 'selector_fuel_diesel', 'Diesel'),
|
|
171
|
-
'fuel_Hybrid (Elektro/Benzin)': this.mapToValue(
|
|
172
|
-
'consumption.fuel',
|
|
173
|
-
'selector_fuel_hybridElectricalPetrol',
|
|
174
|
-
'Hybrid (Elektro/Benzin)',
|
|
175
|
-
),
|
|
176
|
-
'fuel_Hybrid (Elektro/Diesel)': this.mapToValue(
|
|
177
|
-
'consumption.fuel',
|
|
178
|
-
'selector_fuel_hybridElectricalDiesel',
|
|
179
|
-
'Hybrid (Elektro/Diesel)',
|
|
180
|
-
),
|
|
181
|
-
fuel_Elektro: this.mapToValue('consumption.fuel', 'selector_fuel_electrical', 'Elektro'),
|
|
182
|
-
fuel_autogas: this.mapToValue('consumption.fuel', 'selector_fuel_carGas', 'autogas'),
|
|
183
|
-
fuel_Erdgas: this.mapToValue('consumption.fuel', 'selector_fuel_naturalGas', 'Erdgas'),
|
|
184
|
-
fuel_Ethanol: this.mapToValue('consumption.fuel', 'selector_fuel_ethanol', 'Ethanol'),
|
|
185
|
-
fuel_Gemisch: this.mapToValue('consumption.fuel', 'selector_fuel_hydrogen', 'Ethanol'),
|
|
186
|
-
fuel_unknown: this.mapToValue('consumption.fuel', 'selector_unknown', 'unknown'),
|
|
187
|
-
CO2: 'environmentEmissions.co2',
|
|
188
|
-
doors: 'mainData.doors',
|
|
189
|
-
seats: 'mainData.seats',
|
|
190
|
-
category_Kleinwagen: this.mapToValue('mainData.category', 'selector_category_compact', 'Kleinwagen'),
|
|
191
|
-
Category_Limousine: this.mapToValue('mainData.category', 'selector_category_sedan', 'Limousine'),
|
|
192
|
-
category_Kombi: this.mapToValue('mainData.category', 'selector_category_combi', 'Kombi'),
|
|
193
|
-
'category_SUV/Geländewagen': this.mapToValue('mainData.category', 'selector_category_suv', 'SUV'),
|
|
194
|
-
category_Transporter: this.mapToValue('mainData.category', 'selector_category_transporter', 'Transporter'),
|
|
195
|
-
// tslint:disable-next-line
|
|
196
|
-
category_Coupé: this.mapToValue('mainData.category', 'selector_category_coupe', 'Coupé'),
|
|
197
|
-
Category_cabrio: this.mapToValue('mainData.category', 'selector_category_convertible', 'cabrio'),
|
|
198
|
-
category_Pickup: this.mapToValue('mainData.category', 'selector_category_transporter', 'Pickup'),
|
|
199
|
-
category_Van: this.mapToValue('mainData.category', 'selector_category_van|selector_category_minibus', 'Van'),
|
|
200
|
-
torque_in_norm: 'engineData.torque',
|
|
201
|
-
count_of_airbags: 'airbags.airbagCount',
|
|
202
|
-
Fahrer_Airbag: this.checkInArray('airbags.airbag', 'selector_airbag_driver', 'Fahrerairbag'),
|
|
203
|
-
Beifahrer_Airbag: this.checkInArray('airbags.airbag', 'selector_airbag_passenger', 'Beifahrerairbag'),
|
|
204
|
-
Kopf_Airbag: this.checkInArray('airbags.airbag', 'selector_airbag_head', 'Kopfairbag'),
|
|
205
|
-
ABS: this.checkBoolean('assistants.abs', 'ABS'),
|
|
206
|
-
ESP: this.checkBoolean('assistants.esp', 'ESP'),
|
|
207
|
-
Traktionskontrolle: this.checkBoolean('assistants.tractionControlSystem', 'Traktionskontrolle'),
|
|
208
|
-
Spurhalteassistent: this.checkBoolean('assistants.laneAssistant', 'Spurhalteassistent'),
|
|
209
|
-
Spurwechselassistent: this.checkBoolean('assistants.laneAssistant', 'Spurwechselassistent'),
|
|
210
|
-
'Bi-Xenon_Licht': this.checkBoolean('lights.xenonHeadlights', 'Bi-Xenon-Licht'),
|
|
211
|
-
Tagfahrlicht: this.checkBoolean(
|
|
212
|
-
'lights.daytimeRunningLights|lights.daytimeRunningLightsLED',
|
|
213
|
-
'Spurhalteassistent',
|
|
214
|
-
),
|
|
215
|
-
'LED-Scheinwerfer': this.checkBoolean('lights.daytimeRunningLightsLED', 'LED-Scheinwerfer'),
|
|
216
|
-
'LED Nebel': this.checkBoolean('lights.frontFogLights', 'LED-Nebelscheinwerfer'),
|
|
217
|
-
Xenon: this.checkBoolean('lights.xenonHeadlights', 'Xenonscheinwerfer'),
|
|
218
|
-
Servolenkung: this.checkBoolean('assistants.powerAssistedSteering', 'Servolenkung'),
|
|
219
|
-
Zentralverriegelung: this.checkBoolean('doors.centralLocking', 'Zentralverriegelung'),
|
|
220
|
-
Keyless_Go: this.checkBoolean('doors.keylessEntry', 'Keyless-Go'),
|
|
221
|
-
elektrische_Heckklappe: this.checkBoolean('doors.electricTailGate', 'elektrische Heckklappe'),
|
|
222
|
-
Klimaanlage: this.checkBoolean('climatisation.selector_none', 'Klimaanlage', false),
|
|
223
|
-
Klimaautomatik: this.checkBoolean('climatisation.selector_climatisation_automaticAirCondition', 'Klimaautomatik'),
|
|
224
|
-
'2_Zonen_Klimautomatik': this.checkBoolean(
|
|
225
|
-
'climatisation.selector_climatisation_automaticAirCondition',
|
|
226
|
-
'2-Zonen-Klimautomatik',
|
|
227
|
-
),
|
|
228
|
-
'3_Zonen_Klimaautomatik': this.checkBoolean(
|
|
229
|
-
'climatisation.selector_climatisation_automaticAirCondition',
|
|
230
|
-
'3-Zonen-Klimaautomatik',
|
|
231
|
-
),
|
|
232
|
-
'4_Zonen_Klimaautomatik': this.checkBoolean(
|
|
233
|
-
'climatisation.selector_climatisation_automaticAirCondition',
|
|
234
|
-
'4-Zonen-Klimaautomatik',
|
|
235
|
-
),
|
|
236
|
-
Multifunktionslenkrad: this.checkBoolean('wheel.multifunctionalWheel', 'Multifunktionslenkrad'),
|
|
237
|
-
Lenkradheizung: this.checkBoolean('wheel.heatedSteeringWheel', 'Lenkradheizung'),
|
|
238
|
-
Sitzheizung: this.checkBoolean('heatingCooling.auxiliaryHeating', 'Ja'),
|
|
239
|
-
Navigationssystem: this.checkBoolean('multimedia.navigationSystem', 'Navigationssystem'),
|
|
240
|
-
Sprachsteuerung: this.checkBoolean('multimedia.voiceControl', 'Sprachsteuerung'),
|
|
241
|
-
Start_Stop_Automatik: this.checkBoolean('engineData.startStopSystem', 'Start/Stop-Automatik'),
|
|
242
|
-
USB_Anschluss: this.checkBoolean('multimedia.usbInterface', 'USB-Anschluss'),
|
|
243
|
-
'USB_Schnittstelle /Bluetooth': this.checkBoolean('multimedia.bluetooth', 'USB_Schnittstelle /Bluetooth'),
|
|
244
|
-
max_emission_category: this.mapSelection('environmentEmissions.emissionClass'),
|
|
245
|
-
Seitenairbag:
|
|
246
|
-
this.checkInArray('airbags.airbag', 'selector_airbag_frontSideAndOther', 'Seitenairbag') ||
|
|
247
|
-
this.checkInArray('airbags.airbag', 'selector_airbag_frontAndSide', 'Seitenairbag'),
|
|
248
|
-
min_tank: 'sizeVolumeWeight.fuelCapacity',
|
|
249
|
-
Varnish: this.mapSelection('exterior.exteriorColor'),
|
|
250
|
-
Varnish_make: 'exterior.manufacturerColorName',
|
|
251
|
-
Interieur_Color: this.mapSelection('interior.interiorColor'),
|
|
252
|
-
Upholstery: this.mapSelection('interior.interiorType'),
|
|
253
|
-
accident_free: this.checkBoolean('mainData.accidentDamaged', 'Unfallfrei', false),
|
|
254
|
-
not_accident_free: this.checkBoolean('mainData.accidentDamaged', 'Beschädigt'),
|
|
255
|
-
Availability: (car: DataSchemes.Car) => {
|
|
256
|
-
const val = get(car, 'offer.availabilityMode');
|
|
257
|
-
if (val === 'selector_availabilityMode_always') return 'Sofort';
|
|
258
|
-
const date = get(car, 'offer.availabilityFrom');
|
|
259
|
-
return moment(toSafeInteger(date) * 1000).format('DD.MM.YYYY');
|
|
260
|
-
},
|
|
261
|
-
Parkassistent: (car: DataSchemes.Car) => {
|
|
262
|
-
const parks = get(car, 'assistants.parkingAssistants', []).filter(
|
|
263
|
-
(selector: string) => selector !== 'selector_unknown',
|
|
264
|
-
);
|
|
265
|
-
return parks.length ? 'Parkassistent' : '';
|
|
266
|
-
},
|
|
267
|
-
Freisprechanlage: this.checkBoolean('multimedia.handsFreePhoneSystem', 'Freisprechanlage'),
|
|
268
|
-
Car_Play: this.checkBoolean('multimedia.carplay', 'Car Play'),
|
|
269
|
-
Garantie: this.checkBoolean('offer.warranty', 'Garantie'),
|
|
270
|
-
Scheckheftgepflegt: this.checkBoolean('careService.fullServiceHistory', 'Scheckheftgepflegt'),
|
|
271
|
-
Regensenor: this.checkBoolean('assistants.automaticRainSensor', 'Regensenor'),
|
|
272
|
-
Tempomat: this.checkBoolean('assistants.cruiseControl', 'Tempomat'),
|
|
273
|
-
Panoramaschiebedach: this.checkBoolean('window.panoramaFrontWindow', 'Panoramaschiebedach'),
|
|
274
|
-
HU_Date: (car: DataSchemes.Car) => {
|
|
275
|
-
const date = get(car, 'careService.generalInspection');
|
|
276
|
-
if (!date) {
|
|
277
|
-
return '';
|
|
278
|
-
}
|
|
279
|
-
return moment(toSafeInteger(date) * 1000).format('DD.MM.YYYY');
|
|
280
|
-
},
|
|
281
|
-
Abstandsregeltempomat: this.checkBoolean('assistants.adaptiveCruiseControl', 'Abstandsregeltempomat'),
|
|
282
|
-
Verkehrszeichen_Erkennung: this.checkBoolean('assistants.trafficSignRecognition', 'Verkehrszeichen-Erkennung'),
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
return Object.entries(mapping)
|
|
286
|
-
.reverse()
|
|
287
|
-
.reduce(
|
|
288
|
-
(transformed, [key, value]) => {
|
|
289
|
-
return { [key]: this.transformValue(car, value as string), ...transformed };
|
|
290
|
-
},
|
|
291
|
-
{ UID: index },
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
private transformValue(car: DataSchemes.Car, value: string | transformFn): unknown {
|
|
296
|
-
if (isString(value)) {
|
|
297
|
-
return get(car, value);
|
|
298
|
-
}
|
|
299
|
-
return value(car, this.translator);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
private mapToValue(path: string, selection: string, value: string): (car: DataSchemes.Car) => string {
|
|
303
|
-
return (car: DataSchemes.Car) => {
|
|
304
|
-
const cond = get(car, path);
|
|
305
|
-
const selections = selection.split('|');
|
|
306
|
-
return selections.some(sel => sel === cond) ? value : '';
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
private mapToNumber(path: string, divider = 1000, toFix = 1): (car: DataSchemes.Car) => number | '' {
|
|
311
|
-
return (car: DataSchemes.Car) => {
|
|
312
|
-
const data = get(car, path);
|
|
313
|
-
const value = toNumber((toSafeInteger(data) / divider).toFixed(toFix));
|
|
314
|
-
return value > 0.0 ? value : '';
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
private mapToValueDependOnPath(
|
|
319
|
-
valuePath: string,
|
|
320
|
-
conditionPath: string,
|
|
321
|
-
selection: string,
|
|
322
|
-
): (car: DataSchemes.Car) => any {
|
|
323
|
-
return (car: DataSchemes.Car) => {
|
|
324
|
-
const value = get(car, valuePath);
|
|
325
|
-
const cond = get(car, conditionPath);
|
|
326
|
-
return cond === selection ? value : '';
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
private checkBoolean(path: string, value: string, boolean = true): (car: DataSchemes.Car) => string {
|
|
331
|
-
return (car: DataSchemes.Car) => {
|
|
332
|
-
return path
|
|
333
|
-
.split('|')
|
|
334
|
-
.map(path => get(car, path))
|
|
335
|
-
.some(cond => cond === boolean)
|
|
336
|
-
? value
|
|
337
|
-
: '';
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
private checkInArray(path: string, selector: string, value: string): (car: DataSchemes.Car) => string {
|
|
342
|
-
return (car: DataSchemes.Car) => {
|
|
343
|
-
const cond = get(car, path) as string[];
|
|
344
|
-
return cond.some((sel: string) => sel === selector) ? value : '';
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
private mapSelection(path: string): (car: DataSchemes.Car, translator: Translator) => any {
|
|
349
|
-
return (car: DataSchemes.Car, translator: Translator) => {
|
|
350
|
-
const selection = get(car, path);
|
|
351
|
-
return translator.translateVal(selection);
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
}
|
|
1
|
+
import { get, toString, trim, toSafeInteger, toNumber, isString } from 'lodash';
|
|
2
|
+
import { Translator, TranslatorExtended } from '@bytebrand/schema-tools';
|
|
3
|
+
import { de, deVehicleDetailsPage, deVehicleProps } from '@bytebrand/i18n-dictionaries';
|
|
4
|
+
import { DataSchemes } from '@bytebrand/car-schema';
|
|
5
|
+
import { Injectable } from '@nestjs/common';
|
|
6
|
+
import * as moment from 'moment';
|
|
7
|
+
|
|
8
|
+
type transformFn = (car: DataSchemes.Car, translator: TranslatorExtended) => string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated 02.03.2022
|
|
12
|
+
*/
|
|
13
|
+
@Injectable()
|
|
14
|
+
export class ByOwnerTransformer {
|
|
15
|
+
private readonly translator: TranslatorExtended = new TranslatorExtended({
|
|
16
|
+
...de,
|
|
17
|
+
...deVehicleProps,
|
|
18
|
+
...deVehicleDetailsPage,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
transform(car: DataSchemes.Car, index: number): unknown {
|
|
22
|
+
const mapping = {
|
|
23
|
+
UID: '',
|
|
24
|
+
ID: '_id',
|
|
25
|
+
autode_ID: 'metaData.vehicleId',
|
|
26
|
+
|
|
27
|
+
price: 'price.currentSalesPrice',
|
|
28
|
+
'(old price) strike price': 'price.wasPrice',
|
|
29
|
+
rate: (car: DataSchemes.Car) => car.rate.monthlyInstallment,
|
|
30
|
+
'discount in %': this.mapToNumber('price.historyPriceDifferencePerCent', 1, 0),
|
|
31
|
+
'discount in €': this.mapToNumber('price.historyPriceDifference', 1, 0),
|
|
32
|
+
'first_installment in €': (car: DataSchemes.Car) => car.rate.firstInstallment,
|
|
33
|
+
'amount of month': (car: DataSchemes.Car) => car.rate.paybackPeriod,
|
|
34
|
+
|
|
35
|
+
Name: (car: DataSchemes.Car): string => {
|
|
36
|
+
const make = toString(get(car, 'mainData.make', ''));
|
|
37
|
+
const model = toString(get(car, 'mainData.model', ''));
|
|
38
|
+
const subModel = toString(get(car, 'mainData.subModel', ''));
|
|
39
|
+
return trim([make, model, subModel].join(' '));
|
|
40
|
+
},
|
|
41
|
+
make: 'mainData.make',
|
|
42
|
+
model: 'mainData.model',
|
|
43
|
+
Name_Sonderserie: 'mainData.subModel',
|
|
44
|
+
PS: 'engineData.powerPS',
|
|
45
|
+
EngineVolume: this.mapToNumber('engineData.cubicCapacity'),
|
|
46
|
+
|
|
47
|
+
consumptioncombined_Benzin: this.mapToValueDependOnPath(
|
|
48
|
+
'consumption.consumptionCombined',
|
|
49
|
+
'consumption.fuel',
|
|
50
|
+
'selector_fuel_petrol',
|
|
51
|
+
),
|
|
52
|
+
consumptioncombined_Diesel: this.mapToValueDependOnPath(
|
|
53
|
+
'consumption.consumptionCombined',
|
|
54
|
+
'consumption.fuel',
|
|
55
|
+
'selector_fuel_diesel',
|
|
56
|
+
),
|
|
57
|
+
'consumptioncombined_Hybrid(Elektro/Benzin)': this.mapToValueDependOnPath(
|
|
58
|
+
'consumption.consumptionCombined',
|
|
59
|
+
'consumption.fuel',
|
|
60
|
+
'selector_fuel_hybridElectricalPetrol',
|
|
61
|
+
),
|
|
62
|
+
'consumptioncombined_Hybrid(Elektro/Diesel)': this.mapToValueDependOnPath(
|
|
63
|
+
'consumption.consumptionCombined',
|
|
64
|
+
'consumption.fuel',
|
|
65
|
+
'selector_fuel_hybridElectricalDiesel',
|
|
66
|
+
),
|
|
67
|
+
consumptioncombined_Gemisch: this.mapToValueDependOnPath(
|
|
68
|
+
'consumption.consumptionCombined',
|
|
69
|
+
'consumption.fuel',
|
|
70
|
+
'selector_fuel_ethanol',
|
|
71
|
+
),
|
|
72
|
+
consumptioncombined_Erdgas: this.mapToValueDependOnPath(
|
|
73
|
+
'consumption.consumptionCombined',
|
|
74
|
+
'consumption.fuel',
|
|
75
|
+
'selector_fuel_naturalGas',
|
|
76
|
+
),
|
|
77
|
+
consumptioncombined_Elektro: this.mapToValueDependOnPath(
|
|
78
|
+
'consumption.consumptionCombined',
|
|
79
|
+
'consumption.fuel',
|
|
80
|
+
'selector_fuel_electrical',
|
|
81
|
+
),
|
|
82
|
+
consumptioncombined_Autogas: this.mapToValueDependOnPath(
|
|
83
|
+
'consumption.consumptionCombined',
|
|
84
|
+
'consumption.fuel',
|
|
85
|
+
'selector_fuel_carGas',
|
|
86
|
+
),
|
|
87
|
+
consumptioncombined_Ethanol: this.mapToValueDependOnPath(
|
|
88
|
+
'consumption.consumptionCombined',
|
|
89
|
+
'consumption.fuel',
|
|
90
|
+
'selector_fuel_hydrogen',
|
|
91
|
+
),
|
|
92
|
+
consumptioncombined_Wasserstoff: '',
|
|
93
|
+
|
|
94
|
+
constructionYear: 'mainData.constructionYear',
|
|
95
|
+
first_registration: (car: DataSchemes.Car) => {
|
|
96
|
+
const val = get(car, 'mainData.firstRegistration');
|
|
97
|
+
return moment(toSafeInteger(val) * 1000).format('MM/YYYY');
|
|
98
|
+
},
|
|
99
|
+
Condition_New: this.mapToValue('mainData.condition', 'selector_condition_new', 'Neuwagen'),
|
|
100
|
+
Condition_Used: this.mapToValue('mainData.condition', 'selector_condition_used', 'Gebraucht'),
|
|
101
|
+
Mileage: 'mainData.mileage',
|
|
102
|
+
Amount_Owner: this.mapToNumber('mainData.numberOfPreviousOwners', 1, 0),
|
|
103
|
+
highSpeed: 'engineData.highSpeed',
|
|
104
|
+
cylinders: 'engineData.cylinders',
|
|
105
|
+
|
|
106
|
+
cylinders_word: (car: DataSchemes.Car) => {
|
|
107
|
+
const map = {
|
|
108
|
+
1: 'Ein',
|
|
109
|
+
2: 'Zwei',
|
|
110
|
+
3: 'Drei',
|
|
111
|
+
4: 'Vier',
|
|
112
|
+
5: 'Fünf',
|
|
113
|
+
6: 'Sechs',
|
|
114
|
+
7: 'Sieben',
|
|
115
|
+
8: 'Acht',
|
|
116
|
+
9: 'Neun',
|
|
117
|
+
10: 'Zehn',
|
|
118
|
+
12: 'Zwölf',
|
|
119
|
+
14: 'Vierzehn',
|
|
120
|
+
16: 'Sechzehn',
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const cylinders = get(car, 'engineData.cylinders');
|
|
124
|
+
if (!cylinders) {
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return map[toSafeInteger(cylinders)];
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
Drivetype_Heckantrieb: this.mapToValue(
|
|
132
|
+
'driveSuspension.driveType',
|
|
133
|
+
'selector_driveType_rearWheelDrive',
|
|
134
|
+
'Heckantrieb',
|
|
135
|
+
),
|
|
136
|
+
Drivetype_Frontantrieb: this.mapToValue(
|
|
137
|
+
'driveSuspension.driveType',
|
|
138
|
+
'selector_driveType_frontWheelDrive',
|
|
139
|
+
'Frontantrieb',
|
|
140
|
+
),
|
|
141
|
+
Drivetype_allrad: this.mapToValue('driveSuspension.driveType', 'selector_driveType_allWheelDrive', 'Allrad'),
|
|
142
|
+
weight: this.mapToNumber('sizeVolumeWeight.emptyWeight'),
|
|
143
|
+
length: this.mapToNumber('sizeVolumeWeight.length', 10, 1),
|
|
144
|
+
gearbox_manuell: this.mapToValue('driveSuspension.gearbox', 'selector_gearbox_manualShift', 'Handschaltung'),
|
|
145
|
+
gearbox_automatik: this.mapToValue('driveSuspension.gearbox', 'selector_gearbox_automatic', 'Automatik'),
|
|
146
|
+
gearbox_semiAutomatik: this.mapToValue(
|
|
147
|
+
'driveSuspension.gearbox',
|
|
148
|
+
'selector_gearbox_semiAutomatic',
|
|
149
|
+
'Semi Automatik',
|
|
150
|
+
),
|
|
151
|
+
gearbox_unknown: this.mapToValue('driveSuspension.gearbox', 'selector_unknown', 'unknown'),
|
|
152
|
+
|
|
153
|
+
acceleration100: 'engineData.acceleration100',
|
|
154
|
+
|
|
155
|
+
gears_automatik: (car: DataSchemes.Car) => {
|
|
156
|
+
const box = get(car, 'driveSuspension.gearbox');
|
|
157
|
+
if (box === 'selector_gearbox_automatic' || box === 'selector_gearbox_semiAutomatic') {
|
|
158
|
+
return get(car, 'driveSuspension.gears');
|
|
159
|
+
}
|
|
160
|
+
return '';
|
|
161
|
+
},
|
|
162
|
+
gears_Manuell: (car: DataSchemes.Car) => {
|
|
163
|
+
const box = get(car, 'driveSuspension.gearbox');
|
|
164
|
+
if (box === 'selector_gearbox_manualShift') {
|
|
165
|
+
return get(car, 'driveSuspension.gears');
|
|
166
|
+
}
|
|
167
|
+
return '';
|
|
168
|
+
},
|
|
169
|
+
fuel_Benzin: this.mapToValue('consumption.fuel', 'selector_fuel_petrol', 'Benzin'),
|
|
170
|
+
fuel_Diesel: this.mapToValue('consumption.fuel', 'selector_fuel_diesel', 'Diesel'),
|
|
171
|
+
'fuel_Hybrid (Elektro/Benzin)': this.mapToValue(
|
|
172
|
+
'consumption.fuel',
|
|
173
|
+
'selector_fuel_hybridElectricalPetrol',
|
|
174
|
+
'Hybrid (Elektro/Benzin)',
|
|
175
|
+
),
|
|
176
|
+
'fuel_Hybrid (Elektro/Diesel)': this.mapToValue(
|
|
177
|
+
'consumption.fuel',
|
|
178
|
+
'selector_fuel_hybridElectricalDiesel',
|
|
179
|
+
'Hybrid (Elektro/Diesel)',
|
|
180
|
+
),
|
|
181
|
+
fuel_Elektro: this.mapToValue('consumption.fuel', 'selector_fuel_electrical', 'Elektro'),
|
|
182
|
+
fuel_autogas: this.mapToValue('consumption.fuel', 'selector_fuel_carGas', 'autogas'),
|
|
183
|
+
fuel_Erdgas: this.mapToValue('consumption.fuel', 'selector_fuel_naturalGas', 'Erdgas'),
|
|
184
|
+
fuel_Ethanol: this.mapToValue('consumption.fuel', 'selector_fuel_ethanol', 'Ethanol'),
|
|
185
|
+
fuel_Gemisch: this.mapToValue('consumption.fuel', 'selector_fuel_hydrogen', 'Ethanol'),
|
|
186
|
+
fuel_unknown: this.mapToValue('consumption.fuel', 'selector_unknown', 'unknown'),
|
|
187
|
+
CO2: 'environmentEmissions.co2',
|
|
188
|
+
doors: 'mainData.doors',
|
|
189
|
+
seats: 'mainData.seats',
|
|
190
|
+
category_Kleinwagen: this.mapToValue('mainData.category', 'selector_category_compact', 'Kleinwagen'),
|
|
191
|
+
Category_Limousine: this.mapToValue('mainData.category', 'selector_category_sedan', 'Limousine'),
|
|
192
|
+
category_Kombi: this.mapToValue('mainData.category', 'selector_category_combi', 'Kombi'),
|
|
193
|
+
'category_SUV/Geländewagen': this.mapToValue('mainData.category', 'selector_category_suv', 'SUV'),
|
|
194
|
+
category_Transporter: this.mapToValue('mainData.category', 'selector_category_transporter', 'Transporter'),
|
|
195
|
+
// tslint:disable-next-line
|
|
196
|
+
category_Coupé: this.mapToValue('mainData.category', 'selector_category_coupe', 'Coupé'),
|
|
197
|
+
Category_cabrio: this.mapToValue('mainData.category', 'selector_category_convertible', 'cabrio'),
|
|
198
|
+
category_Pickup: this.mapToValue('mainData.category', 'selector_category_transporter', 'Pickup'),
|
|
199
|
+
category_Van: this.mapToValue('mainData.category', 'selector_category_van|selector_category_minibus', 'Van'),
|
|
200
|
+
torque_in_norm: 'engineData.torque',
|
|
201
|
+
count_of_airbags: 'airbags.airbagCount',
|
|
202
|
+
Fahrer_Airbag: this.checkInArray('airbags.airbag', 'selector_airbag_driver', 'Fahrerairbag'),
|
|
203
|
+
Beifahrer_Airbag: this.checkInArray('airbags.airbag', 'selector_airbag_passenger', 'Beifahrerairbag'),
|
|
204
|
+
Kopf_Airbag: this.checkInArray('airbags.airbag', 'selector_airbag_head', 'Kopfairbag'),
|
|
205
|
+
ABS: this.checkBoolean('assistants.abs', 'ABS'),
|
|
206
|
+
ESP: this.checkBoolean('assistants.esp', 'ESP'),
|
|
207
|
+
Traktionskontrolle: this.checkBoolean('assistants.tractionControlSystem', 'Traktionskontrolle'),
|
|
208
|
+
Spurhalteassistent: this.checkBoolean('assistants.laneAssistant', 'Spurhalteassistent'),
|
|
209
|
+
Spurwechselassistent: this.checkBoolean('assistants.laneAssistant', 'Spurwechselassistent'),
|
|
210
|
+
'Bi-Xenon_Licht': this.checkBoolean('lights.xenonHeadlights', 'Bi-Xenon-Licht'),
|
|
211
|
+
Tagfahrlicht: this.checkBoolean(
|
|
212
|
+
'lights.daytimeRunningLights|lights.daytimeRunningLightsLED',
|
|
213
|
+
'Spurhalteassistent',
|
|
214
|
+
),
|
|
215
|
+
'LED-Scheinwerfer': this.checkBoolean('lights.daytimeRunningLightsLED', 'LED-Scheinwerfer'),
|
|
216
|
+
'LED Nebel': this.checkBoolean('lights.frontFogLights', 'LED-Nebelscheinwerfer'),
|
|
217
|
+
Xenon: this.checkBoolean('lights.xenonHeadlights', 'Xenonscheinwerfer'),
|
|
218
|
+
Servolenkung: this.checkBoolean('assistants.powerAssistedSteering', 'Servolenkung'),
|
|
219
|
+
Zentralverriegelung: this.checkBoolean('doors.centralLocking', 'Zentralverriegelung'),
|
|
220
|
+
Keyless_Go: this.checkBoolean('doors.keylessEntry', 'Keyless-Go'),
|
|
221
|
+
elektrische_Heckklappe: this.checkBoolean('doors.electricTailGate', 'elektrische Heckklappe'),
|
|
222
|
+
Klimaanlage: this.checkBoolean('climatisation.selector_none', 'Klimaanlage', false),
|
|
223
|
+
Klimaautomatik: this.checkBoolean('climatisation.selector_climatisation_automaticAirCondition', 'Klimaautomatik'),
|
|
224
|
+
'2_Zonen_Klimautomatik': this.checkBoolean(
|
|
225
|
+
'climatisation.selector_climatisation_automaticAirCondition',
|
|
226
|
+
'2-Zonen-Klimautomatik',
|
|
227
|
+
),
|
|
228
|
+
'3_Zonen_Klimaautomatik': this.checkBoolean(
|
|
229
|
+
'climatisation.selector_climatisation_automaticAirCondition',
|
|
230
|
+
'3-Zonen-Klimaautomatik',
|
|
231
|
+
),
|
|
232
|
+
'4_Zonen_Klimaautomatik': this.checkBoolean(
|
|
233
|
+
'climatisation.selector_climatisation_automaticAirCondition',
|
|
234
|
+
'4-Zonen-Klimaautomatik',
|
|
235
|
+
),
|
|
236
|
+
Multifunktionslenkrad: this.checkBoolean('wheel.multifunctionalWheel', 'Multifunktionslenkrad'),
|
|
237
|
+
Lenkradheizung: this.checkBoolean('wheel.heatedSteeringWheel', 'Lenkradheizung'),
|
|
238
|
+
Sitzheizung: this.checkBoolean('heatingCooling.auxiliaryHeating', 'Ja'),
|
|
239
|
+
Navigationssystem: this.checkBoolean('multimedia.navigationSystem', 'Navigationssystem'),
|
|
240
|
+
Sprachsteuerung: this.checkBoolean('multimedia.voiceControl', 'Sprachsteuerung'),
|
|
241
|
+
Start_Stop_Automatik: this.checkBoolean('engineData.startStopSystem', 'Start/Stop-Automatik'),
|
|
242
|
+
USB_Anschluss: this.checkBoolean('multimedia.usbInterface', 'USB-Anschluss'),
|
|
243
|
+
'USB_Schnittstelle /Bluetooth': this.checkBoolean('multimedia.bluetooth', 'USB_Schnittstelle /Bluetooth'),
|
|
244
|
+
max_emission_category: this.mapSelection('environmentEmissions.emissionClass'),
|
|
245
|
+
Seitenairbag:
|
|
246
|
+
this.checkInArray('airbags.airbag', 'selector_airbag_frontSideAndOther', 'Seitenairbag') ||
|
|
247
|
+
this.checkInArray('airbags.airbag', 'selector_airbag_frontAndSide', 'Seitenairbag'),
|
|
248
|
+
min_tank: 'sizeVolumeWeight.fuelCapacity',
|
|
249
|
+
Varnish: this.mapSelection('exterior.exteriorColor'),
|
|
250
|
+
Varnish_make: 'exterior.manufacturerColorName',
|
|
251
|
+
Interieur_Color: this.mapSelection('interior.interiorColor'),
|
|
252
|
+
Upholstery: this.mapSelection('interior.interiorType'),
|
|
253
|
+
accident_free: this.checkBoolean('mainData.accidentDamaged', 'Unfallfrei', false),
|
|
254
|
+
not_accident_free: this.checkBoolean('mainData.accidentDamaged', 'Beschädigt'),
|
|
255
|
+
Availability: (car: DataSchemes.Car) => {
|
|
256
|
+
const val = get(car, 'offer.availabilityMode');
|
|
257
|
+
if (val === 'selector_availabilityMode_always') return 'Sofort';
|
|
258
|
+
const date = get(car, 'offer.availabilityFrom');
|
|
259
|
+
return moment(toSafeInteger(date) * 1000).format('DD.MM.YYYY');
|
|
260
|
+
},
|
|
261
|
+
Parkassistent: (car: DataSchemes.Car) => {
|
|
262
|
+
const parks = get(car, 'assistants.parkingAssistants', []).filter(
|
|
263
|
+
(selector: string) => selector !== 'selector_unknown',
|
|
264
|
+
);
|
|
265
|
+
return parks.length ? 'Parkassistent' : '';
|
|
266
|
+
},
|
|
267
|
+
Freisprechanlage: this.checkBoolean('multimedia.handsFreePhoneSystem', 'Freisprechanlage'),
|
|
268
|
+
Car_Play: this.checkBoolean('multimedia.carplay', 'Car Play'),
|
|
269
|
+
Garantie: this.checkBoolean('offer.warranty', 'Garantie'),
|
|
270
|
+
Scheckheftgepflegt: this.checkBoolean('careService.fullServiceHistory', 'Scheckheftgepflegt'),
|
|
271
|
+
Regensenor: this.checkBoolean('assistants.automaticRainSensor', 'Regensenor'),
|
|
272
|
+
Tempomat: this.checkBoolean('assistants.cruiseControl', 'Tempomat'),
|
|
273
|
+
Panoramaschiebedach: this.checkBoolean('window.panoramaFrontWindow', 'Panoramaschiebedach'),
|
|
274
|
+
HU_Date: (car: DataSchemes.Car) => {
|
|
275
|
+
const date = get(car, 'careService.generalInspection');
|
|
276
|
+
if (!date) {
|
|
277
|
+
return '';
|
|
278
|
+
}
|
|
279
|
+
return moment(toSafeInteger(date) * 1000).format('DD.MM.YYYY');
|
|
280
|
+
},
|
|
281
|
+
Abstandsregeltempomat: this.checkBoolean('assistants.adaptiveCruiseControl', 'Abstandsregeltempomat'),
|
|
282
|
+
Verkehrszeichen_Erkennung: this.checkBoolean('assistants.trafficSignRecognition', 'Verkehrszeichen-Erkennung'),
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
return Object.entries(mapping)
|
|
286
|
+
.reverse()
|
|
287
|
+
.reduce(
|
|
288
|
+
(transformed, [key, value]) => {
|
|
289
|
+
return { [key]: this.transformValue(car, value as string), ...transformed };
|
|
290
|
+
},
|
|
291
|
+
{ UID: index },
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private transformValue(car: DataSchemes.Car, value: string | transformFn): unknown {
|
|
296
|
+
if (isString(value)) {
|
|
297
|
+
return get(car, value);
|
|
298
|
+
}
|
|
299
|
+
return value(car, this.translator);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private mapToValue(path: string, selection: string, value: string): (car: DataSchemes.Car) => string {
|
|
303
|
+
return (car: DataSchemes.Car) => {
|
|
304
|
+
const cond = get(car, path);
|
|
305
|
+
const selections = selection.split('|');
|
|
306
|
+
return selections.some(sel => sel === cond) ? value : '';
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
private mapToNumber(path: string, divider = 1000, toFix = 1): (car: DataSchemes.Car) => number | '' {
|
|
311
|
+
return (car: DataSchemes.Car) => {
|
|
312
|
+
const data = get(car, path);
|
|
313
|
+
const value = toNumber((toSafeInteger(data) / divider).toFixed(toFix));
|
|
314
|
+
return value > 0.0 ? value : '';
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
private mapToValueDependOnPath(
|
|
319
|
+
valuePath: string,
|
|
320
|
+
conditionPath: string,
|
|
321
|
+
selection: string,
|
|
322
|
+
): (car: DataSchemes.Car) => any {
|
|
323
|
+
return (car: DataSchemes.Car) => {
|
|
324
|
+
const value = get(car, valuePath);
|
|
325
|
+
const cond = get(car, conditionPath);
|
|
326
|
+
return cond === selection ? value : '';
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private checkBoolean(path: string, value: string, boolean = true): (car: DataSchemes.Car) => string {
|
|
331
|
+
return (car: DataSchemes.Car) => {
|
|
332
|
+
return path
|
|
333
|
+
.split('|')
|
|
334
|
+
.map(path => get(car, path))
|
|
335
|
+
.some(cond => cond === boolean)
|
|
336
|
+
? value
|
|
337
|
+
: '';
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
private checkInArray(path: string, selector: string, value: string): (car: DataSchemes.Car) => string {
|
|
342
|
+
return (car: DataSchemes.Car) => {
|
|
343
|
+
const cond = get(car, path) as string[];
|
|
344
|
+
return cond.some((sel: string) => sel === selector) ? value : '';
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
private mapSelection(path: string): (car: DataSchemes.Car, translator: Translator) => any {
|
|
349
|
+
return (car: DataSchemes.Car, translator: Translator) => {
|
|
350
|
+
const selection = get(car, path);
|
|
351
|
+
return translator.translateVal(selection);
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
}
|