Add transaction skeletton
This commit is contained in:
@@ -2,16 +2,23 @@ import { Injectable, OnInit } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { delay, Observable } from 'rxjs';
|
||||
import { TokenStorageService } from './token.service';
|
||||
const API_URL = 'https://aktienbot.flokaiser.com/api/';
|
||||
const API_URL = 'https://gruppe1.testsites.info/api/';
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class DataService {
|
||||
/**
|
||||
* @param {HttpClient} privatehttp
|
||||
* @param {TokenStorageService} privatetokenStorage
|
||||
*/
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private tokenStorage: TokenStorageService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @returns Observable
|
||||
*/
|
||||
public getStockData(): Observable<any> {
|
||||
return this.http.get(API_URL + 'portfolio', {
|
||||
headers: new HttpHeaders({
|
||||
@@ -22,6 +29,9 @@ export class DataService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns Observable
|
||||
*/
|
||||
public getTransactionData(): Observable<any> {
|
||||
return this.http.get(API_URL + 'transactions', {
|
||||
headers: new HttpHeaders({
|
||||
@@ -32,6 +42,34 @@ export class DataService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} symbol
|
||||
* @param {Date} time
|
||||
* @param {number} count
|
||||
* @param {number} price
|
||||
* @returns Observable
|
||||
*/
|
||||
public createTransaction(
|
||||
symbol: string,
|
||||
time: Date,
|
||||
count: number,
|
||||
price: number
|
||||
): Observable<any> {
|
||||
return this.http.post(API_URL + 'transactions', {
|
||||
headers: new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: 'Bearer ' + this.tokenStorage.getToken(),
|
||||
}),
|
||||
symbol,
|
||||
time,
|
||||
count,
|
||||
price,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns Observable
|
||||
*/
|
||||
public getKeywords(): Observable<any> {
|
||||
return this.http.get(API_URL + 'keywords', {
|
||||
headers: new HttpHeaders({
|
||||
|
Reference in New Issue
Block a user