2022-04-27 02:52:23 +04:00
|
|
|
import { Injectable } from '@angular/core';
|
2022-05-01 03:01:27 +04:00
|
|
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
2022-04-27 02:52:23 +04:00
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
|
|
|
const API_BASE_URL = '/lightning/api/v1';
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class LightningApiService {
|
|
|
|
constructor(
|
|
|
|
private httpClient: HttpClient,
|
|
|
|
) { }
|
|
|
|
|
2022-04-29 03:57:27 +04:00
|
|
|
getNode$(publicKey: string): Observable<any> {
|
|
|
|
return this.httpClient.get<any>(API_BASE_URL + '/nodes/' + publicKey);
|
|
|
|
}
|
|
|
|
|
2022-05-01 03:01:27 +04:00
|
|
|
getChannel$(shortId: string): Observable<any> {
|
|
|
|
return this.httpClient.get<any>(API_BASE_URL + '/channels/' + shortId);
|
|
|
|
}
|
|
|
|
|
2022-04-29 03:57:27 +04:00
|
|
|
getChannelsByNodeId$(publicKey: string): Observable<any> {
|
2022-05-01 03:01:27 +04:00
|
|
|
let params = new HttpParams()
|
|
|
|
.set('public_key', publicKey)
|
|
|
|
;
|
|
|
|
|
|
|
|
return this.httpClient.get<any>(API_BASE_URL + '/channels', { params });
|
2022-04-29 03:57:27 +04:00
|
|
|
}
|
|
|
|
|
2022-04-27 02:52:23 +04:00
|
|
|
getLatestStatistics$(): Observable<any> {
|
|
|
|
return this.httpClient.get<any>(API_BASE_URL + '/statistics/latest');
|
|
|
|
}
|
|
|
|
|
|
|
|
listTopNodes$(): Observable<any> {
|
|
|
|
return this.httpClient.get<any>(API_BASE_URL + '/nodes/top');
|
|
|
|
}
|
|
|
|
}
|