@bytebrand/export-cars 1.2.0 → 1.2.1
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 +1 -4
- package/dist/transformers/rubrikk.transformer.js +29 -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 +31 -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.1",
|
|
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": "13a4edb8d673e76002d9f6232d409a704e366607"
|
|
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: 'l',
|
|
76
|
+
motoring__fuel_consumption_combined_unit: 'l/100km',
|
|
86
77
|
motoring__fuel_consumption_extra_urban: get(car, 'consumption.consumptionOuter', null),
|
|
87
|
-
motoring__fuel_consumption_extra_urban_unit: 'l',
|
|
78
|
+
motoring__fuel_consumption_extra_urban_unit: 'l/100km',
|
|
88
79
|
motoring__fuel_consumption_urban: get(car, 'consumption.consumptionInner', null),
|
|
89
|
-
motoring__fuel_consumption_urban_unit: 'l',
|
|
80
|
+
motoring__fuel_consumption_urban_unit: 'l/100km',
|
|
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),
|
|
@@ -130,20 +121,20 @@ export class RubrikkTransformer {
|
|
|
130
121
|
|
|
131
122
|
private getCarLink(car: DataSchemes.Car): string {
|
|
132
123
|
const autodeId = toString(get(car, '_id', ''));
|
|
133
|
-
return `https://www
|
|
124
|
+
return `https://www${this.configService.config.url}/search/vehicle/${autodeId}?source=classifieds&medium=listing&campaign=focus`;
|
|
134
125
|
}
|
|
135
126
|
|
|
136
127
|
private getImageLink(car: DataSchemes.Car): string {
|
|
137
128
|
const mainImageId = get(car, 'metaData.mainImageId', '');
|
|
138
129
|
return mainImageId
|
|
139
|
-
? `https
|
|
140
|
-
:
|
|
130
|
+
? `https://${this.configService.config.imageUrl}carimage/${car._id}/${mainImageId}/large-cached.webp`
|
|
131
|
+
: `https://${this.configService.config.imageUrl}/carimage/noimage/7pNvWELuWhZX/large-cached.jpeg`;
|
|
141
132
|
}
|
|
142
133
|
|
|
143
134
|
private getImagesLinks(carId: string, images: ImboImageResponseInterface[]): string[] {
|
|
144
135
|
if (isNotEmptyArray(images)) {
|
|
145
136
|
return images.map((image: ImboImageResponseInterface) => {
|
|
146
|
-
return
|
|
137
|
+
return `https://${this.configService.config.url}/carimage/${carId}/${image.imageIdentifier}/large`;
|
|
147
138
|
});
|
|
148
139
|
}
|
|
149
140
|
return [];
|
|
@@ -167,64 +158,23 @@ export class RubrikkTransformer {
|
|
|
167
158
|
return get(available, energyClass);
|
|
168
159
|
}
|
|
169
160
|
|
|
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
161
|
private getColor(car: DataSchemes.Car): string {
|
|
212
|
-
let colorSelection = get(car, 'exterior.exteriorColor', '
|
|
162
|
+
let colorSelection = get(car, 'exterior.exteriorColor', 'selector_unknown');
|
|
213
163
|
if (!colorSelection || colorSelection === 'selector_unknown') {
|
|
214
|
-
colorSelection = '
|
|
164
|
+
colorSelection = 'selector_unknown';
|
|
215
165
|
}
|
|
216
166
|
return this.translator.translateVal(colorSelection);
|
|
217
167
|
}
|
|
218
168
|
|
|
219
169
|
private getDrivetrain(car: DataSchemes.Car): string {
|
|
220
170
|
const available = {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
171
|
+
selector_gearbox_manualShift: 'Manual',
|
|
172
|
+
selector_gearbox_semiAutomatic: 'Automatic',
|
|
173
|
+
selector_gearbox_automatic: 'Automatic',
|
|
174
|
+
selector_unknown: 'N/A',
|
|
225
175
|
};
|
|
226
|
-
const
|
|
227
|
-
return get(available,
|
|
176
|
+
const transmission = get(car, 'driveSuspension.gearbox', 'selector_unknown');
|
|
177
|
+
return get(available, transmission);
|
|
228
178
|
}
|
|
229
179
|
|
|
230
180
|
private getYear(car: DataSchemes.Car): number {
|
|
@@ -234,4 +184,16 @@ export class RubrikkTransformer {
|
|
|
234
184
|
}
|
|
235
185
|
return 0;
|
|
236
186
|
}
|
|
187
|
+
|
|
188
|
+
private getDriveType(car: DataSchemes.Car): string {
|
|
189
|
+
const available = {
|
|
190
|
+
selector_unknown: 'N/A',
|
|
191
|
+
selector_driveType_frontWheelDrive: 'FWD',
|
|
192
|
+
selector_driveType_rearWheelDrive: 'RWD',
|
|
193
|
+
selector_driveType_allWheelDrive: 'AWD',
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const driveType = get(car, 'driveSuspension.driveType', 'selector_unknown');
|
|
197
|
+
return get(available, driveType) || 'N/A';
|
|
198
|
+
}
|
|
237
199
|
}
|