Browse Source

Format name

pull/4441/head
Thomas Kaul 1 month ago
parent
commit
228aaf1b5c
  1. 21
      apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts

21
apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts

@ -12,6 +12,7 @@ import {
IDataProviderHistoricalResponse, IDataProviderHistoricalResponse,
IDataProviderResponse IDataProviderResponse
} from '@ghostfolio/api/services/interfaces/interfaces'; } from '@ghostfolio/api/services/interfaces/interfaces';
import { REPLACE_NAME_PARTS } from '@ghostfolio/common/config';
import { DATE_FORMAT, parseDate } from '@ghostfolio/common/helper'; import { DATE_FORMAT, parseDate } from '@ghostfolio/common/helper';
import { import {
DataProviderInfo, DataProviderInfo,
@ -186,7 +187,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
response.isin = assetProfile.isin; response.isin = assetProfile.isin;
} }
response.name = assetProfile.companyName; response.name = this.formatName({ name: assetProfile.companyName });
if (assetProfile.website) { if (assetProfile.website) {
response.url = assetProfile.website; response.url = assetProfile.website;
@ -398,7 +399,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
assetSubClass: undefined, // TODO assetSubClass: undefined, // TODO
dataProviderInfo: this.getDataProviderInfo(), dataProviderInfo: this.getDataProviderInfo(),
dataSource: this.getName(), dataSource: this.getName(),
name: companyName name: this.formatName({ name: companyName })
}; };
}); });
} else { } else {
@ -414,12 +415,12 @@ export class FinancialModelingPrepService implements DataProviderInterface {
items = result.map(({ currency, name, symbol }) => { items = result.map(({ currency, name, symbol }) => {
return { return {
currency, currency,
name,
symbol, symbol,
assetClass: undefined, // TODO assetClass: undefined, // TODO
assetSubClass: undefined, // TODO assetSubClass: undefined, // TODO
dataProviderInfo: this.getDataProviderInfo(), dataProviderInfo: this.getDataProviderInfo(),
dataSource: this.getName() dataSource: this.getName(),
name: this.formatName({ name })
}; };
}); });
} }
@ -438,6 +439,18 @@ export class FinancialModelingPrepService implements DataProviderInterface {
return { items }; return { items };
} }
private formatName({ name }: { name: string }) {
if (name) {
for (const part of REPLACE_NAME_PARTS) {
name = name.replace(part, '');
}
name = name.trim();
}
return name;
}
private getUrl({ version }: { version: number }) { private getUrl({ version }: { version: number }) {
return `https://financialmodelingprep.com/api/v${version}`; return `https://financialmodelingprep.com/api/v${version}`;
} }

Loading…
Cancel
Save