mempool/frontend/src/app/bisq/bisq-api.service.ts

42 lines
1.4 KiB
TypeScript
Raw Normal View History

import { Injectable } from '@angular/core';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
2020-07-14 09:38:52 +02:00
import { BisqTransaction, BisqBlock, BisqStats } from './bisq.interfaces';
2020-07-19 07:57:41 +02:00
const API_BASE_URL = '/bisq/api';
@Injectable({
providedIn: 'root'
})
export class BisqApiService {
apiBaseUrl: string;
constructor(
private httpClient: HttpClient,
) { }
2020-07-14 09:38:52 +02:00
getStats$(): Observable<BisqStats> {
2020-07-19 07:57:41 +02:00
return this.httpClient.get<BisqStats>(API_BASE_URL + '/stats');
2020-07-14 09:38:52 +02:00
}
getTransaction$(txId: string): Observable<BisqTransaction> {
2020-07-19 07:57:41 +02:00
return this.httpClient.get<BisqTransaction>(API_BASE_URL + '/tx/' + txId);
}
listTransactions$(start: number, length: number): Observable<HttpResponse<BisqTransaction[]>> {
2020-07-19 07:57:41 +02:00
return this.httpClient.get<BisqTransaction[]>(API_BASE_URL + `/txs/${start}/${length}`, { observe: 'response' });
}
getBlock$(hash: string): Observable<BisqBlock> {
2020-07-19 07:57:41 +02:00
return this.httpClient.get<BisqBlock>(API_BASE_URL + '/block/' + hash);
}
listBlocks$(start: number, length: number): Observable<HttpResponse<BisqBlock[]>> {
2020-07-19 07:57:41 +02:00
return this.httpClient.get<BisqBlock[]>(API_BASE_URL + `/blocks/${start}/${length}`, { observe: 'response' });
}
2020-07-13 16:46:25 +02:00
getAddress$(address: string): Observable<BisqTransaction[]> {
2020-07-19 07:57:41 +02:00
return this.httpClient.get<BisqTransaction[]>(API_BASE_URL + '/address/' + address);
2020-07-13 16:46:25 +02:00
}
}