ghostfolio/apps/client/src/app/services/admin.service.ts

39 lines
894 B
TypeScript
Raw Normal View History

2021-04-13 21:53:58 +02:00
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { DATE_FORMAT } from '@ghostfolio/common/helper';
import { DataSource, MarketData } from '@prisma/client';
import { format } from 'date-fns';
2021-04-13 21:53:58 +02:00
@Injectable({
providedIn: 'root'
})
export class AdminService {
public constructor(private http: HttpClient) {}
public gatherMax() {
return this.http.post<void>(`/api/admin/gather/max`, {});
}
public gatherProfileData() {
return this.http.post<void>(`/api/admin/gather/profile-data`, {});
}
public gatherSymbol({
dataSource,
date,
symbol
}: {
dataSource: DataSource;
date?: Date;
symbol: string;
}) {
let url = `/api/admin/gather/${dataSource}/${symbol}`;
if (date) {
url = `${url}/${format(date, DATE_FORMAT)}`;
}
return this.http.post<MarketData | void>(url, {});
}
2021-04-13 21:53:58 +02:00
}