Add skeletton for profile page

This commit is contained in:
kevinpauer
2022-04-03 22:32:20 +02:00
parent 9de1258f7f
commit 9115908365
13 changed files with 392 additions and 4 deletions

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { BotService } from './bot.service';
describe('BotService', () => {
let service: BotService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(BotService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,31 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { TokenStorageService } from './token.service';
const API_URL = 'https://gruppe1.testsites.info/api/';
@Injectable({
providedIn: 'root',
})
export class BotService {
constructor(
private http: HttpClient,
private tokenStorage: TokenStorageService
) {}
/**
* @param {string} telegramUserID
* @returns Observable
*/
public createTransaction(telegram_user_id: string): Observable<any> {
return this.http.post(API_URL + 'telegram', {
headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer ' + this.tokenStorage.getToken(),
}),
responseType: 'text',
telegram_user_id,
});
}
}

View File

@@ -16,6 +16,42 @@ export class DataService {
private tokenStorage: TokenStorageService
) {}
/**
* @returns Observable
*/
public getUserData(): Observable<any> {
return this.http.get(API_URL + 'user', {
headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer ' + this.tokenStorage.getToken(),
}),
responseType: 'text',
});
}
/**
* @param {string} email
* @param {string} username
* @param {string} password
* @returns Observable
*/
public updateUserData(
email: string,
username: string,
password: string
): Observable<any> {
return this.http.put(API_URL + 'user', {
headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer ' + this.tokenStorage.getToken(),
}),
responseType: 'text',
email,
username,
password,
});
}
/**
* @returns Observable
*/
@@ -55,6 +91,7 @@ export class DataService {
count: BigInt,
price: number
): Observable<any> {
time = time + 'T12:00:00.000';
return this.http.post(API_URL + 'transactions', {
headers: new HttpHeaders({
'Content-Type': 'application/json',