2020-07-13 10:16:12 +02:00
|
|
|
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-13 10:16:12 +02:00
|
|
|
|
2020-07-19 07:57:41 +02:00
|
|
|
const API_BASE_URL = '/bisq/api';
|
2020-07-13 10:16:12 +02:00
|
|
|
|
|
|
|
@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
|
|
|
}
|
|
|
|
|
2020-07-13 10:16:12 +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);
|
2020-07-13 10:16:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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' });
|
2020-07-13 10:16:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
getBlock$(hash: string): Observable<BisqBlock> {
|
2020-07-19 07:57:41 +02:00
|
|
|
return this.httpClient.get<BisqBlock>(API_BASE_URL + '/block/' + hash);
|
2020-07-13 10:16:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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 10:16:12 +02:00
|
|
|
}
|
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
|
|
|
}
|
2020-07-13 10:16:12 +02:00
|
|
|
}
|