Skip to content

Commit

Permalink
feat(properties): Add additional properties (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
jroehl authored Jul 3, 2020
1 parent 28f1abc commit 3fc5586
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/classes/portals/Estate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export interface RealEstateDetailedProperties {
residentialUnits: number;
summerResidencePractical: boolean;
usableFloorSpace: number;
totalRent: string | undefined;
serviceCharge: string | undefined;
}

export interface Attachment {
Expand Down
2 changes: 2 additions & 0 deletions src/classes/portals/FlowFact/v1/Estate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export class FlowFactEstateV1 extends Estate {
residentialUnits: this.getValue('residentialUnits'),
summerResidencePractical: this.getValue('summerResidencePractical'),
usableFloorSpace: this.getValue('usableFloorSpace'),
totalRent: undefined,
serviceCharge: undefined,
};
}

Expand Down
13 changes: 12 additions & 1 deletion src/classes/portals/FlowFact/v2/Estate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ export class FlowFactEstateV2 extends Estate {
title: this.getTranslatableValue('headline.values[0]'),
previewImage: this.getPreviewImage(),
updatedAt: this.getDate('_metadata.timestamp'),
totalRent: this.getMonetaryValue('rentinclusiveofheating.values[0]'),
serviceCharge: this.getMonetaryValue('additionalexpenses.values[0]'),
};
}

Expand Down Expand Up @@ -108,10 +110,19 @@ export class FlowFactEstateV2 extends Estate {
if (!price && !rent) return;
return {
value: price || rent,
currency: this.getTranslatableValue('currency.values[0]', '€'),
currency: this.getCurrency(),
};
}

private getMonetaryValue(path: any): string | undefined {
const value = this.getValue(path);
if (value) return `${value} ${this.getCurrency()}`;
}

private getCurrency(): string {
return this.getTranslatableValue('currency.values[0]', '€');
}

private getAddress(): Address {
return {
city: this.getValue('addresses.values[0].city'),
Expand Down
13 changes: 12 additions & 1 deletion src/classes/portals/Immobilienscout24/Estate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export class Immobilienscout24Estate extends Estate {
'@modified',
'@modification',
]),
totalRent: this.getMonetaryValue('totalRent'),
serviceCharge: this.getMonetaryValue('serviceCharge'),
};
}

Expand Down Expand Up @@ -119,7 +121,7 @@ export class Immobilienscout24Estate extends Estate {
const rent = this.getValue('baseRent');
if (!price && !rent) return;

const currency = this.getTranslatableValue('price.currency', '€');
const currency = this.getCurrency();
const priceIntervalType = this.getTranslatableValue('price.intervalType');
return {
value: price || rent,
Expand All @@ -128,6 +130,15 @@ export class Immobilienscout24Estate extends Estate {
};
}

private getMonetaryValue(path: any): string | undefined {
const value = this.getValue(path);
if (value) return `${value} ${this.getCurrency()}`;
}

private getCurrency(): string {
return this.getTranslatableValue('price.currency', '€');
}

private getAddress(): Address | undefined {
return {
city: this.getValue('address.city'),
Expand Down
2 changes: 2 additions & 0 deletions src/lib/get-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class Detailed implements RealEstateDetailedProperties {
residentialUnits!: number;
summerResidencePractical!: boolean;
usableFloorSpace!: number;
totalRent!: string;
serviceCharge!: string;
}

class Ad implements Address {
Expand Down
3 changes: 2 additions & 1 deletion src/translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,8 @@ export default {
rent_and_buy: 'Miete und Kauf',
rent_per_month: 'Miete pro Monat',
rent_per_sqm: 'Miete pro Quadratmeter',
rent: 'Miete',
rent: 'Kaltmiete',
totalrent: 'Warmmiete',
rentalincome: 'Mieteinnahmen pro Monat',
rentalincomeactual: 'Mieteinahmen aktuell',
rentalincometarget: 'Mögliche Mieteinahmen',
Expand Down

0 comments on commit 3fc5586

Please sign in to comment.