@bytebrand/export-cars 1.2.0 → 1.2.2
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/dist/config/kleinanzeigeFocus.config.js +1 -1
- package/dist/config/kleinanzeigeFocus.config.js.map +1 -1
- package/dist/interfaces/export-item.interface.d.ts +0 -6
- package/dist/transformers/rubrikk.transformer.d.ts +2 -4
- package/dist/transformers/rubrikk.transformer.js +33 -60
- package/dist/transformers/rubrikk.transformer.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/config/kleinanzeigeFocus.config.ts +1 -1
- package/src/interfaces/export-item.interface.ts +0 -6
- package/src/transformers/rubrikk.transformer.ts +36 -69
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebrand/export-cars",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "bytebrand",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": ">=14.0.0"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "61c542cb69c0f3b94250dc2ac4b30b47b29b170a"
|
|
69
69
|
}
|
|
@@ -7,6 +7,6 @@ export class KleinanzeigeFocusConfig extends Config {
|
|
|
7
7
|
this.pathesConfig.localConvertedDirectory = this.environmentConfig[params.environment].localConvertedDirectory;
|
|
8
8
|
this.pathesConfig.remoteDirectory = this.environmentConfig[params.environment].remoteDirectory;
|
|
9
9
|
this.imageUrl = this.environmentConfig[params.environment].imageUrl;
|
|
10
|
-
this.outputFiles = ['
|
|
10
|
+
this.outputFiles = ['api_export_cars_focus.xml'];
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -164,15 +164,9 @@ export interface RubrikkXmlItem {
|
|
|
164
164
|
advertiser__email: string;
|
|
165
165
|
advertiser__name_company_name: string;
|
|
166
166
|
advertiser__phone: string;
|
|
167
|
-
advertiser__type: string;
|
|
168
|
-
advertiser__company_employee: string;
|
|
169
|
-
location__abroad_region: string;
|
|
170
167
|
location__country: string;
|
|
171
168
|
location__municipality_city: string;
|
|
172
169
|
location__zip_postal_code: string;
|
|
173
|
-
location__streetaddress: string;
|
|
174
|
-
location__latitude: number;
|
|
175
|
-
location__longitude: number;
|
|
176
170
|
motoring__body_type: string;
|
|
177
171
|
motoring__color: string;
|
|
178
172
|
motoring__drivetrain: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { escape, get, isEmpty, join, toNumber, toSafeInteger, toString, trim } from 'lodash';
|
|
2
2
|
import { Injectable } from '@nestjs/common';
|
|
3
3
|
|
|
4
|
-
import { DePostalCodesEntryInterface } from '@bytebrand/car-basic-data-scope/dist/interfaces/DePostalCodesInterface';
|
|
5
4
|
import { de, deVehicleDetailsPage, deVehicleProps } from '@bytebrand/i18n-dictionaries';
|
|
6
5
|
import { DePostalCodesService } from '@bytebrand/car-basic-data-scope';
|
|
7
6
|
import { TranslatorExtended } from '@bytebrand/schema-tools';
|
|
@@ -32,8 +31,6 @@ export class RubrikkTransformer {
|
|
|
32
31
|
images: ImboImageResponseInterface[];
|
|
33
32
|
}): Promise<RubrikkXmlItem> {
|
|
34
33
|
const autodeId = toString(get(car, '_id', ''));
|
|
35
|
-
const region = await this.getRegion(car);
|
|
36
|
-
const { longitude, latitude } = await this.getCoords(car);
|
|
37
34
|
|
|
38
35
|
return {
|
|
39
36
|
//Common Fields
|
|
@@ -50,8 +47,8 @@ export class RubrikkTransformer {
|
|
|
50
47
|
ad__number_ad__number_reference_id: toString(get(car, 'metaData.vehicleId', '')),
|
|
51
48
|
|
|
52
49
|
//Categorization
|
|
53
|
-
category_original: '
|
|
54
|
-
maincategory_original: '
|
|
50
|
+
category_original: 'Autos',
|
|
51
|
+
maincategory_original: 'Fahrzeuge',
|
|
55
52
|
|
|
56
53
|
//Advertiser Info
|
|
57
54
|
advertiser__company_homepage_url: 'https://www.auto.de',
|
|
@@ -59,34 +56,28 @@ export class RubrikkTransformer {
|
|
|
59
56
|
'https://autode-static.de/wp-content/themes/autode/front/img/header/b_logo_autode.svg',
|
|
60
57
|
advertiser__email: 'auto@auto.de',
|
|
61
58
|
advertiser__name_company_name: 'Auto.de',
|
|
62
|
-
advertiser__phone: '+
|
|
63
|
-
advertiser__type: 'Dealer',
|
|
64
|
-
advertiser__company_employee: 'auto.de',
|
|
59
|
+
advertiser__phone: '+498004030182',
|
|
65
60
|
|
|
66
61
|
// Geography Info
|
|
67
|
-
location__abroad_region: region,
|
|
68
62
|
location__country: 'Deutschland',
|
|
69
63
|
location__municipality_city: get(car, 'location.city', ''),
|
|
70
64
|
location__zip_postal_code: toString(get(car, 'location.zipCode', '')),
|
|
71
|
-
location__streetaddress: this.getStreetAddress(car),
|
|
72
|
-
location__longitude: longitude,
|
|
73
|
-
location__latitude: latitude,
|
|
74
65
|
|
|
75
66
|
// Motoring Fields
|
|
76
67
|
motoring__body_type: this.translateSelector(get(car, 'mainData.category', '')),
|
|
77
68
|
motoring__color: this.getColor(car),
|
|
78
|
-
motoring__drivetrain: this.
|
|
69
|
+
motoring__drivetrain: this.getDriveType(car),
|
|
79
70
|
motoring__emission_class: this.translateSelector(get(car, 'environmentEmissions.emissionClass', '')),
|
|
80
71
|
motoring__emission_co2: get(car, 'environmentEmissions.co2', null),
|
|
81
72
|
motoring__emission_co2_unit: 'g/km',
|
|
82
73
|
motoring__emission_sticker: this.translateSelector(get(car, 'environmentEmissions.emissionSticker', '')),
|
|
83
74
|
motoring__engine_displacement_cubic_centimeters: toNumber(get(car, 'engineData.cubicCapacity', null)),
|
|
84
75
|
motoring__fuel_consumption_combined: get(car, 'consumption.consumptionCombined', null),
|
|
85
|
-
motoring__fuel_consumption_combined_unit:
|
|
76
|
+
motoring__fuel_consumption_combined_unit: this.getUrbanUnit(car),
|
|
86
77
|
motoring__fuel_consumption_extra_urban: get(car, 'consumption.consumptionOuter', null),
|
|
87
|
-
motoring__fuel_consumption_extra_urban_unit:
|
|
78
|
+
motoring__fuel_consumption_extra_urban_unit: this.getUrbanUnit(car),
|
|
88
79
|
motoring__fuel_consumption_urban: get(car, 'consumption.consumptionInner', null),
|
|
89
|
-
motoring__fuel_consumption_urban_unit:
|
|
80
|
+
motoring__fuel_consumption_urban_unit: this.getUrbanUnit(car),
|
|
90
81
|
motoring__fuel_type: this.translateSelector(get(car, 'consumption.fuel', '')),
|
|
91
82
|
motoring__make: toString(get(car, 'mainData.make', '')),
|
|
92
83
|
motoring__mileage_kilometers: get(car, 'mainData.mileage', null),
|
|
@@ -100,6 +91,11 @@ export class RubrikkTransformer {
|
|
|
100
91
|
};
|
|
101
92
|
}
|
|
102
93
|
|
|
94
|
+
private getUrbanUnit(car: DataSchemes.Car) {
|
|
95
|
+
const fuel_type = this.translateSelector(get(car, 'consumption.fuel', ''));
|
|
96
|
+
return fuel_type === 'Elektro' ? 'kWt/100km' : 'l/100km';
|
|
97
|
+
}
|
|
98
|
+
|
|
103
99
|
private translateSelector(selector: string): string {
|
|
104
100
|
if (isEmpty(selector) || selector === 'selector_unknown') {
|
|
105
101
|
return '';
|
|
@@ -130,20 +126,20 @@ export class RubrikkTransformer {
|
|
|
130
126
|
|
|
131
127
|
private getCarLink(car: DataSchemes.Car): string {
|
|
132
128
|
const autodeId = toString(get(car, '_id', ''));
|
|
133
|
-
return `https
|
|
129
|
+
return `https://${this.configService.config.url}/search/vehicle/${autodeId}?source=classifieds&medium=listing&campaign=focus`;
|
|
134
130
|
}
|
|
135
131
|
|
|
136
132
|
private getImageLink(car: DataSchemes.Car): string {
|
|
137
133
|
const mainImageId = get(car, 'metaData.mainImageId', '');
|
|
138
134
|
return mainImageId
|
|
139
|
-
?
|
|
140
|
-
:
|
|
135
|
+
? `${this.configService.config.imageUrl}carimage/${car._id}/${mainImageId}/large-cached.webp`
|
|
136
|
+
: `${this.configService.config.imageUrl}/carimage/noimage/7pNvWELuWhZX/large-cached.jpeg`;
|
|
141
137
|
}
|
|
142
138
|
|
|
143
139
|
private getImagesLinks(carId: string, images: ImboImageResponseInterface[]): string[] {
|
|
144
140
|
if (isNotEmptyArray(images)) {
|
|
145
141
|
return images.map((image: ImboImageResponseInterface) => {
|
|
146
|
-
return
|
|
142
|
+
return `https://${this.configService.config.url}/carimage/${carId}/${image.imageIdentifier}/large`;
|
|
147
143
|
});
|
|
148
144
|
}
|
|
149
145
|
return [];
|
|
@@ -167,64 +163,23 @@ export class RubrikkTransformer {
|
|
|
167
163
|
return get(available, energyClass);
|
|
168
164
|
}
|
|
169
165
|
|
|
170
|
-
private getStreetAddress(car: DataSchemes.Car): string {
|
|
171
|
-
const street = get(car, 'location.street', '');
|
|
172
|
-
const streetNumber = get(car, 'location.streetNumber', '');
|
|
173
|
-
return trim(escape(join([street, streetNumber], ' ')));
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
private async getRegion(car: DataSchemes.Car): Promise<string> {
|
|
177
|
-
const city: string = get(car, 'location.city', '');
|
|
178
|
-
const zipCode: number = toNumber(get(car, 'location.zipCode', ''));
|
|
179
|
-
|
|
180
|
-
const locationEntity = await this.getLocationByInfo({ city, zip: toSafeInteger(zipCode) });
|
|
181
|
-
return get(locationEntity, 'Place Name', 'Deutschland');
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
private async getCoords(car: DataSchemes.Car): Promise<Pick<DataSchemes.Location, 'latitude' | 'longitude'>> {
|
|
185
|
-
const city: string = get(car, 'location.city', '');
|
|
186
|
-
const zipCode: number = toNumber(get(car, 'location.zipCode', ''));
|
|
187
|
-
const locationEntity = await this.getLocationByInfo({ city, zip: toSafeInteger(zipCode) });
|
|
188
|
-
|
|
189
|
-
const data: Pick<DataSchemes.Location, 'latitude' | 'longitude'> = {
|
|
190
|
-
latitude: get(car, 'location.latitude'),
|
|
191
|
-
longitude: get(car, 'location.longitude'),
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
if (data.latitude && data.longitude) return data;
|
|
195
|
-
|
|
196
|
-
return {
|
|
197
|
-
longitude: get(locationEntity, 'Longitude'),
|
|
198
|
-
latitude: get(locationEntity, 'Latitude'),
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
private async getLocationByInfo(info: { zip: number; city: string }): Promise<DePostalCodesEntryInterface> {
|
|
203
|
-
let entry: DePostalCodesEntryInterface = await this.postalCodesService.getLocationByPostalCode(info.zip);
|
|
204
|
-
|
|
205
|
-
if (!entry) {
|
|
206
|
-
entry = await this.postalCodesService.getLocationByCity(info.city);
|
|
207
|
-
}
|
|
208
|
-
return entry;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
166
|
private getColor(car: DataSchemes.Car): string {
|
|
212
|
-
let colorSelection = get(car, 'exterior.exteriorColor', '
|
|
167
|
+
let colorSelection = get(car, 'exterior.exteriorColor', 'selector_unknown');
|
|
213
168
|
if (!colorSelection || colorSelection === 'selector_unknown') {
|
|
214
|
-
colorSelection = '
|
|
169
|
+
colorSelection = 'selector_unknown';
|
|
215
170
|
}
|
|
216
171
|
return this.translator.translateVal(colorSelection);
|
|
217
172
|
}
|
|
218
173
|
|
|
219
174
|
private getDrivetrain(car: DataSchemes.Car): string {
|
|
220
175
|
const available = {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
176
|
+
selector_gearbox_manualShift: 'Manual',
|
|
177
|
+
selector_gearbox_semiAutomatic: 'Automatic',
|
|
178
|
+
selector_gearbox_automatic: 'Automatic',
|
|
179
|
+
selector_unknown: 'N/A',
|
|
225
180
|
};
|
|
226
|
-
const
|
|
227
|
-
return get(available,
|
|
181
|
+
const transmission = get(car, 'driveSuspension.gearbox', 'selector_unknown');
|
|
182
|
+
return get(available, transmission);
|
|
228
183
|
}
|
|
229
184
|
|
|
230
185
|
private getYear(car: DataSchemes.Car): number {
|
|
@@ -234,4 +189,16 @@ export class RubrikkTransformer {
|
|
|
234
189
|
}
|
|
235
190
|
return 0;
|
|
236
191
|
}
|
|
192
|
+
|
|
193
|
+
private getDriveType(car: DataSchemes.Car): string {
|
|
194
|
+
const available = {
|
|
195
|
+
selector_unknown: 'N/A',
|
|
196
|
+
selector_driveType_frontWheelDrive: 'FWD',
|
|
197
|
+
selector_driveType_rearWheelDrive: 'RWD',
|
|
198
|
+
selector_driveType_allWheelDrive: 'AWD',
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const driveType = get(car, 'driveSuspension.driveType', 'selector_unknown');
|
|
202
|
+
return get(available, driveType) || 'N/A';
|
|
203
|
+
}
|
|
237
204
|
}
|